Skip to content

Commit 43da779

Browse files
kvapsclaude
andcommitted
feat(api): add chartRef to CozystackResourceDefinition
Replace the chart field with chartRef for referencing Helm charts via ExternalArtifact resources. This enables the Package controller to manage chart sources centrally. Changes: - Add chartRef field to CozystackResourceDefinition spec - Remove chart field (deprecated) - Remove validation (moved to controller) - Update lineage mapper for new field structure - Regenerate openapi specs Co-Authored-By: Claude <[email protected]> Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 74d7160 commit 43da779

13 files changed

Lines changed: 106 additions & 222 deletions

File tree

‎api/v1alpha1/cozystackresourcedefinitions_types.go‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
helmv2 "github.com/fluxcd/helm-controller/api/v2"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
)
2223

@@ -61,24 +62,6 @@ type CozystackResourceDefinitionSpec struct {
6162
Dashboard *CozystackResourceDefinitionDashboard `json:"dashboard,omitempty"`
6263
}
6364

64-
type CozystackResourceDefinitionChart struct {
65-
// Name of the Helm chart
66-
Name string `json:"name"`
67-
// Source reference for the Helm chart
68-
SourceRef SourceRef `json:"sourceRef"`
69-
}
70-
71-
type SourceRef struct {
72-
// Kind of the source reference
73-
// +kubebuilder:default:="HelmRepository"
74-
Kind string `json:"kind"`
75-
// Name of the source reference
76-
Name string `json:"name"`
77-
// Namespace of the source reference
78-
// +kubebuilder:default:="cozy-public"
79-
Namespace string `json:"namespace"`
80-
}
81-
8265
type CozystackResourceDefinitionApplication struct {
8366
// Kind of the application, used for UI and API
8467
Kind string `json:"kind"`
@@ -91,9 +74,8 @@ type CozystackResourceDefinitionApplication struct {
9174
}
9275

9376
type CozystackResourceDefinitionRelease struct {
94-
// Helm chart configuration
95-
// +optional
96-
Chart CozystackResourceDefinitionChart `json:"chart,omitempty"`
77+
// Reference to the chart source
78+
ChartRef *helmv2.CrossNamespaceSourceReference `json:"chartRef"`
9779
// Labels for the release
9880
Labels map[string]string `json:"labels,omitempty"`
9981
// Prefix for the release name

‎api/v1alpha1/zz_generated.deepcopy.go‎

Lines changed: 6 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pkg/apis/apps/fuzzer/fuzzer.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package fuzzer
1818

1919
import (
20-
"github.com/cozystack/cozystack/pkg/apis/apps"
20+
"github.com/cozystack/cozystack/pkg/apis/apps/v1alpha1"
2121
fuzz "github.com/google/gofuzz"
2222

2323
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
@@ -26,7 +26,7 @@ import (
2626
// Funcs returns the fuzzer functions for the apps api group.
2727
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
2828
return []interface{}{
29-
func(s *apps.ApplicationSpec, c fuzz.Continue) {
29+
func(s *v1alpha1.Application, c fuzz.Continue) {
3030
c.FuzzNoCustom(s) // fuzz self without calling this function again
3131
},
3232
}

‎pkg/apis/apps/validation/validation.go‎

Lines changed: 0 additions & 40 deletions
This file was deleted.

‎pkg/apis/core/fuzzer/fuzzer.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package fuzzer
1818

1919
import (
20-
"github.com/cozystack/cozystack/pkg/apis/core"
20+
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1"
2121
fuzz "github.com/google/gofuzz"
2222

2323
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
@@ -26,7 +26,7 @@ import (
2626
// Funcs returns the fuzzer functions for the core api group.
2727
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
2828
return []interface{}{
29-
func(s *core.TenantNamespaceSpec, c fuzz.Continue) {
29+
func(s *v1alpha1.TenantNamespace, c fuzz.Continue) {
3030
c.FuzzNoCustom(s) // fuzz self without calling this function again
3131
},
3232
}

‎pkg/apis/core/validation/validation.go‎

Lines changed: 0 additions & 40 deletions
This file was deleted.

‎pkg/cmd/server/start.go‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,10 @@ func (o *CozyServerOptions) Complete() error {
169169
Release: config.ReleaseConfig{
170170
Prefix: crd.Spec.Release.Prefix,
171171
Labels: crd.Spec.Release.Labels,
172-
Chart: config.ChartConfig{
173-
Name: crd.Spec.Release.Chart.Name,
174-
SourceRef: config.SourceRefConfig{
175-
Kind: crd.Spec.Release.Chart.SourceRef.Kind,
176-
Name: crd.Spec.Release.Chart.SourceRef.Name,
177-
Namespace: crd.Spec.Release.Chart.SourceRef.Namespace,
178-
},
172+
ChartRef: config.ChartRefConfig{
173+
Kind: crd.Spec.Release.ChartRef.Kind,
174+
Name: crd.Spec.Release.ChartRef.Name,
175+
Namespace: crd.Spec.Release.ChartRef.Namespace,
179176
},
180177
},
181178
}

‎pkg/config/config.go‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,13 @@ type ApplicationConfig struct {
3838

3939
// ReleaseConfig contains the release settings.
4040
type ReleaseConfig struct {
41-
Prefix string `yaml:"prefix"`
42-
Labels map[string]string `yaml:"labels"`
43-
Chart ChartConfig `yaml:"chart"`
41+
Prefix string `yaml:"prefix"`
42+
Labels map[string]string `yaml:"labels"`
43+
ChartRef ChartRefConfig `yaml:"chartRef"`
4444
}
4545

46-
// ChartConfig contains the chart settings.
47-
type ChartConfig struct {
48-
Name string `yaml:"name"`
49-
SourceRef SourceRefConfig `yaml:"sourceRef"`
50-
}
51-
52-
// SourceRefConfig contains the reference to the chart source.
53-
type SourceRefConfig struct {
46+
// ChartRefConfig references a Flux source artifact for the Helm chart.
47+
type ChartRefConfig struct {
5448
Kind string `yaml:"kind"`
5549
Name string `yaml:"name"`
5650
Namespace string `yaml:"namespace"`

‎pkg/generated/openapi/zz_generated.openapi.go‎

Lines changed: 43 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pkg/lineage/lineage.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const (
2222
HRLabel = "helm.toolkit.fluxcd.io/name"
2323
)
2424

25+
// AppMapper maps HelmRelease to application metadata.
26+
type AppMapper interface {
27+
Map(*helmv2.HelmRelease) (apiVersion, kind, prefix string, err error)
28+
}
29+
2530
type ObjectID struct {
2631
APIVersion string
2732
Kind string

0 commit comments

Comments
 (0)