@@ -19,6 +19,7 @@ package v1alpha1
19
19
import (
20
20
"time"
21
21
22
+ "github.com/fluxcd/pkg/apis/meta"
22
23
corev1 "k8s.io/api/core/v1"
23
24
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24
25
)
@@ -51,7 +52,8 @@ type BucketSpec struct {
51
52
// +optional
52
53
Region string `json:"region,omitempty"`
53
54
54
- // The secret name containing the bucket accesskey and secretkey.
55
+ // The name of the secret containing authentication credentials
56
+ // for the Bucket.
55
57
// +optional
56
58
SecretRef * corev1.LocalObjectReference `json:"secretRef,omitempty"`
57
59
@@ -63,8 +65,8 @@ type BucketSpec struct {
63
65
// +optional
64
66
Timeout * metav1.Duration `json:"timeout,omitempty"`
65
67
66
- // Ignore overrides the set of excluded patterns in the .sourceignore
67
- // format (which is the same as .gitignore).
68
+ // Ignore overrides the set of excluded patterns in the .sourceignore format
69
+ // (which is the same as .gitignore).
68
70
// +optional
69
71
Ignore * string `json:"ignore,omitempty"`
70
72
}
@@ -82,7 +84,7 @@ type BucketStatus struct {
82
84
83
85
// Conditions holds the conditions for the Bucket.
84
86
// +optional
85
- Conditions []SourceCondition `json:"conditions,omitempty"`
87
+ Conditions []meta. Condition `json:"conditions,omitempty"`
86
88
87
89
// URL is the download link for the artifact output of the last Bucket sync.
88
90
// +optional
@@ -94,61 +96,62 @@ type BucketStatus struct {
94
96
}
95
97
96
98
const (
97
- // BucketOperationSucceedReason represents the fact that the bucket listing
98
- // and download operations succeeded.
99
+ // BucketOperationSucceedReason represents the fact that the bucket listing and
100
+ // download operations succeeded.
99
101
BucketOperationSucceedReason string = "BucketOperationSucceed"
100
102
101
- // BucketOperationFailedReason represents the fact that the bucket listing
102
- // or download operations failed.
103
+ // BucketOperationFailedReason represents the fact that the bucket listing or
104
+ // download operations failed.
103
105
BucketOperationFailedReason string = "BucketOperationFailed"
104
106
)
105
107
106
- // BucketProgressing resets the conditions of the Bucket
107
- // to SourceCondition of type Ready with status unknown and
108
- // progressing reason and message. It returns the modified Bucket.
108
+ // BucketProgressing resets the conditions of the Bucket to meta.Condition of
109
+ // type meta.ReadyCondition with status 'Unknown' and meta.ProgressingReason
110
+ // reason and message. It returns the modified Bucket.
109
111
func BucketProgressing (bucket Bucket ) Bucket {
110
112
bucket .Status .ObservedGeneration = bucket .Generation
111
113
bucket .Status .URL = ""
112
- bucket .Status .Conditions = []SourceCondition {}
113
- SetBucketCondition (& bucket , ReadyCondition , corev1 .ConditionUnknown , ProgressingReason , "reconciliation in progress" )
114
+ bucket .Status .Conditions = []meta. Condition {}
115
+ SetBucketCondition (& bucket , meta . ReadyCondition , corev1 .ConditionUnknown , meta . ProgressingReason , "reconciliation in progress" )
114
116
return bucket
115
117
}
116
118
117
- // SetBucketCondition sets the given condition with the given status, reason and message on the Bucket.
118
- func SetBucketCondition (bucket * Bucket , condition string , status corev1.ConditionStatus , reason , message string ) {
119
- bucket .Status .Conditions = filterOutSourceCondition (bucket .Status .Conditions , condition )
120
- bucket .Status .Conditions = append (bucket .Status .Conditions , SourceCondition {
121
- Type : condition ,
119
+ // SetBucketCondition sets the given condition with the given status, reason and
120
+ // message on the Bucket.
121
+ func SetBucketCondition (bucket * Bucket , conditionType string , status corev1.ConditionStatus , reason , message string ) {
122
+ bucket .Status .Conditions = meta .FilterOutCondition (bucket .Status .Conditions , conditionType )
123
+ bucket .Status .Conditions = append (bucket .Status .Conditions , meta.Condition {
124
+ Type : conditionType ,
122
125
Status : status ,
123
126
LastTransitionTime : metav1 .Now (),
124
127
Reason : reason ,
125
128
Message : message ,
126
129
})
127
130
}
128
131
129
- // BucketReady sets the given artifact and url on the Bucket
130
- // and sets the ReadyCondition to True, with the given reason and
131
- // message. It returns the modified Bucket.
132
- func BucketReady (repository Bucket , artifact Artifact , url , reason , message string ) Bucket {
133
- repository .Status .Artifact = & artifact
134
- repository .Status .URL = url
135
- SetBucketCondition (& repository , ReadyCondition , corev1 .ConditionTrue , reason , message )
136
- return repository
132
+ // BucketReady sets the given Artifact and URL on the Bucket and sets the
133
+ // meta. ReadyCondition to ' True' , with the given reason and message. It returns
134
+ // the modified Bucket.
135
+ func BucketReady (bucket Bucket , artifact Artifact , url , reason , message string ) Bucket {
136
+ bucket .Status .Artifact = & artifact
137
+ bucket .Status .URL = url
138
+ SetBucketCondition (& bucket , meta . ReadyCondition , corev1 .ConditionTrue , reason , message )
139
+ return bucket
137
140
}
138
141
139
- // BucketNotReady sets the ReadyCondition on the given Bucket
140
- // to False, with the given reason and message. It returns the modified Bucket.
141
- func BucketNotReady (repository Bucket , reason , message string ) Bucket {
142
- SetBucketCondition (& repository , ReadyCondition , corev1 .ConditionFalse , reason , message )
143
- return repository
142
+ // BucketNotReady sets the meta. ReadyCondition on the Bucket to 'False', with
143
+ // the given reason and message. It returns the modified Bucket.
144
+ func BucketNotReady (bucket Bucket , reason , message string ) Bucket {
145
+ SetBucketCondition (& bucket , meta . ReadyCondition , corev1 .ConditionFalse , reason , message )
146
+ return bucket
144
147
}
145
148
146
- // BucketReadyMessage returns the message of the SourceCondition
147
- // of type Ready with status true if present, or an empty string.
148
- func BucketReadyMessage (repository Bucket ) string {
149
- for _ , condition := range repository . Status .Conditions {
150
- if condition . Type == ReadyCondition && condition .Status == corev1 .ConditionTrue {
151
- return condition .Message
149
+ // BucketReadyMessage returns the message of the meta.Condition of type
150
+ // meta.ReadyCondition with status 'True' if present, or an empty string.
151
+ func BucketReadyMessage (bucket Bucket ) string {
152
+ if c := meta . GetCondition ( bucket . Status .Conditions , meta . ReadyCondition ); c != nil {
153
+ if c .Status == corev1 .ConditionTrue {
154
+ return c .Message
152
155
}
153
156
}
154
157
return ""
@@ -162,8 +165,8 @@ func (in *Bucket) GetTimeout() time.Duration {
162
165
return BucketTimeout
163
166
}
164
167
165
- // GetArtifact returns the latest artifact from the source
166
- // if present in the status sub-resource.
168
+ // GetArtifact returns the latest artifact from the source if present in the
169
+ // status sub-resource.
167
170
func (in * Bucket ) GetArtifact () * Artifact {
168
171
return in .Status .Artifact
169
172
}
0 commit comments