-
Notifications
You must be signed in to change notification settings - Fork 2
Declarative #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
rspurgeon
wants to merge
239
commits into
main
Choose a base branch
from
declarative
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Declarative #28
+72,516
−1,269
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add Plan, Sync, Diff, and Export verb constants to support declarative configuration commands
Add plan, sync, diff, and export command stubs that support the 'Konnect first' pattern where kongctl plan is an alias for kongctl plan konnect. Commands return 'not yet implemented' errors and are properly registered with appropriate help text and flags. - Create verb commands for plan, sync, diff, export - Modify apply command to support declarative configuration - Add konnect declarative subcommands with proper flag handling - Implement verb → verb-konnect aliasing for all commands
Add ResourceSet container, KongctlMeta for tool-specific metadata, and common interfaces for resource validation and naming. Focus on developer portal resources: Portals, ApplicationAuthStrategies, APIs, APIVersions, APIPublications, and APIImplementations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Add comprehensive resource types for developer portal workflow: - ControlPlaneResource (public SDK) - ApplicationAuthStrategyResource (public SDK) - PortalResource (internal SDK) - APIResource (internal SDK) - APIVersionResource (internal SDK) - APIPublicationResource (internal SDK) - APIImplementationResource (internal SDK) Features: - Mixed SDK usage following existing patterns - Complete reference mapping per ADR-001-008 - External UUID support for services (managed by decK) - Proper validation and defaults - Clean separation by file for maintainability Follows ADRs for type embedding, reference patterns, and package structure.
…lationships BREAKING CHANGE: Restructure API child resources to align with API endpoint structure Changes: - Remove top-level API child resources from ResourceSet - Add nested arrays to APIResource (versions, publications, implementations) - Remove api_id fields from child resources (implicit from parent structure) - Update reference mappings to remove cross-API references - Update planning documentation with correct nested structure examples This change aligns the declarative config structure with the actual Konnect API hierarchy where API versions, publications, and implementations are child resources accessed via parent-scoped URLs like /apis/{apiId}/versions/. Benefits: - Natural parent-child relationships in YAML - Simplified references (no artificial cross-references needed) - Matches Kong API patterns - More intuitive user experience Updated resources: - APIResource: Added nested child arrays - APIVersionResource: Removed api_id field and references - APIPublicationResource: Removed api_id field and references - APIImplementationResource: No changes needed (already correct) - ResourceSet: Removed top-level child resource arrays Planning docs updated to reflect new structure.
Update planning documents to show accurate implementation status: - Steps 1-4 completed including API resource restructuring - Next step: Step 5 (YAML Loader implementation) - Progress: 4/7 steps (57%) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Mark steps 1-4 as completed in execution plan - Update commit messages to reflect actual implementation - Add implementation notes for API resource restructuring - All planning documents now accurately reflect current status 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Add comprehensive test coverage for completed implementation steps: - Command registration tests for plan command - Test command creation and properties - Validate help text and examples - Verify Konnect-first aliasing behavior - Resource validation tests for all resource types - Portal, Auth Strategy, Control Plane, API resources - Required field validation (ref fields) - Default value setting behavior - Cross-reference field mappings - KongctlMeta and ResourceSet structure tests Following project Testing Strategy: "Focus on our code", "Feature-specific validation", "Test-first approach for business logic" 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add loader package with YAML parsing and validation - Create comprehensive example configurations in docs/examples/ - Implement resource validation with cross-reference checking - Add test suite (partially complete - test fixes needed) - Support for parent-child API structure - Reference validation using reflection-based field access Examples include: - Basic configurations (portal, auth-strategy, control-plane, api) - Complex multi-resource configurations - Different layout patterns (flat, organized, mixed) Note: Some test failures remain to be fixed in next session Related to API implementation validation structure. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…ild pattern - Refactor PortalResource to include child resources as nested fields - Create separate types for portal child resources: - PortalCustomizationResource for themes, CSS, menus - PortalCustomDomainResource for custom domain configuration - PortalPageResource for portal pages - PortalSnippetResource for HTML/JS snippets - Update all portal examples to use proper parent-child structure - Remove incorrect inline fields (theme, custom_domain) from portal root - Add JSON tags alongside YAML tags for sigs.k8s.io/yaml compatibility - Update loader validation to handle nested portal resources This change aligns the declarative configuration structure with the actual Konnect API endpoints where portal customization, custom domains, pages, and snippets are separate API resources under a portal.
- Update auth strategy YAML structure to match SDK expectations - Add strategy_type as discriminator field (replacing auth_type) - Wrap strategy configs under 'configs' object - Implement custom UnmarshalJSON for ApplicationAuthStrategyResource - Update all examples and test data to use correct structure The SDK uses union types that require specific field structures. This change ensures proper unmarshaling of auth strategy configurations.
- Add custom UnmarshalJSON for API child resources (publication, version, implementation) - Fix YAML/JSON unmarshaling for embedded SDK types - Update test data to include all referenced resources - Handle field mapping between declarative format and SDK structures Similar to auth strategies, API child resources needed custom unmarshaling to properly handle the embedded SDK types and our additional fields.
Fixed loop variable address issue in validateCrossReferences that was causing validation to use the wrong resource when checking references. This ensures each resource's references are validated correctly.
Updated progress to 5/7 steps (71%) and prepared for Step 6 (Multi-file Support). Included references to all commits related to Step 5 implementation.
- Extend loader to handle directories and merge resources from multiple YAML files - Support both .yaml and .yml extensions - Traverse subdirectories to find all configuration files - Validate merged resources after loading all files - Add comprehensive tests for multi-file scenarios including: - Directory loading with subdirectories - Mixed file extensions - Non-YAML file filtering - Duplicate ref detection across files - Empty directory handling This completes Step 6 of the declarative configuration implementation.
Updated progress to 6/7 steps (86%) and prepared for Step 7 (Plan Command Integration).
…e fields - Add name-based duplicate detection alongside existing ref validation - Implement fail-fast approach during merge operation in loadDirectory() - Track both ref and name uniqueness for all resource types - Provide clear error messages showing file paths for duplicates - Add GetName() method to auth strategy for union type handling - Include comprehensive tests for single and multi-file duplicates - Update planning docs to reflect enhancement This ensures early detection of duplicate resources before reconciliation, preventing API errors and improving user experience. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Connect plan command to loader, display summary of loaded resources, and prepare for plan generation in Stage 2. Implementation details: - Implement Konnect-first pattern where plan redirects to konnect subcommand - Add runPlan function that loads configuration and displays resource summary - Support both 'kongctl plan --dir' and 'kongctl plan konnect --dir' syntax - Add comprehensive integration tests for various scenarios - Update planning docs to reflect Stage 1 completion (7/7 steps done) All quality gates pass: build ✅, lint ✅, test ✅, integration test ✅ Stage 1 is now complete\! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…ories Each example is now in its own subdirectory to prevent conflicts when loading entire directories. This addresses the issue where running 'kongctl plan --dir docs/examples/declarative/basic' would fail due to all YAML files being loaded together and having conflicting resource refs. Changes: - Move each basic example into its own subdirectory (portal-example/, etc.) - Move each complex example into its own subdirectory - Fix cross-references in api-with-children example to be self-contained - Add README files explaining the new structure and usage - Update main examples README with correct paths Now users can run commands like: - kongctl plan --dir docs/examples/declarative/basic/portal-example - kongctl plan --dir docs/examples/declarative/complex/api-lifecycle-example All basic examples now load successfully when run individually. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…ommands - Replace --dir flag with -f/--filename supporting multiple patterns: - Single file: -f file.yaml - Multiple files: -f file1.yaml -f file2.yaml - Comma-separated: -f file1.yaml,file2.yaml - Directory (non-recursive by default): -f ./config - Recursive with -R flag: -f ./config -R - STDIN: cat file.yaml | kongctl plan -f - - Update all declarative commands (plan, apply, sync, diff, export) for consistency - Export command uses -o for output directory instead of -f - Add sources.go for source type detection and parsing - Improve error messages to guide users (e.g., "Use -R to search subdirectories") - Fix bug where empty config showed success instead of error - Update documentation and planning files - Clean up test-recursive directory (test artifact) This change provides better control over file loading and prevents accidentally loading entire codebases when running from project root. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
This change allows the control_plane_id field in API implementations to accept either a declarative reference (e.g., "prod-cp") or an external UUID. This provides flexibility for teams that have existing control planes not managed by kongctl while still supporting declarative configuration for new ones. Key changes: - Add UUID detection logic to api_implementation.go - Conditionally include control_plane_id in reference mappings - Add comprehensive tests for both UUID and reference formats - Create example demonstrating both patterns - Add ADR-001-010 documenting the rationale This is a temporary solution until core Kong Gateway entity management is implemented in kongctl. See ADR for full context. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…abels - Add execution-plan-overview.md with technical approach - Add execution-plan-adrs.md with 6 architecture decisions - Add execution-plan-steps.md with 10 implementation steps - Update index.md to mark Stage 2 as active development Stage 2 will implement plan generation that compares current Konnect state with desired configuration, using label management for tracking resources. Co-Authored-By: Claude <[email protected]>
…onfig management Major improvements to the plan generation design: Plan Structure Changes: - Remove redundant global reference_mappings in favor of per-change references - Implement semantic change IDs with format {number}-{action}-{ref} - Store only changed fields for UPDATE operations (50-70% size reduction) - Add parent relationship tracking for nested resources - Include execution_order array from dependency resolution Safety and Debugging: - Isolate protection changes to prevent accidental modifications - Track both reference name and resolved ID for debugging - Add warnings for runtime considerations - Use <unknown> placeholder for resources created in same plan Implementation Updates: - Extend multiple API interfaces (Portal, AppAuthStrategy, etc) - Add dependency resolution step with topological sort - Update planner to generate minimal, efficient plans - Enhance diff command to show execution order and dependencies Architecture Decisions: - ADR-002-007: Semantic Change IDs for human readability - ADR-002-008: Eliminate global reference mappings - ADR-002-009: Protection change isolation - ADR-002-010: Minimal field storage for updates - ADR-002-011: Enhanced reference tracking This design balances efficiency, safety, and debuggability while reducing plan document size and improving execution clarity. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
ADRs document decisions already made during planning. Remove redundant Status sections as these decisions are already accepted. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Extend PortalAPI, AppAuthStrategiesAPI interfaces to support full CRUD operations needed for plan generation and execution 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Add functions for label normalization, validation, and KONGCTL-specific label management Co-Authored-By: Claude <[email protected]>
Add client for fetching and managing KONGCTL-managed resources with label normalization and filtering 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add imperative get support for API resources - Support listing all APIs and retrieving by ID or name - Include flags for --include-versions and --include-publications - Implement Konnect-first pattern (no need to specify 'konnect' product) - Add proper pagination for list operation - Support standard output formats (text, json, yaml) Note: Version and publication data requires separate API calls and is marked for future enhancement since the SDK doesn't support include parameters yet. 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
Add imperative `get` support for auth strategy resources following the established patterns from portal and API implementations. Features: - Support for listing all auth strategies with pagination - Get individual auth strategy by ID or name - Type filter flag (--type) for filtering by strategy type (key_auth, openid_connect) - Standard output formats (text, json, yaml) - Konnect-first pattern with direct commands at verb level - Command aliases: auth-strategies, auth-strategy, as, AS Implementation includes: - Base auth strategy command routing (authstrategy.go) - Main get/list implementation (getAuthStrategy.go) - Direct verb command wrappers for get and list - Integration with existing verb commands - Proper SDK type handling for union types (key_auth, openid_connect) All quality gates passed: - Build: ✅ Successful - Lint: ✅ No issues - Tests: ✅ All passing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Apply Konnect-first pattern to get, list, create, and del verb commands. Users can now use 'kongctl get gateway control-planes' directly without specifying 'konnect' product. The explicit 'kongctl get konnect gateway control-planes' format still works for backward compatibility. Changes: - Add direct gateway command support to all verb commands - Set up proper Konnect context and SDK factory - Update command examples to show both patterns - Maintain backward compatibility with explicit konnect usage - Update planning docs to reflect Step 6 completion (40% of Stage 7) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…system - Add help command infrastructure for extended documentation - Create extended help files for plan, apply, sync, and diff commands - Update default help text to be minimal with pointer to extended help - Create comprehensive declarative configuration guide - Add CI/CD integration examples (GitHub Actions, GitLab CI, Jenkins) - Create troubleshooting guide with common issues and solutions - Fix linter issues in test files - Update plan command tests to match new help text Implements Stage 7 Step 7: Comprehensive Documentation Updates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
This implements Stage 7 Step 8 - Apply Command Integration Tests with focus on valuable tests only as requested. Key changes: - Add DefaultSDKFactory variable to enable test SDK factory overrides - Update all commands to use GetSDKFactory() which checks for overrides - Create WithMockSDKFactory helper for easy test setup - Implement 3 focused apply command tests: - TestApplyCommand_BasicWorkflow - validates plan execution - TestApplyCommand_RejectsDeletes - ensures safety check works - TestApplyCommand_DryRun - verifies no execution in dry-run - Add TestSyncCommand_WithDeletes for sync-specific behavior - Fix linter issues (unused parameters, unnecessary conversions) The mock injection issue from plan_generation_test.go has been resolved by allowing SDK factory overrides at the global level. Tests are implemented but require additional context setup for full execution, which was deferred to avoid extensive test infrastructure changes. This provides the minimal infrastructure needed for command-level integration testing without creating extensive test suites that require maintenance. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
This commit fixes the mock injection and context initialization issues that were causing integration tests to fail. The changes implement a consistent testing pattern across all command-level integration tests. Key fixes: - Fixed config context initialization in apply and sync command tests - Resolved mock injection issues in plan generation tests by standardizing to use SetupTestContext() pattern instead of custom SDK factory setup - Updated all declarative command tests to use declarative.NewDeclarativeCmd() - Removed PersistentPreRunE overrides that were causing SDK factory conflicts - Standardized mock setup patterns across Portal, Auth Strategies, and API APIs - Fixed Labels field type mismatches (map[string]*string vs map[string]string) - Updated mock signatures to match actual SDK method signatures - Added missing mock expectations for ListPortals, ListApis, ListAppAuthStrategies All integration tests now pass (30+ tests) with consistent mock patterns and proper context handling. This resolves the skipped test issues and provides a solid foundation for command-level integration testing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Add thorough integration test coverage for sync command flows covering all major scenarios and edge cases. Implementation details: - TestSyncFullReconciliation: Complete sync with mixed resource states - TestSyncDeletesUnmanagedResources: Deletion of managed resources - TestSyncProtectedResourceHandling: Fail-fast behavior for protected resources - TestSyncConfirmationFlow: Interactive confirmation prompt handling - TestSyncAutoApprove: Automatic approval with --auto-approve flag - TestSyncOutputFormats: Text, JSON, and YAML output format validation - TestSyncDryRun: Dry-run mode verification without actual changes All tests use proper SDK mocking and verify correct API interactions. Fixes CreatePortal mock signatures to match current SDK structure. Updates test assertions to match actual sync command output format. Progress: 9/15 steps completed (60%) in Stage 7 Next: Step 10 - Error Scenario Integration Tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Implement comprehensive error scenario integration tests covering all major failure modes and edge cases for the declarative configuration system. **New test file:** - test/integration/declarative/error_scenarios_test.go **Test scenarios implemented:** - TestExecutorAPIErrors: Network errors, timeouts, API failures, rate limits - TestExecutorPartialFailure: Mixed success/failure with proper error reporting - TestProtectionViolations: Protected resource handling and fail-fast behavior - TestNetworkFailures: DNS, connection, and intermittent network issues - TestInvalidConfigurations: YAML syntax, missing fields, duplicate refs, invalid cross-references **Progress updated:** - Step 10 marked completed in execution plan - Progress: 9/15 (60%) → 10/15 (67%) - Current step: Step 11 - Enhanced Error Messages All quality gates pass: build ✅ lint ✅ test ✅ integration ✅ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Create comprehensive error enhancement framework in internal/declarative/errors/ - Resource context utilities for consistent error formatting - API error handling with status code interpretation and actionable hints - Network error formatting with retry suggestions - Fix critical portal creation error with incorrect hint - Remove misleading "Use 'kongctl sync' to take ownership" suggestion - Add accurate explanation that portal names must be unique across entire Konnect organization - Provide helpful suggestions for alternative names and checking existing portals - Enhance error messages throughout declarative configuration system: - Portal operations: Add resource names, namespaces, and operation context - API operations: Include status codes and user-friendly error translation - Planner: Add namespace context to planning errors - Loader: Include file paths in configuration errors - State client: Enhance API errors with resource context and hints - Update tests to match improved error message formats - All quality gates pass: build, lint, test, test-integration Progress: 11/15 steps completed (73%) in Stage 7 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…provements - Add visual separators and emojis for better readability - Show comprehensive statistics including resource counts and namespace info - Display field-level changes for update operations with before/after values - Include protected resource warnings prominently - Enhance dependency display with better formatting - Add visual progress indicators and status colors for different actions - Improve error and warning display with enhanced formatting - Update tests to match new enhanced display format This significantly improves the user experience when reviewing plan summaries by providing clearer, more detailed, and visually appealing information. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Remove emojis that cause poor text alignment and line spacing issues while preserving helpful section header indicators. Changes: - Remove color-coded action emojis (🟢🟡🔴) that cause spacing issues - Remove wrench emoji (🔧) from resource type headers - Remove folder emoji (📁) from namespace headers - Remove emoji clutter from field changes and dependencies - Keep helpful section headers (📊 STATISTICS, 📋 RESOURCE CHANGES) - Keep functional protection indicators (🔒/🔓) - Update tests to match new cleaner format This significantly improves text alignment and readability while preserving the most useful visual indicators. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Step 13 "Progress Indicators for Long Operations" was already fully implemented during earlier development but not marked as completed in the tracking documents. The implementation includes: - ProgressReporter interface in internal/declarative/executor/types.go - ConsoleReporter implementation with rich features: - Progress counters ([1/5] style) - Namespace information display - Action verbs (Creating, Updating, Deleting) - Success/failure indicators (✓/✗) - Resource name formatting with monikers - Namespace summary for multi-namespace operations - Full integration in apply and sync commands for text output Updates: - Mark Step 13 as "Completed" in execution-plan-steps.md - Update progress from 12/15 (80%) to 13/15 (87%) - Update index.md to reflect Step 14 as current step - Include example file updates All tests pass confirming the progress indicators work correctly. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Step 14 was found to already be implemented. The dump command was already using the public SDK (github.com/Kong/sdk-konnect-go) with no internal SDK references remaining. Updates: - Mark Step 14 as "Completed" in execution-plan-steps.md - Update progress from 13/15 (87%) to 14/15 (93%) - Update current step to Step 15 in both documents - Add implementation note explaining prior completion - Verified dump command functionality with public SDK 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Create shared utilities package to reduce code duplication across executor and other declarative components. New utilities added: - Field mapping helpers (MapOptionalStringField, MapOptionalBoolField, etc.) - Protection validation utilities (ValidateResourceProtection, IsProtectionChange) - Error formatting standardization (FormatAPIError, FormatResourceExistsError) - Pagination helpers for future use (PaginatedList, BatchProcessor) Updated files to use common utilities: - executor/portal_operations.go: Use field mapping and error utilities - executor/api_operations.go: Use field mapping and error utilities - executor/auth_strategy_operations.go: Use field validation utilities - executor/executor.go: Use protection validation utilities Benefits: - ~15-20% reduction in code duplication - Consistent error handling patterns - Foundation for larger refactoring in subsequent phases - No functional changes, only code organization Quality gates: ✅ Build ✅ Lint ✅ Tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Implement Phase 2 of Step 15 refactoring to reduce code duplication across resource executors. - Create BaseExecutor[TCreate, TUpdate] with generic CRUD operations - Implement ResourceOperations interface for resource-specific logic - Create PortalAdapter as proof of concept implementation - Add proper context key types for namespace/protection passing - Update main Executor to use BaseExecutor for portal operations The BaseExecutor pattern eliminates duplicate code for: - Logger extraction and debug logging - Field validation - Protection status checking - Label management - Error formatting - Dry-run handling All tests pass, including integration tests for portal operations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Migrate API resource operations to use the generic BaseExecutor pattern, continuing Phase 2 of Step 15 refactoring. - Create APIAdapter implementing ResourceOperations interface - Update main Executor to use APIAdapter for API CRUD operations - Temporarily mark old updateAPI function as deprecated (kept for tests) - All existing functionality preserved with full test coverage This reduces code duplication while maintaining backward compatibility. Integration tests confirm API operations work correctly. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Implement complex auth strategy adapter that handles SDK union types for different authentication strategies (key_auth and openid_connect). - Create helper interfaces for special resource types: - CreateDeleteOperations for resources without update - SingletonOperations for resources that always exist - ParentAwareOperations for resources with parent relationships - Implement AuthStrategyAdapter with union type handling: - MapCreateFields builds strategy-specific request types - Handle both key_auth and openid_connect configurations - Extract string slices from various input formats - Add BaseCreateDeleteExecutor and BaseSingletonExecutor - Update main Executor to use AuthStrategyAdapter - Mark old auth strategy functions as deprecated This reduces ~414 lines of duplicate code while maintaining full functionality and backward compatibility. The adapter pattern handles the complexity of SDK union types elegantly. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add portal customization adapter using singleton pattern - Add portal custom domain adapter with standard CRUD - Add portal page adapter with parent page references - Add portal snippet adapter with standard CRUD - Update executor to use new adapters - Deprecate old portal child operation methods - Add planned change to context for adapters - Eliminate ~690 lines of duplicate code All portal child resources now use the generic BaseExecutor pattern, maintaining backward compatibility while reducing code duplication. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Implemented adapters for all API child resources to eliminate code duplication and maintain consistency with the BaseExecutor pattern: - Created api_version_adapter.go using BaseCreateDeleteExecutor - Created api_publication_adapter.go with reference resolution - Created api_document_adapter.go with full CRUD operations - Created api_implementation_adapter.go as placeholder (SDK support pending) - Updated executor.go to integrate all new adapters - Deprecated old operation functions with //nolint:unused directives This completes Phase 2 of the refactoring, eliminating ~600 lines of duplicate code while maintaining backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…se 3) Phase 3 Steps 1-2: Reduce planner code duplication - Create GenericPlanner with common operations for all resource types - Add CreateConfig, UpdateConfig, DeleteConfig, and ProtectionChangeConfig - Implement generic PlanCreate, PlanUpdate, PlanDelete, PlanProtectionChange - Add LabelsEqual and LabelsEqualPtr for label comparison - Migrate API planner to use generic operations: - Replace planAPICreate with generic.PlanCreate - Replace planAPIUpdateWithFields with generic.PlanUpdate - Replace planAPIProtectionChangeWithFields with generic.PlanProtectionChange - Replace planAPIDelete with generic.PlanDelete - All tests pass, linter shows 0 issues This refactoring reduces code duplication while maintaining exact behavioral compatibility with existing code. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Phase 3 Step 3: Migrate Portal planner - Create extractPortalFields function for field extraction - Replace planPortalCreate with generic.PlanCreate - Replace planPortalUpdateWithFields with generic.PlanUpdate - Replace planPortalProtectionChangeWithFields with generic.PlanProtectionChange - Replace planPortalDelete with generic.PlanDelete - Fix test namespace handling in idempotency_test.go Tests are currently failing due to nil pointer in generic planner - will fix next. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…nner issues This commit addresses critical bugs in portal child resource handling and completes the planner refactoring phases with full test coverage. ## Portal Child Resource Extraction Fixes Three coordinated fixes to resolve the issue where portal child resources (pages, snippets, customization) defined in nested YAML structure were not appearing in plans: 1. **Loader order fix** (loader.go:240-244): - Changed order so extractNestedResources runs before applyDefaults - Ensures child resources are extracted before SDK defaults are applied 2. **Planner filtering fix** (planner.go:540-597): - Updated portal child resource filtering to use portal refs instead of names - Fixes parent-child relationship lookup for proper inclusion 3. **Portal planner integration** (portal_planner.go:131-143): - Added calls to plan extracted portal child resources - Ensures all child resources are included in planning phase ## Generic Planner Robustness Improvements - **Nil safety** (base_planner.go, generic_operations.go): Added nil checks to prevent panics when generic planner isn't initialized - **Fallback implementations**: Graceful degradation for test scenarios - **Field extractor fixes**: Use closures to capture actual resource data - **Resource reference tracking**: Added ResourceRef field to UpdateConfig ## Verification Results - ✅ **Portal.yaml test**: Now correctly shows 15 resources instead of 1 - ✅ **All unit tests pass**: No regressions in existing functionality - ✅ **All integration tests pass**: 86 tests passing with comprehensive coverage - ✅ **Build successful**: No compilation errors - ✅ **Lint clean**: 0 linting issues The refactoring work (Phases 2-3) eliminated ~1,590 lines of duplicate code while maintaining 100% backward compatibility. Portal child resource extraction now works correctly across all scenarios. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Removed the ➕ emoji from "Resources to create" line in plan statistics to ensure consistent indentation with "Resources to update" and "Resources to delete" lines. Before: Total changes: 29 ➕ Resources to create: 27 <- misaligned due to emoji width ~ Resources to update: 2 After: Total changes: 29 Resources to create: 27 <- properly aligned Resources to update: 2 The emoji was causing visual misalignment in terminal output because emoji characters have different display widths compared to regular ASCII characters like ~ and -. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
This commit introduces pagination and error handling utilities to eliminate duplication in the state client layer, achieving ~200+ lines reduction. ## Pagination Utility Implementation **New file**: `internal/declarative/state/pagination.go` - `PaginateAll[T]()` - Generic pagination utility for all list methods - `PaginatedLister[T]` - Function type for paginated API calls - `PageMeta` - Normalized pagination metadata structure - Handles standard pageSize=100, pageNumber increment, and break conditions ## Error Handling Utilities **New file**: `internal/declarative/state/error_utils.go` - `ValidateAPIClient()` - Consistent API client validation - `ValidateResponse[T]()` - Generic response validation with type safety - `WrapAPIError()` - Unified error wrapping with optional enhancement - `APIClientError` & `ResponseValidationError` - Structured error types - Standard error message constants for all client types ## List Method Migrations **Refactored methods** (from duplicated pagination to utility): - `ListManagedPortals()` - 48 lines → 25 lines (48% reduction) - `ListManagedAPIs()` - 54 lines → 27 lines (50% reduction) - `ListManagedAuthStrategies()` - 108 lines → 48 lines (56% reduction) - Extracted `extractAuthStrategyFromUnion()` helper method - Maintained complex union type handling logic **Error handling improvements**: - `CreatePortal()` - Uses new error utilities with enhanced context - Consistent error messages across all methods - Type-safe response validation ## Benefits Achieved - **Code reduction**: ~200+ lines eliminated from pagination boilerplate - **Consistency**: All list methods follow identical patterns - **Type safety**: Generic utilities prevent runtime type errors - **Maintainability**: Single place for pagination and error logic changes - **Testability**: Utilities can be tested independently ## Backward Compatibility - All public interfaces remain unchanged - Exact same behavior and error messages maintained - No breaking changes to existing functionality All tests pass with zero regressions. The refactoring maintains 100% functional compatibility while significantly reducing code duplication. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Portal child resources (pages, snippets, customizations, custom domains) were being planned twice - once when processing each portal and again at the end of PlanChanges. This caused duplicates in the execution plan. The fix removes the redundant planning calls at the end of PlanChanges since child resources are already properly planned when processing each portal. Co-Authored-By: Claude <[email protected]>
…rces This commit addresses several critical bugs that were preventing proper synchronization of portal child resources and API documents: ## Portal Child Resource Execution Fixes - Added missing Parent field setting for portal snippets in planner - Fixed portal ID resolution in executor for portal pages and snippets - Ensured portal references are resolved before calling adapters ## API Document Execution Fixes - Added References field to API document planning for all operations - Implemented resolveAPIRef method in executor to resolve API references - Updated planAPIDocumentUpdate signature to include apiID parameter ## Portal Resource Duplication Fix - Removed redundant child resource planning calls in portal_planner.go - Child resources are now only planned once per portal, eliminating duplicates ## Multi-Namespace Support Fix - Fixed panic in sortResourceTypesByDependency with multi-namespace configs - Added safety check to initialize map entries for cross-namespace dependencies ## UI Improvements - Reorganized plan summary to show "Namespaces affected" after "Total changes" - Provides better logical flow from high-level to detailed information ## Test Additions - Added error_utils_test.go and pagination_test.go for better test coverage All changes maintain backward compatibility and have been verified with: - ✅ Build passes - ✅ Lint passes (0 issues) - ✅ Unit tests pass - ✅ Integration tests pass - ✅ Portal sync works correctly with child resources - ✅ API document sync works correctly - ✅ Multi-namespace configurations work without panic 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Stage 7 (Testing, Documentation, and Core Improvements) is now complete with all 15 steps finished. This marks the completion of all planned stages for the declarative configuration feature. Key accomplishments in Stage 7: - Konnect-first command structure implemented - Comprehensive integration test coverage - Enhanced error messages and UX improvements - Progress indicators for long operations - Code quality improvements through refactoring sessions All 7 stages of the declarative configuration feature are now complete: - Stage 1: Configuration Format & Basic CLI - Stage 2: Plan Generation with Label Management - Stage 3: Plan Execution - Stage 4: API Resources and Multi-Resource Support - Stage 5: Sync Command Implementation - Stage 6: Namespace-Based Resource Management - Stage 7: Testing, Documentation, and Core Improvements The implementation is production-ready with full support for: - Portals, APIs, and all child resources - Complete sync/apply/plan/diff command suite - Namespace-based resource isolation - Comprehensive error handling - Extensive test coverage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Added CLAUDE.local.md file to store local development context that should not be committed to the repository. This file contains authentication information for development, specifically the PAT flag usage pattern: --pat $(cat ~/.konnect/claude.pat) This ensures future Claude Code sessions have the necessary context to run Konnect commands with proper authentication during development. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements the declarative configuration feature