@@ -10,10 +10,7 @@ locals {
1010
1111 # Build attribute condition for repository access
1212 # GitHub uses "repository" claim in format "owner/repo"
13- repositories_attribute_condition = length (var. github_repository_names ) > 0 ? " (${ join (" || " , [for repo in var . github_repository_names : " attribute.repository==\" ${ repo } \" " ])} )" : null
14-
15- # Build attribute condition for repository ID access
16- repository_ids_attribute_condition = length (var. github_repository_ids ) > 0 ? " (${ join (" || " , [for id in var . github_repository_ids : " attribute.repository_id==\" ${ id } \" " ])} )" : null
13+ repositories_attribute_condition = length (var. github_repository_names ) > 0 ? " (${ join (" || " , [for repo in var . github_repository_names : " attribute.repository_id==\" ${ data . github_repository . repositories [repo ]. repo_id } \" " ])} )" : null
1714
1815 # Build attribute condition for organization access
1916 # GitHub uses "repository_owner_id" claim for organization ID
@@ -25,7 +22,6 @@ locals {
2522 # Combine all conditions
2623 base_attribute_condition = join (" || " , compact ([
2724 local . repositories_attribute_condition ,
28- local . repository_ids_attribute_condition ,
2925 local . organization_attribute_condition ,
3026 local . enterprise_attribute_condition ,
3127 ]))
@@ -38,8 +34,7 @@ locals {
3834 # For organization, we bind to the repository_owner_id attribute
3935 # For enterprise, we bind to the enterprise_id attribute
4036 principal_subjects = merge (
41- { for repo in var . github_repository_names : " ${ local . repository_resource_suffix } -${ replace (repo, " /" , " -" )} " => " attribute.repository/${ repo } " },
42- { for id in var . github_repository_ids : " ${ local . repository_resource_suffix } -id-${ id } " => " attribute.repository_id/${ id } " },
37+ { for repo in var . github_repository_names : " ${ local . repository_resource_suffix } -${ replace (repo, " /" , " -" )} " => " attribute.repository_id/${ data . github_repository . repositories [repo ]. repo_id } " },
4338 var. github_organization_id != null ? { (local.organization_resource_suffix) = " attribute.repository_owner_id/${ var . github_organization_id } " } : {},
4439 var. github_enterprise_id != null ? { (local.enterprise_resource_suffix) = " attribute.enterprise_id/${ var . github_enterprise_id } " } : {},
4540 )
@@ -92,6 +87,7 @@ locals {
9287 repo = > {
9388 owner = split (" /" , repo)[0 ]
9489 name = split (" /" , repo)[1 ]
90+ id = data.github_repository.repositories[repo].repo_id
9591 }
9692 }
9793}
0 commit comments