@@ -25,25 +25,41 @@ const HelmChartKind = "HelmChart"
2525
2626// HelmChartSpec defines the desired state of a Helm chart.
2727type HelmChartSpec struct {
28- // The name of the Helm chart, as made available by the referenced
29- // Helm repository.
28+ // The name or path the Helm chart is available at in the SourceRef.
3029 // +required
31- Name string `json:"name "`
30+ Chart string `json:"chart "`
3231
33- // The chart version semver expression, defaults to latest when
34- // omitted.
32+ // The chart version semver expression, ignored for charts from GitRepository
33+ // sources. Defaults to latest when omitted.
3534 // +optional
3635 Version string `json:"version,omitempty"`
3736
38- // The name of the HelmRepository the chart is available at.
37+ // The reference to the Source the chart is available at.
3938 // +required
40- HelmRepositoryRef corev1. LocalObjectReference `json:"helmRepositoryRef "`
39+ SourceRef LocalHelmChartSourceReference `json:"sourceRef "`
4140
42- // The interval at which to check the Helm repository for updates.
41+ // The interval at which to check the Source for updates.
4342 // +required
4443 Interval metav1.Duration `json:"interval"`
4544}
4645
46+ // LocalHelmChartSourceReference contains enough information to let you locate the
47+ // typed referenced object at namespace level.
48+ type LocalHelmChartSourceReference struct {
49+ // APIVersion of the referent.
50+ // +optional
51+ APIVersion string `json:"apiVersion,omitempty"`
52+
53+ // Kind of the referent, valid values are ('HelmRepository', 'GitRepository').
54+ // +kubebuilder:validation:Enum=HelmRepository;GitRepository
55+ // +required
56+ Kind string `json:"kind"`
57+
58+ // Name of the referent.
59+ // +required
60+ Name string `json:"name"`
61+ }
62+
4763// HelmChartStatus defines the observed state of the HelmChart.
4864type HelmChartStatus struct {
4965 // +optional
@@ -63,72 +79,62 @@ const (
6379 // Helm chart failed.
6480 ChartPullFailedReason string = "ChartPullFailed"
6581
66- // ChartPulLSucceededReason represents the fact that the pull of
82+ // ChartPullSucceededReason represents the fact that the pull of
6783 // the Helm chart succeeded.
6884 ChartPullSucceededReason string = "ChartPullSucceeded"
69- )
7085
71- // HelmChartReady sets the given artifact and url on the HelmChart
72- // and resets the conditions to SourceCondition of type Ready with
73- // status true and the given reason and message. It returns the
74- // modified HelmChart.
75- func HelmChartReady (chart HelmChart , artifact Artifact , url , reason , message string ) HelmChart {
76- chart .Status .Conditions = []SourceCondition {
77- {
78- Type : ReadyCondition ,
79- Status : corev1 .ConditionTrue ,
80- LastTransitionTime : metav1 .Now (),
81- Reason : reason ,
82- Message : message ,
83- },
84- }
85- chart .Status .URL = url
86+ // ChartPackageFailedReason represent the fact that the package of
87+ // the Helm chart failed.
88+ ChartPackageFailedReason string = "ChartPackageFailed"
8689
87- if chart .Status .Artifact != nil {
88- if chart .Status .Artifact .Path != artifact .Path {
89- chart .Status .Artifact = & artifact
90- }
91- } else {
92- chart .Status .Artifact = & artifact
93- }
90+ // ChartPackageSucceededReason represents the fact that the package of
91+ // the Helm chart succeeded.
92+ ChartPackageSucceededReason string = "ChartPackageSucceeded"
93+ )
9494
95+ // HelmReleaseProgressing resets any failures and registers progress toward reconciling the given HelmRelease
96+ // by setting the ReadyCondition to ConditionUnknown for ProgressingReason.
97+ func HelmChartProgressing (chart HelmChart ) HelmChart {
98+ chart .Status .URL = ""
99+ chart .Status .Artifact = nil
100+ chart .Status .Conditions = []SourceCondition {}
101+ SetHelmChartCondition (& chart , ReadyCondition , corev1 .ConditionUnknown , ProgressingReason , "reconciliation in progress" )
95102 return chart
96103}
97104
98- // HelmChartProgressing resets the conditions of the HelmChart
99- // to SourceCondition of type Ready with status unknown and
100- // progressing reason and message. It returns the modified HelmChart.
101- func HelmChartProgressing (chart HelmChart ) HelmChart {
102- chart .Status .Conditions = []SourceCondition {
103- {
104- Type : ReadyCondition ,
105- Status : corev1 .ConditionUnknown ,
106- LastTransitionTime : metav1 .Now (),
107- Reason : ProgressingReason ,
108- Message : "reconciliation in progress" ,
109- },
110- }
105+ // SetHelmChartCondition sets the given condition with the given status, reason and message
106+ // on the HelmChart.
107+ func SetHelmChartCondition (chart * HelmChart , condition string , status corev1.ConditionStatus , reason , message string ) {
108+ chart .Status .Conditions = filterOutSourceCondition (chart .Status .Conditions , condition )
109+ chart .Status .Conditions = append (chart .Status .Conditions , SourceCondition {
110+ Type : condition ,
111+ Status : status ,
112+ LastTransitionTime : metav1 .Now (),
113+ Reason : reason ,
114+ Message : message ,
115+ })
116+ }
117+
118+ // HelmChartReady sets the given artifact and url on the HelmChart
119+ // and sets the ReadyCondition to True, with the given reason and
120+ // message. It returns the modified HelmChart.
121+ func HelmChartReady (chart HelmChart , artifact Artifact , url , reason , message string ) HelmChart {
122+ chart .Status .Artifact = & artifact
123+ chart .Status .URL = url
124+ SetHelmChartCondition (& chart , ReadyCondition , corev1 .ConditionTrue , reason , message )
111125 return chart
112126}
113127
114- // HelmChartNotReady resets the conditions of the HelmChart to
115- // SourceCondition of type Ready with status false and the given
116- // reason and message. It returns the modified HelmChart.
128+ // HelmChartNotReady sets the ReadyCondition on the given HelmChart
129+ // to False, with the given reason and message. It returns the modified
130+ // HelmChart.
117131func HelmChartNotReady (chart HelmChart , reason , message string ) HelmChart {
118- chart .Status .Conditions = []SourceCondition {
119- {
120- Type : ReadyCondition ,
121- Status : corev1 .ConditionFalse ,
122- LastTransitionTime : metav1 .Now (),
123- Reason : reason ,
124- Message : message ,
125- },
126- }
132+ SetHelmChartCondition (& chart , ReadyCondition , corev1 .ConditionFalse , reason , message )
127133 return chart
128134}
129135
130- // HelmChartReadyMessage returns the message of the SourceCondition
131- // of type Ready with status true if present , or an empty string.
136+ // HelmChartReadyMessage returns the message of the ReadyCondition
137+ // with status True , or an empty string.
132138func HelmChartReadyMessage (chart HelmChart ) string {
133139 for _ , condition := range chart .Status .Conditions {
134140 if condition .Type == ReadyCondition && condition .Status == corev1 .ConditionTrue {
@@ -153,9 +159,10 @@ func (in *HelmChart) GetInterval() metav1.Duration {
153159// +genclient:Namespaced
154160// +kubebuilder:object:root=true
155161// +kubebuilder:subresource:status
156- // +kubebuilder:printcolumn:name="Name ",type=string,JSONPath=`.spec.name `
162+ // +kubebuilder:printcolumn:name="Chart ",type=string,JSONPath=`.spec.chart `
157163// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=`.spec.version`
158- // +kubebuilder:printcolumn:name="Repository",type=string,JSONPath=`.spec.helmRepositoryRef.name`
164+ // +kubebuilder:printcolumn:name="Source Kind",type=string,JSONPath=`.spec.sourceRef.kind`
165+ // +kubebuilder:printcolumn:name="Source Name",type=string,JSONPath=`.spec.sourceRef.name`
159166// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
160167// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
161168// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
0 commit comments