@@ -54,6 +54,11 @@ type HelmRepositorySpec struct {
5454
5555// HelmRepositoryStatus defines the observed state of the HelmRepository.
5656type HelmRepositoryStatus struct {
57+ // ObservedGeneration is the last observed generation.
58+ // +optional
59+ ObservedGeneration int64 `json:"observedGeneration,omitempty"`
60+
61+ // Conditions holds the conditions for the HelmRepository.
5762 // +optional
5863 Conditions []SourceCondition `json:"conditions,omitempty"`
5964
@@ -76,62 +81,46 @@ const (
7681 IndexationSucceededReason string = "IndexationSucceed"
7782)
7883
79- // HelmRepositoryReady sets the given artifact and url on the
80- // HelmRepository and resets the conditions to SourceCondition of
81- // type Ready with status true and the given reason and message.
82- // It returns the modified HelmRepository.
83- func HelmRepositoryReady (repository HelmRepository , artifact Artifact , url , reason , message string ) HelmRepository {
84- repository .Status .Conditions = []SourceCondition {
85- {
86- Type : ReadyCondition ,
87- Status : corev1 .ConditionTrue ,
88- LastTransitionTime : metav1 .Now (),
89- Reason : reason ,
90- Message : message ,
91- },
92- }
93- repository .Status .URL = url
94-
95- if repository .Status .Artifact != nil {
96- if repository .Status .Artifact .Path != artifact .Path {
97- repository .Status .Artifact = & artifact
98- }
99- } else {
100- repository .Status .Artifact = & artifact
101- }
102-
103- return repository
104- }
105-
10684// HelmRepositoryProgressing resets the conditions of the HelmRepository
10785// to SourceCondition of type Ready with status unknown and
10886// progressing reason and message. It returns the modified HelmRepository.
10987func HelmRepositoryProgressing (repository HelmRepository ) HelmRepository {
110- repository .Status .Conditions = []SourceCondition {
111- {
112- Type : ReadyCondition ,
113- Status : corev1 .ConditionUnknown ,
114- LastTransitionTime : metav1 .Now (),
115- Reason : ProgressingReason ,
116- Message : "reconciliation in progress" ,
117- },
118- }
88+ repository .Status .ObservedGeneration = repository .Generation
89+ repository .Status .URL = ""
90+ repository .Status .Artifact = nil
91+ repository .Status .Conditions = []SourceCondition {}
92+ SetHelmRepositoryCondition (& repository , ReadyCondition , corev1 .ConditionUnknown , ProgressingReason , "reconciliation in progress" )
93+ return repository
94+ }
95+
96+ // SetHelmRepositoryCondition sets the given condition with the given status,
97+ // reason and message on the HelmRepository.
98+ func SetHelmRepositoryCondition (repository * HelmRepository , condition string , status corev1.ConditionStatus , reason , message string ) {
99+ repository .Status .Conditions = filterOutSourceCondition (repository .Status .Conditions , condition )
100+ repository .Status .Conditions = append (repository .Status .Conditions , SourceCondition {
101+ Type : condition ,
102+ Status : status ,
103+ LastTransitionTime : metav1 .Now (),
104+ Reason : reason ,
105+ Message : message ,
106+ })
107+ }
108+
109+ // HelmRepositoryReady sets the given artifact and url on the HelmRepository
110+ // and sets the ReadyCondition to True, with the given reason and
111+ // message. It returns the modified HelmRepository.
112+ func HelmRepositoryReady (repository HelmRepository , artifact Artifact , url , reason , message string ) HelmRepository {
113+ repository .Status .Artifact = & artifact
114+ repository .Status .URL = url
115+ SetHelmRepositoryCondition (& repository , ReadyCondition , corev1 .ConditionTrue , reason , message )
119116 return repository
120117}
121118
122- // HelmRepositoryNotReady resets the conditions of the HelmRepository
123- // to SourceCondition of type Ready with status false and the given
124- // reason and message. It returns the modified HelmRepository.
119+ // HelmRepositoryNotReady sets the ReadyCondition on the given HelmRepository
120+ // to False, with the given reason and message. It returns the modified
121+ // HelmRepository.
125122func HelmRepositoryNotReady (repository HelmRepository , reason , message string ) HelmRepository {
126- repository .Status .Conditions = []SourceCondition {
127- {
128- Type : ReadyCondition ,
129- Status : corev1 .ConditionFalse ,
130- LastTransitionTime : metav1 .Now (),
131- Reason : reason ,
132- Message : message ,
133- },
134- }
123+ SetHelmRepositoryCondition (& repository , ReadyCondition , corev1 .ConditionFalse , reason , message )
135124 return repository
136125}
137126
0 commit comments