Skip to content

Commit

Permalink
renaming test util var
Browse files Browse the repository at this point in the history
  • Loading branch information
lindnerby committed Sep 26, 2023
1 parent 38e3ad6 commit 2b76d0b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions runtime-watcher/internal/handler_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func createAdmissionRequest(operation admissionv1.Operation, watchedName string,
func generateAdmissionRequestRawObject(objectName string, labels, annotations map[string]string,
isOldObject bool, changeObj ChangeObj,
) ([]byte, error) {
objectWatched := &internal.WatchedObject{
obj := &internal.WatchedObject{
Metadata: internal.Metadata{
Name: objectName,
Namespace: metav1.NamespaceDefault,
Expand All @@ -158,7 +158,7 @@ func generateAdmissionRequestRawObject(objectName string, labels, annotations ma
APIVersion: WatchedResourceAPIVersion,
}

configuredObjectWatched := configureObjectWatched(objectWatched, isOldObject, changeObj)
configuredObjectWatched := configureObjectWatched(obj, isOldObject, changeObj)

rawObject, err := json.Marshal(configuredObjectWatched)
if err != nil {
Expand All @@ -167,33 +167,33 @@ func generateAdmissionRequestRawObject(objectName string, labels, annotations ma
return rawObject, nil
}

func configureObjectWatched(objectWatched *internal.WatchedObject,
func configureObjectWatched(obj *internal.WatchedObject,
isOldObject bool, changeObj ChangeObj,
) *internal.WatchedObject {
if isOldObject {
switch changeObj {
case NoSpecField:
objectWatched.Spec = nil
obj.Spec = nil
case NoChange, SpecChange, StatusChange:
fallthrough
default:
objectWatched.Status[specOrStatusKey] = specOrStatusOldValue
objectWatched.Spec[specOrStatusKey] = specOrStatusOldValue
obj.Status[specOrStatusKey] = specOrStatusOldValue
obj.Spec[specOrStatusKey] = specOrStatusOldValue
}
} else {
switch changeObj {
case SpecChange:
objectWatched.Spec[specOrStatusKey] = specOrStatusNewValue
obj.Spec[specOrStatusKey] = specOrStatusNewValue
case StatusChange:
objectWatched.Status[specOrStatusKey] = specOrStatusNewValue
obj.Status[specOrStatusKey] = specOrStatusNewValue
case NoSpecField:
objectWatched.Spec = nil
obj.Spec = nil
case NoChange:
fallthrough
default:
objectWatched.Status[specOrStatusKey] = specOrStatusOldValue
objectWatched.Spec[specOrStatusKey] = specOrStatusOldValue
obj.Status[specOrStatusKey] = specOrStatusOldValue
obj.Spec[specOrStatusKey] = specOrStatusOldValue
}
}
return objectWatched
return obj
}

0 comments on commit 2b76d0b

Please sign in to comment.