Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow duplicate file names in project hierarchy #2661

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions fast/stages/2-project-factory/data/hierarchy/team-a/dev/ce-0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2024 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.

# yaml-language-server: $schema=../../schemas/project.schema.json

name: ta-d-ce-0
iam:
roles/owner:
# refer to the rw service account defined below
- rw
roles/viewer:
# refer to the ro service account defined below
- ro
automation:
# no context is possible here
# use the complete project id
project: xxx-iac-pf-0
service_accounts:
rw:
description: Read/write automation sa for team a dev ce.
ro:
description: Read-only automation sa for team a dev ce.
buckets:
state:
description: Terraform state bucket for team a dev ce.
iam:
roles/storage.objectCreator:
- rw
roles/storage.objectViewer:
- rw
- ro
- group:[email protected]
42 changes: 42 additions & 0 deletions fast/stages/2-project-factory/data/hierarchy/team-b/dev/ce-0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2024 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.

# yaml-language-server: $schema=../../schemas/project.schema.json

iam:
roles/owner:
# refer to the rw service account defined below
- rw
roles/viewer:
# refer to the ro service account defined below
- ro
automation:
# no context is possible here
# use the complete project id
project: xxx-iac-pf-0
service_accounts:
rw:
description: Read/write automation sa for team a dev ce.
ro:
description: Read-only automation sa for team a dev ce.
buckets:
state:
description: Terraform state bucket for team b dev ce.
iam:
roles/storage.objectCreator:
- rw
roles/storage.objectViewer:
- rw
- ro
- group:[email protected]
2 changes: 1 addition & 1 deletion modules/project-factory/factory-projects.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ locals {
_hierarchy_projects = (
{
for f in try(fileset(local._folders_path, "**/*.yaml"), []) :
basename(trimsuffix(f, ".yaml")) => merge(
replace(trimsuffix(f, ".yaml"), "/", "-") => merge(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer having the / being part of the key, to make it clear which part is the hierarchy and which is the project. Keep in mind the primary use case is using the key in substitutions (e.g. automation.project = "foo/bar"). Let's keep the path intact, and then find a way to map that to project ids. Probably by moving the replace there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you comment on this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem (I think) is that '/' is invalid in project ids

Copy link
Collaborator

@ludoo ludoo Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to keep the path for keys, not project ids

juliocc marked this conversation as resolved.
Show resolved Hide resolved
{ parent = dirname(f) == "." ? "default" : dirname(f) },
yamldecode(file("${local._folders_path}/${f}"))
)
Expand Down
Loading