Skip to content

Commit 9028c7a

Browse files
committed
Fix linting issues
1 parent 5b1f824 commit 9028c7a

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
@@ -54,15 +54,18 @@ func SetControllerReference(owner, object v1.Object, scheme *runtime.Scheme) err
5454
// OperationType is the action result of a CreateOrUpdate call
5555
type OperationType string
5656

57-
const ( // They should complete the sentence "v1.Deployment has been ..."
58-
OperationNoop = "unchanged"
57+
const ( // They should complete the sentence "Deployment default/foo has been ..."
58+
// OperationNoop means that the resource has not been changed
59+
OperationNoop = "unchanged"
60+
// OperationCreated means that a new resource has been created
5961
OperationCreated = "created"
62+
// OperationUpdated means that an existing resource has been updated
6063
OperationUpdated = "updated"
6164
)
6265

6366
// CreateOrUpdate creates or updates a kuberenes resource. It takes in a key and
6467
// a placeholder for the existing object and returns the modified object
65-
func CreateOrUpdate(c client.Client, ctx context.Context, key client.ObjectKey, existing runtime.Object, t TransformFn) (runtime.Object, OperationType, error) {
68+
func CreateOrUpdate(ctx context.Context, c client.Client, key client.ObjectKey, existing runtime.Object, t TransformFn) (runtime.Object, OperationType, error) {
6669
err := c.Get(ctx, key, existing)
6770
var obj runtime.Object
6871

@@ -73,11 +76,11 @@ func CreateOrUpdate(c client.Client, ctx context.Context, key client.ObjectKey,
7376
}
7477

7578
err = c.Create(ctx, obj)
79+
7680
if err != nil {
7781
return nil, OperationNoop, err
78-
} else {
79-
return obj, OperationCreated, err
8082
}
83+
return obj, OperationCreated, err
8184
} else if err != nil {
8285
return nil, OperationNoop, err
8386
} else {
@@ -90,12 +93,10 @@ func CreateOrUpdate(c client.Client, ctx context.Context, key client.ObjectKey,
9093
err = c.Update(ctx, obj)
9194
if err != nil {
9295
return nil, OperationNoop, err
93-
} else {
94-
return obj, OperationUpdated, err
9596
}
96-
} else {
97-
return obj, OperationNoop, nil
97+
return obj, OperationUpdated, err
9898
}
99+
return obj, OperationNoop, nil
99100
}
100101
}
101102

0 commit comments

Comments
 (0)