diff --git a/runtime-watcher/internal/handler_util_test.go b/runtime-watcher/internal/handler_util_test.go index 3c0810ff..d1df925e 100644 --- a/runtime-watcher/internal/handler_util_test.go +++ b/runtime-watcher/internal/handler_util_test.go @@ -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, @@ -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 { @@ -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 }