Skip to content

feat: Added changes to support workspace with konnect flow#1892

Open
shivaygupta-dotcom wants to merge 17 commits intomainfrom
feature/konnect-workspaces
Open

feat: Added changes to support workspace with konnect flow#1892
shivaygupta-dotcom wants to merge 17 commits intomainfrom
feature/konnect-workspaces

Conversation

@shivaygupta-dotcom
Copy link
Contributor

@shivaygupta-dotcom shivaygupta-dotcom commented Feb 20, 2026

https://konghq.atlassian.net/browse/KOKO-3141
#1859

Supporting PRs:
Kong/go-kong#602
Kong/go-database-reconciler#376

Summary:

This PR introduces workspace support for Konnect as part of the referenced Jira task. The changes extend existing commands to support workspaces when operating in Konnect mode. Add changes in sync, diff, reset, apply, dump and validate command. The overall flow is similar to the existing Kong workspace implementation, but Konnect uses different workspace API endpoints, which required additional handling.
In Konnect, all entities are attached to the default workspace by default but endpoint is bit different then what we have in Kong . Therefore, when the user explicitly specifies the default workspace (e.g., during reset or dump), the system should follow the existing normal Konnect flow, without triggering workspace-specific logic.

Few major changes I want to highlight below:

  1. Introduced a new flag isKonnect in KongClient to distinguish and handle Konnect-specific execution paths.
  2. Added conditional checks based on the isKonnect flag across the relevant commands to ensure correct handling of workspaces when running in Konnect mode.
  3. Updated the workspaceExists func by adding a boolean parameter to support workspace validation logic for Konnect.
  4. Updated GetKongClientForKonnectMode to support WorkspaceName and added validation to check if an Authorization Bearer token is already set; if present, the token initialization step is skipped
  5. Updated resetKonnectV2 to support both single workspace resets (--workspace) and reset across all workspaces (--all-workspaces), with additional validation to ensure the default workspace follows the existing Konnect behavior.
  6. Updated dumpKonnectV2 to support dumping configurations for a single workspace or all workspaces, with logic to treat the default workspace using the current standard Konnect flow.
  7. Updated the validate command to ensure entity schema validation works correctly with Konnect workspaces. Since Konnect workspace APIs include the workspace name in the base endpoint but the schema endpoint does not support workspace-prefixed URLs, a conditional check based on the isKonnect flag was added to handle schema validation using the correct endpoint.

Integration tests For Konnect Workspaces:

Dump Command

  1. dump empty workspace
  2. dump workspace with single entity
  3. dump without _workspace field in state file
  4. dump with default workspace name
  5. workspace isolation - entities synced to workspace should not appear in CP-level dump
  6. dump all workspaces (workspace1, workspace2, default)

Reset Command

  1. reset workspace with single entity
  2. reset workspace with multiple entities
  3. reset without workspace flag (CP-level)
  4. reset with default workspace name
  5. reset workspace isolation - reset workspace1, verify workspace2 unaffected
  6. reset all workspaces

Sync Command

  1. sync entities into konnect workspace
  2. sync empty workspace - no entities
  3. sync without _workspace field in state file
  4. sync with different workspace name - workspace mismatch
  5. sync then reset to empty workspace

Diff Command

  1. create konnect workspace with entity creation
  2. create konnect workspace with existing entity deletion and new entity creation
  3. update single entity in konnect workspace
  4. empty state file should show deletion of all entities
  5. workspace mismatch - different workspace name should create new workspace
  6. idempotency - no diff after sync

Apply Command

  1. apply entity into konnect workspace
  2. apply and update entity in konnect workspace
  3. apply is additive - does not delete existing entities
  4. apply without _workspace field in state file

Validate Command

  1. validate with _workspace in state file
  2. validate with --workspace flag
  3. validate without workspace (CP-level)
  4. validate with default workspace in state file
  5. validate with --workspace=default flag
  6. validate empty workspace
  7. validate with non-existent --workspace flag
  8. validate workspace isolation - sync entity to workspace, validate both workspace and CP-level files

@shivaygupta-dotcom
Copy link
Contributor Author

shivaygupta-dotcom commented Mar 11, 2026

CI is failing because, no other entity is present other than routes for Konnect Workspaces.This will be fixed once changes are deployed from KoKo side.

Changes are inProgress from KoKo side, I didn't got any specific ETA.
https://konghq.atlassian.net/browse/KOKO-3141?focusedCommentId=206410

@shivaygupta-dotcom shivaygupta-dotcom marked this pull request as ready for review March 12, 2026 05:59
@codecov-commenter
Copy link

codecov-commenter commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 0% with 158 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.02%. Comparing base (9cce3c6) to head (3bef3fd).

Files with missing lines Patch % Lines
cmd/common_konnect.go 0.00% 98 Missing ⚠️
cmd/common.go 0.00% 30 Missing ⚠️
cmd/gateway_validate.go 0.00% 20 Missing ⚠️
validate/validate.go 0.00% 8 Missing ⚠️
cmd/gateway_dump.go 0.00% 1 Missing ⚠️
cmd/gateway_reset.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1892      +/-   ##
==========================================
- Coverage   33.54%   33.02%   -0.52%     
==========================================
  Files          76       76              
  Lines        6711     6810      +99     
==========================================
- Hits         2251     2249       -2     
- Misses       4280     4381     +101     
  Partials      180      180              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

errorExpected: true,
errorString: "workspace doesn't exist: nonexistent",
},
{
Copy link
Contributor Author

@shivaygupta-dotcom shivaygupta-dotcom Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed runtime group test because, --konnect-runtime-group-name is deprecated and CI was throwing error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants