Skip to content

Commit

Permalink
chore: add KONG_CUSTOM_DOMAIN handling with sdk-konnect-go 0.1.7 (#6695)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek authored Nov 21, 2024
1 parent c1c3b43 commit 48e9abd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
17 changes: 4 additions & 13 deletions hack/cleanup/konnect_control_planes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
}
Expand Down

0 comments on commit 48e9abd

Please sign in to comment.