Skip to content

Commit 8e107ea

Browse files
committed
HelmChartReconciler refactor
Signed-off-by: Hidde Beydals <[email protected]>
1 parent e0e048a commit 8e107ea

13 files changed

+753
-562
lines changed

api/v1beta2/condition_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ const (
3232
// Source may be outdated.
3333
// This is a "negative polarity" or "abnormal-true" type, and is only present on the resource if it is True.
3434
FetchFailedCondition string = "FetchFailed"
35+
36+
// BuildFailedCondition indicates a transient or persistent build failure of a Source's Artifact.
37+
// If True, the Source can be in an ArtifactOutdatedCondition
38+
BuildFailedCondition string = "BuildFailed"
3539
)
3640

3741
const (

api/v1beta2/helmchart_types.go

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ package v1beta2
1919
import (
2020
"time"
2121

22-
apimeta "k8s.io/apimachinery/pkg/api/meta"
2322
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423

2524
"github.com/fluxcd/pkg/apis/acl"
2625
"github.com/fluxcd/pkg/apis/meta"
27-
"github.com/fluxcd/pkg/runtime/conditions"
2826
)
2927

3028
// HelmChartKind is the string representation of a HelmChart.
@@ -115,6 +113,16 @@ type HelmChartStatus struct {
115113
// +optional
116114
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
117115

116+
// ObservedSourceArtifactRevision is the last observed Artifact.Revision
117+
// of the Source reference.
118+
// +optional
119+
ObservedSourceArtifactRevision string `json:"observedSourceArtifactRevision,omitempty"`
120+
121+
// ObservedChartName is the last observed chart name as defined by the
122+
// resolved chart reference.
123+
// +optional
124+
ObservedChartName string `json:"observedChartName,omitempty"`
125+
118126
// Conditions holds the conditions for the HelmChart.
119127
// +optional
120128
Conditions []metav1.Condition `json:"conditions,omitempty"`
@@ -148,46 +156,6 @@ const (
148156
ChartPackageSucceededReason string = "ChartPackageSucceeded"
149157
)
150158

151-
// HelmChartProgressing resets the conditions of the HelmChart to meta.Condition
152-
// of type meta.ReadyCondition with status 'Unknown' and meta.ProgressingReason
153-
// reason and message. It returns the modified HelmChart.
154-
func HelmChartProgressing(chart HelmChart) HelmChart {
155-
chart.Status.ObservedGeneration = chart.Generation
156-
chart.Status.URL = ""
157-
chart.Status.Conditions = []metav1.Condition{}
158-
conditions.MarkUnknown(&chart, meta.ReadyCondition, meta.ProgressingReason, "reconciliation in progress")
159-
return chart
160-
}
161-
162-
// HelmChartReady sets the given Artifact and URL on the HelmChart and sets the
163-
// meta.ReadyCondition to 'True', with the given reason and message. It returns
164-
// the modified HelmChart.
165-
func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message string) HelmChart {
166-
chart.Status.Artifact = &artifact
167-
chart.Status.URL = url
168-
conditions.MarkTrue(&chart, meta.ReadyCondition, reason, message)
169-
return chart
170-
}
171-
172-
// HelmChartNotReady sets the meta.ReadyCondition on the given HelmChart to
173-
// 'False', with the given reason and message. It returns the modified
174-
// HelmChart.
175-
func HelmChartNotReady(chart HelmChart, reason, message string) HelmChart {
176-
conditions.MarkFalse(&chart, meta.ReadyCondition, reason, message)
177-
return chart
178-
}
179-
180-
// HelmChartReadyMessage returns the message of the meta.ReadyCondition with
181-
// status 'True', or an empty string.
182-
func HelmChartReadyMessage(chart HelmChart) string {
183-
if c := apimeta.FindStatusCondition(chart.Status.Conditions, meta.ReadyCondition); c != nil {
184-
if c.Status == metav1.ConditionTrue {
185-
return c.Message
186-
}
187-
}
188-
return ""
189-
}
190-
191159
// GetConditions returns the status conditions of the object.
192160
func (in HelmChart) GetConditions() []metav1.Condition {
193161
return in.Status.Conditions

config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,18 @@ spec:
517517
reconcile request value, so a change of the annotation value can
518518
be detected.
519519
type: string
520+
observedChartName:
521+
description: ObservedChartName is the last observed chart name as
522+
defined by the resolved chart reference.
523+
type: string
520524
observedGeneration:
521525
description: ObservedGeneration is the last observed generation.
522526
format: int64
523527
type: integer
528+
observedSourceArtifactRevision:
529+
description: ObservedSourceArtifactRevision is the last observed Artifact.Revision
530+
of the Source reference.
531+
type: string
524532
url:
525533
description: URL is the download link for the last chart pulled.
526534
type: string

0 commit comments

Comments
 (0)