@@ -19,6 +19,7 @@ package v1beta1
1919import (
2020 "github.com/fluxcd/pkg/apis/meta"
2121 corev1 "k8s.io/api/core/v1"
22+ apimeta "k8s.io/apimachinery/pkg/api/meta"
2223 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324)
2425
@@ -63,7 +64,7 @@ type HelmRepositoryStatus struct {
6364
6465 // Conditions holds the conditions for the HelmRepository.
6566 // +optional
66- Conditions []meta .Condition `json:"conditions,omitempty"`
67+ Conditions []metav1 .Condition `json:"conditions,omitempty"`
6768
6869 // URL is the download link for the last index fetched.
6970 // +optional
@@ -85,53 +86,40 @@ const (
8586)
8687
8788// HelmRepositoryProgressing resets the conditions of the HelmRepository to
88- // meta .Condition of type meta.ReadyCondition with status 'Unknown' and
89+ // metav1 .Condition of type meta.ReadyCondition with status 'Unknown' and
8990// meta.ProgressingReason reason and message. It returns the modified
9091// HelmRepository.
9192func HelmRepositoryProgressing (repository HelmRepository ) HelmRepository {
9293 repository .Status .ObservedGeneration = repository .Generation
9394 repository .Status .URL = ""
94- repository .Status .Conditions = []meta .Condition {}
95- SetHelmRepositoryCondition (& repository , meta .ReadyCondition , corev1 .ConditionUnknown , meta .ProgressingReason , "reconciliation in progress" )
95+ repository .Status .Conditions = []metav1 .Condition {}
96+ meta . SetResourceCondition (& repository , meta .ReadyCondition , metav1 .ConditionUnknown , meta .ProgressingReason , "reconciliation in progress" )
9697 return repository
9798}
9899
99- // SetHelmRepositoryCondition sets the given condition with the given status,
100- // reason and message on the HelmRepository.
101- func SetHelmRepositoryCondition (repository * HelmRepository , condition string , status corev1.ConditionStatus , reason , message string ) {
102- repository .Status .Conditions = meta .FilterOutCondition (repository .Status .Conditions , condition )
103- repository .Status .Conditions = append (repository .Status .Conditions , meta.Condition {
104- Type : condition ,
105- Status : status ,
106- LastTransitionTime : metav1 .Now (),
107- Reason : reason ,
108- Message : message ,
109- })
110- }
111-
112100// HelmRepositoryReady sets the given Artifact and URL on the HelmRepository and
113101// sets the meta.ReadyCondition to 'True', with the given reason and message. It
114102// returns the modified HelmRepository.
115103func HelmRepositoryReady (repository HelmRepository , artifact Artifact , url , reason , message string ) HelmRepository {
116104 repository .Status .Artifact = & artifact
117105 repository .Status .URL = url
118- SetHelmRepositoryCondition (& repository , meta .ReadyCondition , corev1 .ConditionTrue , reason , message )
106+ meta . SetResourceCondition (& repository , meta .ReadyCondition , metav1 .ConditionTrue , reason , message )
119107 return repository
120108}
121109
122110// HelmRepositoryNotReady sets the meta.ReadyCondition on the given
123111// HelmRepository to 'False', with the given reason and message. It returns the
124112// modified HelmRepository.
125113func HelmRepositoryNotReady (repository HelmRepository , reason , message string ) HelmRepository {
126- SetHelmRepositoryCondition (& repository , meta .ReadyCondition , corev1 .ConditionFalse , reason , message )
114+ meta . SetResourceCondition (& repository , meta .ReadyCondition , metav1 .ConditionFalse , reason , message )
127115 return repository
128116}
129117
130- // HelmRepositoryReadyMessage returns the message of the meta .Condition of type
118+ // HelmRepositoryReadyMessage returns the message of the metav1 .Condition of type
131119// meta.ReadyCondition with status 'True' if present, or an empty string.
132120func HelmRepositoryReadyMessage (repository HelmRepository ) string {
133- if c := meta . GetCondition (repository .Status .Conditions , meta .ReadyCondition ); c != nil {
134- if c .Status == corev1 .ConditionTrue {
121+ if c := apimeta . FindStatusCondition (repository .Status .Conditions , meta .ReadyCondition ); c != nil {
122+ if c .Status == metav1 .ConditionTrue {
135123 return c .Message
136124 }
137125 }
@@ -144,6 +132,11 @@ func (in *HelmRepository) GetArtifact() *Artifact {
144132 return in .Status .Artifact
145133}
146134
135+ // GetStatusConditions returns a pointer to the Status.Conditions slice
136+ func (in * HelmRepository ) GetStatusConditions () * []metav1.Condition {
137+ return & in .Status .Conditions
138+ }
139+
147140// GetInterval returns the interval at which the source is updated.
148141func (in * HelmRepository ) GetInterval () metav1.Duration {
149142 return in .Spec .Interval
0 commit comments