Skip to content

Commit cd886e3

Browse files
committed
Rewrite BucketReconciler to new standards
Signed-off-by: Hidde Beydals <[email protected]>
1 parent 82583f2 commit cd886e3

File tree

6 files changed

+1071
-353
lines changed

6 files changed

+1071
-353
lines changed

api/v1beta1/bucket_types.go

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package v1beta1
1818

1919
import (
2020
"github.com/fluxcd/pkg/apis/meta"
21-
"github.com/fluxcd/pkg/runtime/conditions"
22-
apimeta "k8s.io/apimachinery/pkg/api/meta"
2321
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2422
)
2523

@@ -28,6 +26,18 @@ const (
2826
BucketKind = "Bucket"
2927
)
3028

29+
const (
30+
GenericBucketProvider string = "generic"
31+
AmazonBucketProvider string = "aws"
32+
)
33+
34+
const (
35+
// DownloadFailedCondition indicates a transient or persistent download failure. If True, observations on the
36+
// upstream Source revision are not possible, and the Artifact available for the Source may be outdated.
37+
// This is a "negative polarity" or "abnormal-true" type, and is only present on the resource if it is True.
38+
DownloadFailedCondition string = "DownloadFailed"
39+
)
40+
3141
// BucketSpec defines the desired state of an S3 compatible bucket
3242
type BucketSpec struct {
3343
// The S3 compatible storage provider name, default ('generic').
@@ -77,11 +87,6 @@ type BucketSpec struct {
7787
Suspend bool `json:"suspend,omitempty"`
7888
}
7989

80-
const (
81-
GenericBucketProvider string = "generic"
82-
AmazonBucketProvider string = "aws"
83-
)
84-
8590
// BucketStatus defines the observed state of a bucket
8691
type BucketStatus struct {
8792
// ObservedGeneration is the last observed generation.
@@ -113,45 +118,6 @@ const (
113118
BucketOperationFailedReason string = "BucketOperationFailed"
114119
)
115120

116-
// BucketProgressing resets the conditions of the Bucket to metav1.Condition of
117-
// type meta.ReadyCondition with status 'Unknown' and meta.ProgressingReason
118-
// reason and message. It returns the modified Bucket.
119-
func BucketProgressing(bucket Bucket) Bucket {
120-
bucket.Status.ObservedGeneration = bucket.Generation
121-
bucket.Status.URL = ""
122-
bucket.Status.Conditions = []metav1.Condition{}
123-
conditions.MarkUnknown(&bucket, meta.ReadyCondition, meta.ProgressingReason, "reconciliation in progress")
124-
return bucket
125-
}
126-
127-
// BucketReady sets the given Artifact and URL on the Bucket and sets the
128-
// meta.ReadyCondition to 'True', with the given reason and message. It returns
129-
// the modified Bucket.
130-
func BucketReady(bucket Bucket, artifact Artifact, url, reason, message string) Bucket {
131-
bucket.Status.Artifact = &artifact
132-
bucket.Status.URL = url
133-
conditions.MarkTrue(&bucket, meta.ReadyCondition, reason, message)
134-
return bucket
135-
}
136-
137-
// BucketNotReady sets the meta.ReadyCondition on the Bucket to 'False', with
138-
// the given reason and message. It returns the modified Bucket.
139-
func BucketNotReady(bucket Bucket, reason, message string) Bucket {
140-
conditions.MarkFalse(&bucket, meta.ReadyCondition, reason, message)
141-
return bucket
142-
}
143-
144-
// BucketReadyMessage returns the message of the metav1.Condition of type
145-
// meta.ReadyCondition with status 'True' if present, or an empty string.
146-
func BucketReadyMessage(bucket Bucket) string {
147-
if c := apimeta.FindStatusCondition(bucket.Status.Conditions, meta.ReadyCondition); c != nil {
148-
if c.Status == metav1.ConditionTrue {
149-
return c.Message
150-
}
151-
}
152-
return ""
153-
}
154-
155121
// GetConditions returns the status conditions of the object.
156122
func (in Bucket) GetConditions() []metav1.Condition {
157123
return in.Status.Conditions

0 commit comments

Comments
 (0)