# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#########
# Grant GCP role Folder Admin on Admin's folder to admin
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicyMember
metadata:
  name: admins.admin1-admin-folder-admin-permissions # kpt-set: admins.${admin-name}-admin-folder-admin-permissions
  namespace: hierarchy
  annotations:
    cnrm.cloud.google.com/ignore-clusterless: "true"
spec:
  resourceRef:
    apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
    kind: Folder
    name: tests.admins.admin1 # kpt-set: tests.admins.${admin-name}
  role: roles/resourcemanager.folderAdmin
  member: admin-owner # kpt-set: ${admin-owner}
---
# Grant GCP role Project Creator on Admin's folder to admin
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicyMember
metadata:
  name: admins.admin1-admin-project-creator-permissions # kpt-set: admins.${admin-name}-admin-project-creator-permissions
  namespace: hierarchy
  annotations:
    cnrm.cloud.google.com/ignore-clusterless: "true"
spec:
  resourceRef:
    apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
    kind: Folder
    name: tests.admins.admin1 # kpt-set: tests.admins.${admin-name}
  role: roles/resourcemanager.projectCreator
  member: admin-owner # kpt-set: ${admin-owner}
---
# Grant GCP role Owner on Admin's folder to admin
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicyMember
metadata:
  name: admins.admin1-admin-owner-permissions # kpt-set: admins.${admin-name}-admin-owner-permissions
  namespace: hierarchy
  annotations:
    cnrm.cloud.google.com/ignore-clusterless: "true"
spec:
  resourceRef:
    apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
    kind: Folder
    name: tests.admins.admin1 # kpt-set: tests.admins.${admin-name}
  role: roles/owner
  member: admin-owner # kpt-set: ${admin-owner}
