Skip to content

Commit 71a233e

Browse files
changing mirror, aggregate and summary to private; rename correspondig setters methods
1 parent bf3d451 commit 71a233e

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

controllers/machine_controller_phases.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (r *MachineReconciler) reconcileBootstrap(ctx context.Context, cluster *clu
185185
}
186186

187187
// Report a summary of current status of the bootstrap object defined for this machine.
188-
conditions.SetMirrorCondition(m, clusterv1.BootstrapReadyCondition,
188+
conditions.SetMirror(m, clusterv1.BootstrapReadyCondition,
189189
conditions.UnstructuredGetter(bootstrapConfig),
190190
conditions.WithFallbackValue(ready, clusterv1.WaitingForDataSecretFallbackReason, clusterv1.ConditionSeverityInfo, ""),
191191
)
@@ -248,7 +248,7 @@ func (r *MachineReconciler) reconcileInfrastructure(ctx context.Context, cluster
248248
m.Status.InfrastructureReady = ready
249249

250250
// Report a summary of current status of the infrastructure object defined for this machine.
251-
conditions.SetMirrorCondition(m, clusterv1.InfrastructureReadyCondition,
251+
conditions.SetMirror(m, clusterv1.InfrastructureReadyCondition,
252252
conditions.UnstructuredGetter(infraConfig),
253253
conditions.WithFallbackValue(ready, clusterv1.WaitingForInfrastructureFallbackReason, clusterv1.ConditionSeverityInfo, ""),
254254
)

util/conditions/getter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ func GetLastTransitionTime(from Getter, t clusterv1.ConditionType) *metav1.Time
114114
return nil
115115
}
116116

117-
// Summary returns a Ready condition with the summary of all the conditions existing
117+
// summary returns a Ready condition with the summary of all the conditions existing
118118
// on an object. If the object does not have other conditions, no summary condition is generated.
119-
func Summary(from Getter, options ...MergeOption) *clusterv1.Condition {
119+
func summary(from Getter, options ...MergeOption) *clusterv1.Condition {
120120
conditions := from.GetConditions()
121121

122122
conditionsInScope := make([]localizedCondition, 0, len(conditions))
@@ -159,9 +159,9 @@ func WithFallbackValue(fallbackValue bool, reason string, severity clusterv1.Con
159159
}
160160
}
161161

162-
// Mirror mirrors the Ready condition from a dependent object into the target condition;
162+
// mirror mirrors the Ready condition from a dependent object into the target condition;
163163
// if the Ready condition does not exists in the source object, no target conditions is generated.
164-
func Mirror(from Getter, targetCondition clusterv1.ConditionType, options ...MirrorOptions) *clusterv1.Condition {
164+
func mirror(from Getter, targetCondition clusterv1.ConditionType, options ...MirrorOptions) *clusterv1.Condition {
165165
mirrorOpt := &mirrorOptions{}
166166
for _, o := range options {
167167
o(mirrorOpt)
@@ -188,7 +188,7 @@ func Mirror(from Getter, targetCondition clusterv1.ConditionType, options ...Mir
188188
// Aggregates all the the Ready condition from a list of dependent objects into the target object;
189189
// if the Ready condition does not exists in one of the source object, the object is excluded from
190190
// the aggregation; if none of the source object have ready condition, no target conditions is generated.
191-
func Aggregate(from []Getter, targetCondition clusterv1.ConditionType, options ...MergeOption) *clusterv1.Condition {
191+
func aggregate(from []Getter, targetCondition clusterv1.ConditionType, options ...MergeOption) *clusterv1.Condition {
192192
conditionsInScope := make([]localizedCondition, 0, len(from))
193193
for i := range from {
194194
condition := Get(from[i], clusterv1.ReadyCondition)

util/conditions/getter_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestMirror(t *testing.T) {
120120
t.Run(tt.name, func(t *testing.T) {
121121
g := NewWithT(t)
122122

123-
got := Mirror(tt.from, tt.t)
123+
got := mirror(tt.from, tt.t)
124124
if tt.want == nil {
125125
g.Expect(got).To(BeNil())
126126
return
@@ -161,7 +161,7 @@ func TestSummary(t *testing.T) {
161161
t.Run(tt.name, func(t *testing.T) {
162162
g := NewWithT(t)
163163

164-
got := Summary(tt.from)
164+
got := summary(tt.from)
165165
if tt.want == nil {
166166
g.Expect(got).To(BeNil())
167167
return
@@ -205,7 +205,7 @@ func TestAggregate(t *testing.T) {
205205
t.Run(tt.name, func(t *testing.T) {
206206
g := NewWithT(t)
207207

208-
got := Aggregate(tt.from, tt.t)
208+
got := aggregate(tt.from, tt.t)
209209
if tt.want == nil {
210210
g.Expect(got).To(BeNil())
211211
return

util/conditions/merge_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ func TestMergeRespectPriority(t *testing.T) {
8989
want *clusterv1.Condition
9090
}{
9191
{
92-
name: "Aggregate nil list return nil",
92+
name: "aggregate nil list return nil",
9393
conditions: nil,
9494
want: nil,
9595
},
9696
{
97-
name: "Aggregate empty list return nil",
97+
name: "aggregate empty list return nil",
9898
conditions: []*clusterv1.Condition{},
9999
want: nil,
100100
},

util/conditions/setter.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,21 @@ func MarkFalse(to Setter, t clusterv1.ConditionType, reason string, severity clu
115115
// SetSummary sets a Ready condition with the summary of all the conditions existing
116116
// on an object. If the object does not have other conditions, no summary condition is generated.
117117
func SetSummary(to Setter, options ...MergeOption) {
118-
Set(to, Summary(to, options...))
118+
Set(to, summary(to, options...))
119119
}
120120

121-
// SetMirrorCondition creates a new condition by mirroring the the Ready condition from a dependent object;
121+
// SetMirror creates a new condition by mirroring the the Ready condition from a dependent object;
122122
// if the Ready condition does not exists in the source object, no target conditions is generated.
123-
func SetMirrorCondition(to Setter, targetCondition clusterv1.ConditionType, from Getter, options ...MirrorOptions) {
124-
Set(to, Mirror(from, targetCondition, options...))
123+
func SetMirror(to Setter, targetCondition clusterv1.ConditionType, from Getter, options ...MirrorOptions) {
124+
Set(to, mirror(from, targetCondition, options...))
125125
}
126126

127-
// SetAggregateCondition creates a new condition with the aggregation of all the the Ready condition
127+
// SetAggregate creates a new condition with the aggregation of all the the Ready condition
128128
// from a list of dependent objects; if the Ready condition does not exists in one of the source object,
129129
// the object is excluded from the aggregation; if none of the source object have ready condition,
130130
// no target conditions is generated.
131-
func SetAggregateCondition(to Setter, targetCondition clusterv1.ConditionType, from []Getter, options ...MergeOption) {
132-
Set(to, Aggregate(from, targetCondition, options...))
131+
func SetAggregate(to Setter, targetCondition clusterv1.ConditionType, from []Getter, options ...MergeOption) {
132+
Set(to, aggregate(from, targetCondition, options...))
133133
}
134134

135135
// Delete deletes the condition with the given type.

0 commit comments

Comments
 (0)