Skip to content

Commit

Permalink
Update pdc scope
Browse files Browse the repository at this point in the history
  • Loading branch information
aangelisc committed Jan 30, 2025
1 parent f572d44 commit 546c078
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func (r *PDCNetworksDataSource) Read(ctx context.Context, req datasource.ReadReq
if data.NameFilter.ValueString() != "" && data.NameFilter.ValueString() != policy.Name {
continue
}
if !slices.Contains(policy.Scopes, "pdc-signing:write") {
// Include pdc-signing:write to account for old PDC access policies
if !slices.Contains(policy.Scopes, "pdc-signing:write") || !slices.Contains(policy.Scopes, "set:pdc-signing") {
continue
}
data.PrivateDataSourceNetworks = append(data.PrivateDataSourceNetworks, PDCNetworksDataSourcePolicyModel{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ func listPDCNetworkIds(ctx context.Context, client *gcom.APIClient, data *Lister
}

for _, policy := range resp.Items {
if slices.Contains(policy.Scopes, "pdc-signing:write") {
// Include pdc-signing:write to account for old PDC access policies
if slices.Contains(policy.Scopes, "pdc-signing:write") || slices.Contains(policy.Scopes, "set:pdc-signing") {
policies = append(policies, resourceAccessPolicyID.Make(regionSlug, policy.Id))
}
}
Expand All @@ -145,7 +146,7 @@ func createPDCNetwork(ctx context.Context, d *schema.ResourceData, client *gcom.
PostAccessPoliciesRequest(gcom.PostAccessPoliciesRequest{
Name: d.Get("name").(string),
DisplayName: &displayName,
Scopes: []string{"pdc-signing:write"},
Scopes: []string{"set:pdc-signing"},
Realms: []gcom.PostAccessPoliciesRequestRealmsInner{{Type: "stack", Identifier: d.Get("stack_identifier").(string)}},
})
result, _, err := req.Execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestResourcePrivateDataSourceConnectNetworkToken_Basic(t *testing.T) {
resource.TestCheckResourceAttr("grafana_cloud_access_policy.test", "name", initialName),
resource.TestCheckResourceAttr("grafana_cloud_access_policy.test", "display_name", initialName),
resource.TestCheckResourceAttr("grafana_cloud_access_policy.test", "scopes.#", "1"),
resource.TestCheckResourceAttr("grafana_cloud_access_policy.test", "scopes.0", "pdc-signing:write"),
resource.TestCheckResourceAttr("grafana_cloud_access_policy.test", "scopes.0", "set:pdc-signing"),
resource.TestCheckResourceAttr("grafana_cloud_access_policy.test", "realm.#", "1"),
resource.TestCheckResourceAttr("grafana_cloud_access_policy.test", "realm.0.type", "stack"),

Expand Down

0 comments on commit 546c078

Please sign in to comment.