Skip to content

Conversation

@devantler
Copy link
Collaborator

@devantler devantler commented Dec 28, 2025

Introduce a new GitOpsCRDetector for detecting existing resources and update the scaffolder to generate appropriate CR manifests. Adjust documentation to reflect these changes and correct table formatting in the configuration documentation.

Also remove the Flux interval configuration from KSail to streamline GitOps resource management.

Fixes #1604

Type of change

  • 🧹 Refactor
  • 🪲 Bug fix
  • 🚀 New feature
  • ⛓️‍💥 Breaking change
  • 📚 Documentation update

…ps resources

- Removed the Flux interval configuration from the KSail spec.
- Updated documentation to reflect changes in GitOps engine scaffolding.
- Introduced GitOpsCRDetector for detecting existing FluxInstance and ArgoCD Application resources.
- Added generators for FluxInstance and ArgoCD Application CR manifests.
- Updated scaffolder to generate GitOps resources based on the configured GitOps engine.
- Removed Flux interval validation and related tests.
- Adjusted resource building logic to use default interval values from the generated CRs.

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
@github-project-automation github-project-automation bot moved this to 🏃🏻‍♂️ In Progress in 🌊 Project Board Dec 28, 2025
@devantler devantler self-assigned this Dec 28, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 28, 2025

@codecov
Copy link

codecov bot commented Dec 28, 2025

@devantler devantler marked this pull request as ready for review December 28, 2025 16:52
Copilot AI review requested due to automatic review settings December 28, 2025 16:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements GitOps CR scaffolding support, introducing automated generation of FluxInstance and ArgoCD Application custom resources when a GitOps engine is configured. The feature removes the Flux interval configuration from the KSail config schema (moving it to the FluxInstance CR) and adds detection logic to prevent overwriting existing GitOps CRs.

Key changes:

  • New GitOpsCRDetector that recursively searches for existing FluxInstance/ArgoCD Application CRs by matching apiVersion, kind, and KSail-managed identifiers (name or label)
  • New generators for FluxInstance and ArgoCD Application CRs with OCI registry configuration
  • Removed spec.cluster.flux.interval configuration field and related validation, tests, and field selectors

Reviewed changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
schemas/ksail-config.schema.json Removed Flux interval configuration from schema, marked flux options as alpha placeholder
pkg/svc/installer/flux/resources.go Updated to use fallback interval instead of config-based interval
pkg/io/validator/ksail/validator_test.go Removed test case for Flux interval validation
pkg/io/validator/ksail/validator.go Removed Flux interval validation logic
pkg/io/scaffolder/scaffolder.go Added GitOps CR scaffolding with detection and kustomization resource references
pkg/io/generator/kustomization/generator.go Added nil check for Resources field initialization
pkg/io/generator/generator.go Added BuildOCIURL utility function for constructing OCI registry URLs
pkg/io/generator/flux/flux_instance.go New generator for FluxInstance CR manifests
pkg/io/generator/argocd/application.go New generator for ArgoCD Application CR manifests
pkg/io/detector/gitops.go New detector for finding existing GitOps CRs in source directory
pkg/io/detector/doc.go Package documentation for detector
pkg/io/config-manager/ksail/manager_test.go Removed tests for Flux interval parsing
pkg/io/config-manager/ksail/field_selector_test.go Removed tests and assertions for Flux interval field selector
pkg/io/config-manager/ksail/field_selector.go Removed DefaultFluxIntervalFieldSelector
pkg/io/config-manager/ksail/binding_test.go Removed Flux interval field test cases
pkg/io/config-manager/ksail/binding.go Removed flux-interval field mapping
pkg/apis/cluster/v1alpha1/types.go Removed Interval field from OptionsFlux struct
pkg/apis/cluster/v1alpha1/marshal.go Removed Flux interval marshalling logic
pkg/apis/cluster/v1alpha1/defaults.go Removed DefaultFluxInterval constant and imports
go.sum Updated c2sp.org/CCTV/age and filippo.io/age dependencies
docs/declarative-configuration.md Updated GitOps engine documentation and removed Flux interval option
docs/core-concepts.md Updated GitOps section with CR scaffolding information
docs/cli-flags/* Removed --flux-interval flag from all CLI command documentation

@botantler botantler bot enabled auto-merge (squash) December 28, 2025 17:07
- Fix YAML document separator pattern to handle files starting with '---'
- Fix FluxInstance Ref field from 'oci://latest' to 'latest'
- Add comprehensive unit tests for GitOpsCRDetector
- Add comprehensive unit tests for FluxInstance generator
- Add comprehensive unit tests for ArgoCD Application generator
- Add comprehensive unit tests for BuildOCIURL utility function
Copilot AI review requested due to automatic review settings December 28, 2025 17:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 5 comments.

devantler and others added 2 commits December 28, 2025 18:24
… code

- Add json struct tags to FluxInstance types for sigs.k8s.io/yaml compatibility
- Add json struct tags to ArgoCD Application types for sigs.k8s.io/yaml compatibility
- Remove redundant GitOpsEngineNone case in generateGitOpsConfig (already handled earlier)
- Update test snapshots with correct lowercase YAML field names
Copilot AI review requested due to automatic review settings December 28, 2025 17:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 1 comment.

devantler and others added 2 commits December 28, 2025 18:34
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Copilot AI review requested due to automatic review settings December 28, 2025 17:44
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated no new comments.

@devantler devantler disabled auto-merge December 28, 2025 18:09
@devantler devantler merged commit 0dac39c into main Dec 28, 2025
48 of 50 checks passed
@devantler devantler deleted the feat/scaffold-fluxinstance-and-argocd-application-crs branch December 28, 2025 18:09
@github-project-automation github-project-automation bot moved this from 🏃🏻‍♂️ In Progress to ✅ Done in 🌊 Project Board Dec 28, 2025
devantler added a commit that referenced this pull request Dec 28, 2025
* feat: remove Flux interval configuration from KSail and scaffold GitOps resources

- Removed the Flux interval configuration from the KSail spec.
- Updated documentation to reflect changes in GitOps engine scaffolding.
- Introduced GitOpsCRDetector for detecting existing FluxInstance and ArgoCD Application resources.
- Added generators for FluxInstance and ArgoCD Application CR manifests.
- Updated scaffolder to generate GitOps resources based on the configured GitOps engine.
- Removed Flux interval validation and related tests.
- Adjusted resource building logic to use default interval values from the generated CRs.

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

* fix: correct table formatting in declarative configuration documentation

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

* chore: update generated JSON schema

* chore: tidy go modules

* chore: update generated CLI flags docs

* feat: refactor OCI URL construction to use shared generator function

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

* chore: Apply megalinter fixes

* chore: apply golangci-lint fixes

* fix: address PR review feedback for GitOps scaffolding

- Fix YAML document separator pattern to handle files starting with '---'
- Fix FluxInstance Ref field from 'oci://latest' to 'latest'
- Add comprehensive unit tests for GitOpsCRDetector
- Add comprehensive unit tests for FluxInstance generator
- Add comprehensive unit tests for ArgoCD Application generator
- Add comprehensive unit tests for BuildOCIURL utility function

* fix: add json struct tags for proper YAML field names and remove dead code

- Add json struct tags to FluxInstance types for sigs.k8s.io/yaml compatibility
- Add json struct tags to ArgoCD Application types for sigs.k8s.io/yaml compatibility
- Remove redundant GitOpsEngineNone case in generateGitOpsConfig (already handled earlier)
- Update test snapshots with correct lowercase YAML field names

* fix: golangci-lint issues

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

* test: add GitOps scaffolding tests for Flux and ArgoCD

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

---------

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Co-authored-by: devantler <26203420+devantler@users.noreply.github.com>
Co-authored-by: botantler[bot] <185060876+botantler[bot]@users.noreply.github.com>
devantler added a commit that referenced this pull request Dec 28, 2025
* docs: rework documentation for configuration

- Created documentation for `ksail workload install`, `logs`, `push`, `reconcile`, `root`, `scale`, `validate`, and `wait` commands.
- Added a comprehensive `declarative-configuration.md` file detailing the `ksail.yaml` structure and examples.
- Updated `index.md` to include new configuration documentation and improved navigation.
- Enhanced `core-concepts.md` and `use-cases.md` to reference the new documentation structure.

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

* feat: Update GitOps scaffolding (#1607)

* feat: remove Flux interval configuration from KSail and scaffold GitOps resources

- Removed the Flux interval configuration from the KSail spec.
- Updated documentation to reflect changes in GitOps engine scaffolding.
- Introduced GitOpsCRDetector for detecting existing FluxInstance and ArgoCD Application resources.
- Added generators for FluxInstance and ArgoCD Application CR manifests.
- Updated scaffolder to generate GitOps resources based on the configured GitOps engine.
- Removed Flux interval validation and related tests.
- Adjusted resource building logic to use default interval values from the generated CRs.

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

* fix: correct table formatting in declarative configuration documentation

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

* chore: update generated JSON schema

* chore: tidy go modules

* chore: update generated CLI flags docs

* feat: refactor OCI URL construction to use shared generator function

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

* chore: Apply megalinter fixes

* chore: apply golangci-lint fixes

* fix: address PR review feedback for GitOps scaffolding

- Fix YAML document separator pattern to handle files starting with '---'
- Fix FluxInstance Ref field from 'oci://latest' to 'latest'
- Add comprehensive unit tests for GitOpsCRDetector
- Add comprehensive unit tests for FluxInstance generator
- Add comprehensive unit tests for ArgoCD Application generator
- Add comprehensive unit tests for BuildOCIURL utility function

* fix: add json struct tags for proper YAML field names and remove dead code

- Add json struct tags to FluxInstance types for sigs.k8s.io/yaml compatibility
- Add json struct tags to ArgoCD Application types for sigs.k8s.io/yaml compatibility
- Remove redundant GitOpsEngineNone case in generateGitOpsConfig (already handled earlier)
- Update test snapshots with correct lowercase YAML field names

* fix: golangci-lint issues

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

* test: add GitOps scaffolding tests for Flux and ArgoCD

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

---------

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Co-authored-by: devantler <26203420+devantler@users.noreply.github.com>
Co-authored-by: botantler[bot] <185060876+botantler[bot]@users.noreply.github.com>

* docs: simplify argument handling in generate_command_docs function

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

---------

Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Co-authored-by: devantler <26203420+devantler@users.noreply.github.com>
Co-authored-by: botantler[bot] <185060876+botantler[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

[feature]: Scaffold FluxInstance / ArgoCD Application CRs into source dir when GitOps is configured

2 participants