Skip to content

Commit 3123992

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

File tree

6 files changed

+1118
-389
lines changed

6 files changed

+1118
-389
lines changed

api/v1beta1/bucket_types.go

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import (
2020
"time"
2121

2222
"github.com/fluxcd/pkg/apis/meta"
23-
"github.com/fluxcd/pkg/runtime/conditions"
24-
apimeta "k8s.io/apimachinery/pkg/api/meta"
2523
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2624
)
2725

@@ -30,6 +28,18 @@ const (
3028
BucketKind = "Bucket"
3129
)
3230

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

82-
const (
83-
GenericBucketProvider string = "generic"
84-
AmazonBucketProvider string = "aws"
85-
)
86-
8792
// BucketStatus defines the observed state of a bucket
8893
type BucketStatus struct {
8994
// ObservedGeneration is the last observed generation.
@@ -115,45 +120,6 @@ const (
115120
BucketOperationFailedReason string = "BucketOperationFailed"
116121
)
117122

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

0 commit comments

Comments
 (0)