From 340f3bc89b41f5facc521fe7172439d14613fdbd Mon Sep 17 00:00:00 2001 From: Rohit Ramkumar Date: Wed, 22 Aug 2018 15:55:38 -0700 Subject: [PATCH] Export getPatchBytes in pkg/util --- pkg/utils/finalizer.go | 4 ++-- pkg/utils/finalizer_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/utils/finalizer.go b/pkg/utils/finalizer.go index c00ebcd9b6..fdf06ca2cb 100644 --- a/pkg/utils/finalizer.go +++ b/pkg/utils/finalizer.go @@ -40,9 +40,9 @@ func hasFinalizer(m meta_v1.ObjectMeta, key string) bool { return slice.ContainsString(m.Finalizers, key, nil) } -// getPatchBytes returns a patch which is the difference between the old and new objects. +// GetPatchBytes returns a patch which is the difference between the old and new objects. // Note: refStruct is a empty struct of the type which the patch is being generated for. -func getPatchBytes(old interface{}, cur interface{}, refStruct interface{}) ([]byte, error) { +func GetPatchBytes(old interface{}, cur interface{}, refStruct interface{}) ([]byte, error) { oldBytes, err := json.Marshal(old) if err != nil { return nil, fmt.Errorf("failed to marshal old object: %v", err) diff --git a/pkg/utils/finalizer_test.go b/pkg/utils/finalizer_test.go index 84ab904b04..202474d4b7 100644 --- a/pkg/utils/finalizer_test.go +++ b/pkg/utils/finalizer_test.go @@ -28,24 +28,24 @@ func TestGetPatchBytes(t *testing.T) { Finalizers: []string{"foo"}, }, } - b, err := getPatchBytes(ing, updated, extensions.Ingress{}) + b, err := GetPatchBytes(ing, updated, extensions.Ingress{}) if err != nil { t.Fatal(err) } expected := `{"metadata":{"finalizers":["foo"]}}` if string(b) != expected { - t.Errorf("getPatchBytes(%+v, %+v) = %s ; want %s", ing, updated, string(b), expected) + t.Errorf("GetPatchBytes(%+v, %+v) = %s ; want %s", ing, updated, string(b), expected) } // Patch an Ingress with the finalizer removed ing = updated updated = &extensions.Ingress{} - b, err = getPatchBytes(ing, updated, extensions.Ingress{}) + b, err = GetPatchBytes(ing, updated, extensions.Ingress{}) if err != nil { t.Fatal(err) } expected = `{"metadata":{"finalizers":null}}` if string(b) != expected { - t.Errorf("getPatchBytes(%+v, %+v) = %s ; want %s", ing, updated, string(b), expected) + t.Errorf("GetPatchBytes(%+v, %+v) = %s ; want %s", ing, updated, string(b), expected) } }