Skip to content

Commit 4d12f01

Browse files
authored
chore(test-org): remove non-org members (#2798)
1 parent e93712c commit 4d12f01

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

infra/terraform/test-org/org/github.tf

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2023-2024 Google LLC
2+
* Copyright 2023-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,24 +16,11 @@
1616
provider "github" {}
1717

1818
locals {
19-
owners = flatten(
20-
[for repo, val in local.repos : [for owner in setunion(lookup(val, "admins", []), lookup(val, "maintainers", [])) : owner]]
19+
repo_members = flatten(
20+
[for repo, val in local.repos : [for member in setunion(lookup(val, "admins", []), lookup(val, "maintainers", [])) : member]]
2121
)
2222

2323
org_members = [for login in setunion(data.github_organization.tgm.users[*].login, data.github_organization.gcp.users[*].login) : login]
24-
25-
invalid_owners = setsubtract(local.owners, local.org_members)
26-
}
27-
28-
variable "temp_allow_invalid_owners" {
29-
type = list(string)
30-
description = "Googlers added as owners on TF blueprint repos but are not part of the GCP or TGM orgs yet."
31-
default = [
32-
"nidhi0710", # remove once heynidhi@ is added to GCP org
33-
"sylvioneto",
34-
"erictune",
35-
"megelatim",
36-
]
3724
}
3825

3926
data "github_organization" "tgm" {

infra/terraform/test-org/org/outputs.tf

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019-2024 Google LLC
2+
* Copyright 2019-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -101,13 +101,16 @@ output "ci_media_cdn_vod_project_id" {
101101
}
102102

103103
output "modules" {
104-
value = [for value in local.repos : value if try(value.module, true)]
105-
106-
precondition {
107-
condition = length(setsubtract(local.invalid_owners, var.temp_allow_invalid_owners)) == 0
108-
error_message = "Provided Repo Owners are not currently members of GCP or TGM Orgs: ${join(", ", setsubtract(local.invalid_owners, var.temp_allow_invalid_owners))}. You can bypass this error by setting `-var='temp_allow_invalid_owners=[\"${join("\",\"", local.invalid_owners)}\"]'` when running plan/apply."
109-
}
104+
value = [for value in local.repos : merge(value,
105+
try({ maintainers = sort(setintersection(local.org_members, value.maintainers)) }, {}),
106+
try({ admins = sort(setintersection(local.org_members, value.admins)) }, {})
107+
) if try(value.module, true)
108+
]
109+
}
110110

111+
output "removed_members" {
112+
value = setsubtract(local.repo_members, local.org_members)
113+
description = "Members not part of GCP or TGM orgs (removed from config)"
111114
}
112115

113116
output "bpt_folder" {

0 commit comments

Comments
 (0)