Skip to content
Merged
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
9 changes: 8 additions & 1 deletion scaleway/resource_iam_api_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ func testSweepIamAPIKey(_ string) error {

l.Debugf("sweeper: destroying the api keys")

listAPIKeys, err := api.ListAPIKeys(&iam.ListAPIKeysRequest{}, scw.WithAllPages())
orgID, exists := scwClient.GetDefaultOrganizationID()
if !exists {
return fmt.Errorf("missing organizationID")
}

listAPIKeys, err := api.ListAPIKeys(&iam.ListAPIKeysRequest{
OrganizationID: &orgID,
}, scw.WithAllPages())
if err != nil {
return fmt.Errorf("failed to list api keys: %w", err)
}
Expand Down
9 changes: 8 additions & 1 deletion scaleway/resource_iam_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ func testSweepIamApplication(_ string) error {
return sweep(func(scwClient *scw.Client) error {
api := iam.NewAPI(scwClient)

listApps, err := api.ListApplications(&iam.ListApplicationsRequest{})
orgID, exists := scwClient.GetDefaultOrganizationID()
if !exists {
return fmt.Errorf("missing organizationID")
}

listApps, err := api.ListApplications(&iam.ListApplicationsRequest{
OrganizationID: &orgID,
})
if err != nil {
return fmt.Errorf("failed to list applications: %w", err)
}
Expand Down
10 changes: 6 additions & 4 deletions scaleway/resource_iam_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package scaleway

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand All @@ -22,10 +21,13 @@ func testSweepIamGroup(_ string) error {
return sweep(func(scwClient *scw.Client) error {
api := iam.NewAPI(scwClient)

// Requiring organization_id in list request is temporary
organizationID := os.Getenv("DEFAULT_ORGANIZATION_ID")
orgID, exists := scwClient.GetDefaultOrganizationID()
if !exists {
return fmt.Errorf("missing organizationID")
}

listApps, err := api.ListGroups(&iam.ListGroupsRequest{
OrganizationID: &organizationID,
OrganizationID: &orgID,
})
if err != nil {
return fmt.Errorf("failed to list groups: %w", err)
Expand Down
9 changes: 8 additions & 1 deletion scaleway/resource_iam_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ func testSweepIamPolicy(_ string) error {
return sweep(func(scwClient *scw.Client) error {
api := iam.NewAPI(scwClient)

listPols, err := api.ListPolicies(&iam.ListPoliciesRequest{})
orgID, exists := scwClient.GetDefaultOrganizationID()
if !exists {
return fmt.Errorf("missing organizationID")
}

listPols, err := api.ListPolicies(&iam.ListPoliciesRequest{
OrganizationID: &orgID,
})
if err != nil {
return fmt.Errorf("failed to list policies: %w", err)
}
Expand Down