diff --git a/.github/workflows/cleanup.yaml b/.github/workflows/cleanup.yaml index 6e1013af1e..30a2e34725 100644 --- a/.github/workflows/cleanup.yaml +++ b/.github/workflows/cleanup.yaml @@ -37,4 +37,8 @@ jobs: - name: cleanup orphaned test clusters run: go run ./hack/cleanup konnect env: + # Ref: https://github.com/Kong/sdk-konnect-go/issues/20 + KONG_CUSTOM_DOMAIN: konghq.tech + # NOTE: This token has to align with the domain above until the linked + # issue is resolved. TEST_KONG_KONNECT_ACCESS_TOKEN: ${{ secrets.K8S_TEAM_KONNECT_ACCESS_TOKEN }} diff --git a/go.mod b/go.mod index 957c8d09c6..10d8c9e9b9 100644 --- a/go.mod +++ b/go.mod @@ -76,7 +76,7 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Kong/go-diff v1.2.2 // indirect github.com/Kong/gojsondiff v1.3.2 // indirect - github.com/Kong/sdk-konnect-go v0.1.6 + github.com/Kong/sdk-konnect-go v0.1.7 github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.3.0 // indirect diff --git a/go.sum b/go.sum index 161c0a415e..0500d0ce12 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/Kong/go-diff v1.2.2 h1:KKKaqHc8IxuguFVIZMNt3bi6YuC/t9r7BGD8bOOpSgM= github.com/Kong/go-diff v1.2.2/go.mod h1:nlvdwVZQk3Rm+tbI0cDmKFrOjghtcZTrZBp+UruvvA8= github.com/Kong/gojsondiff v1.3.2 h1:qIOVq2mUXt+NXy8Be5gRUee9TP3Ve0MbQSafg9bXKZE= github.com/Kong/gojsondiff v1.3.2/go.mod h1:DiIxtU59q4alK7ecP+7k56C5UjgOviJ5gQVR2esEhYw= -github.com/Kong/sdk-konnect-go v0.1.6 h1:e0wSujJVVo16y2qOrKvzg6/4sMPc/FLK70eSt80HnXE= -github.com/Kong/sdk-konnect-go v0.1.6/go.mod h1:ipu67aQNnwDzu/LXKePG46cVqkkZnAHKWpsbhTEI8xE= +github.com/Kong/sdk-konnect-go v0.1.7 h1:EK6N+qrcnHxJGtz5DRqLU2Kw0itC3jwhjzbUkGIufrc= +github.com/Kong/sdk-konnect-go v0.1.7/go.mod h1:ipu67aQNnwDzu/LXKePG46cVqkkZnAHKWpsbhTEI8xE= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= diff --git a/hack/cleanup/konnect_control_planes.go b/hack/cleanup/konnect_control_planes.go index 985c3df191..1eb5a0f00e 100644 --- a/hack/cleanup/konnect_control_planes.go +++ b/hack/cleanup/konnect_control_planes.go @@ -24,15 +24,13 @@ const ( // cleanupKonnectControlPlanes deletes orphaned control planes created by the tests and their roles. func cleanupKonnectControlPlanes(ctx context.Context, log logr.Logger) error { + // NOTE: The domain for global endpoints is overridden in cleanup.yaml workflow. + // See https://github.com/Kong/sdk-konnect-go/issues/20 for details sdk := sdk.New(konnectAccessToken, sdkkonnectgo.WithServerURL(test.KonnectServerURL()), ) - me, err := sdk.Me.GetUsersMe(ctx, - // NOTE: Otherwise we use prod server by default. - // Related issue: https://github.com/Kong/sdk-konnect-go/issues/20 - sdkkonnectops.WithServerURL(test.KonnectServerURL()), - ) + me, err := sdk.Me.GetUsersMe(ctx) if err != nil { return fmt.Errorf("failed to get user info: %w", err) } @@ -149,9 +147,6 @@ func findOrphanedRolesToDelete( // NOTE: Sadly we can't do filtering here (yet?) because ListUserRolesQueryParamFilter // can only match by exact name and we match against a list of orphaned control plane IDs. &sdkkonnectops.ListUserRolesQueryParamFilter{}, - // NOTE: Otherwise we use prod server by default. - // Related issue: https://github.com/Kong/sdk-konnect-go/issues/20 - sdkkonnectops.WithServerURL(test.KonnectServerURL()), ) if err != nil { return nil, fmt.Errorf("failed to list user roles: %w", err) @@ -195,11 +190,7 @@ func deleteRoles( var errs []error for _, roleID := range rolesIDsToDelete { log.Info("Deleting role", "id", roleID) - _, err := sdk.UsersRemoveRole(ctx, userID, roleID, - // NOTE: Otherwise we use prod server by default. - // Related issue: https://github.com/Kong/sdk-konnect-go/issues/20 - sdkkonnectops.WithServerURL(test.KonnectServerURL()), - ) + _, err := sdk.UsersRemoveRole(ctx, userID, roleID) if err != nil { errs = append(errs, fmt.Errorf("failed to delete role %s: %w", roleID, err)) }