-
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Update GitOps scaffolding #1607
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
feat: Update GitOps scaffolding #1607
Conversation
…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>
✅MegaLinter analysis: Success✅ Linters with no issuesactionlint, bash-exec, checkov, git_diff, grype, hadolint, jscpd, jsonlint, lychee, markdown-table-formatter, markdownlint, prettier, prettier, shellcheck, shfmt, syft, trivy, trivy-sbom, trufflehog, v8r, v8r, yamllint See detailed reports in MegaLinter artifacts |
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this 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
GitOpsCRDetectorthat 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.intervalconfiguration 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 |
- 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
There was a problem hiding this 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.
… 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
There was a problem hiding this 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.
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
There was a problem hiding this 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.
* 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: 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>

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