Skip to content

Commit fea475a

Browse files
committed
Fix linting issues
1 parent 7ae5d0e commit fea475a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pkg/controller/controllerutil/controllerutil.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,18 @@ func referSameObject(a, b v1.OwnerReference) bool {
105105
// OperationType is the action result of a CreateOrUpdate call
106106
type OperationType string
107107

108-
const ( // They should complete the sentence "v1.Deployment has been ..."
109-
OperationNoop = "unchanged"
108+
const ( // They should complete the sentence "Deployment default/foo has been ..."
109+
// OperationNoop means that the resource has not been changed
110+
OperationNoop = "unchanged"
111+
// OperationCreated means that a new resource has been created
110112
OperationCreated = "created"
113+
// OperationUpdated means that an existing resource has been updated
111114
OperationUpdated = "updated"
112115
)
113116

114117
// CreateOrUpdate creates or updates a kuberenes resource. It takes in a key and
115118
// a placeholder for the existing object and returns the modified object
116-
func CreateOrUpdate(c client.Client, ctx context.Context, key client.ObjectKey, existing runtime.Object, t TransformFn) (runtime.Object, OperationType, error) {
119+
func CreateOrUpdate(ctx context.Context, c client.Client, key client.ObjectKey, existing runtime.Object, t TransformFn) (runtime.Object, OperationType, error) {
117120
err := c.Get(ctx, key, existing)
118121
var obj runtime.Object
119122

@@ -124,11 +127,11 @@ func CreateOrUpdate(c client.Client, ctx context.Context, key client.ObjectKey,
124127
}
125128

126129
err = c.Create(ctx, obj)
130+
127131
if err != nil {
128132
return nil, OperationNoop, err
129-
} else {
130-
return obj, OperationCreated, err
131133
}
134+
return obj, OperationCreated, err
132135
} else if err != nil {
133136
return nil, OperationNoop, err
134137
} else {
@@ -141,12 +144,10 @@ func CreateOrUpdate(c client.Client, ctx context.Context, key client.ObjectKey,
141144
err = c.Update(ctx, obj)
142145
if err != nil {
143146
return nil, OperationNoop, err
144-
} else {
145-
return obj, OperationUpdated, err
146147
}
147-
} else {
148-
return obj, OperationNoop, nil
148+
return obj, OperationUpdated, err
149149
}
150+
return obj, OperationNoop, nil
150151
}
151152
}
152153

0 commit comments

Comments
 (0)