diff --git a/cmd/kube-controller-manager/app/controllermanager.go b/cmd/kube-controller-manager/app/controllermanager.go index fe6b3caa89f..9824c58b97c 100644 --- a/cmd/kube-controller-manager/app/controllermanager.go +++ b/cmd/kube-controller-manager/app/controllermanager.go @@ -66,6 +66,7 @@ import ( "k8s.io/kubernetes/pkg/serviceaccount" "k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util/configz" + "k8s.io/kubernetes/pkg/util/crypto" "k8s.io/kubernetes/pkg/util/wait" "github.com/golang/glog" @@ -359,7 +360,7 @@ func StartControllers(s *options.CMServer, kubeClient *client.Client, kubeconfig if err != nil { return fmt.Errorf("error reading root-ca-file at %s: %v", s.RootCAFile, err) } - if _, err := util.CertsFromPEM(rootCA); err != nil { + if _, err := crypto.CertsFromPEM(rootCA); err != nil { return fmt.Errorf("error parsing root-ca-file at %s: %v", s.RootCAFile, err) } } else { diff --git a/cmd/kubelet/app/server.go b/cmd/kubelet/app/server.go index 19bb96049f2..80ae438fa85 100644 --- a/cmd/kubelet/app/server.go +++ b/cmd/kubelet/app/server.go @@ -60,6 +60,7 @@ import ( kubetypes "k8s.io/kubernetes/pkg/kubelet/types" "k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util/configz" + "k8s.io/kubernetes/pkg/util/crypto" "k8s.io/kubernetes/pkg/util/flock" "k8s.io/kubernetes/pkg/util/io" "k8s.io/kubernetes/pkg/util/mount" @@ -377,7 +378,7 @@ func InitializeTLS(s *options.KubeletServer) (*server.TLSOptions, error) { if s.TLSCertFile == "" && s.TLSPrivateKeyFile == "" { s.TLSCertFile = path.Join(s.CertDirectory, "kubelet.crt") s.TLSPrivateKeyFile = path.Join(s.CertDirectory, "kubelet.key") - if err := util.GenerateSelfSignedCert(nodeutil.GetHostname(s.HostnameOverride), s.TLSCertFile, s.TLSPrivateKeyFile, nil, nil); err != nil { + if err := crypto.GenerateSelfSignedCert(nodeutil.GetHostname(s.HostnameOverride), s.TLSCertFile, s.TLSPrivateKeyFile, nil, nil); err != nil { return nil, fmt.Errorf("unable to generate self signed cert: %v", err) } glog.V(4).Infof("Using self-signed cert (%s, %s)", s.TLSCertFile, s.TLSPrivateKeyFile) diff --git a/contrib/mesos/pkg/controllermanager/controllermanager.go b/contrib/mesos/pkg/controllermanager/controllermanager.go index e2ecdfad758..749f624f533 100644 --- a/contrib/mesos/pkg/controllermanager/controllermanager.go +++ b/contrib/mesos/pkg/controllermanager/controllermanager.go @@ -59,6 +59,7 @@ import ( quotainstall "k8s.io/kubernetes/pkg/quota/install" "k8s.io/kubernetes/pkg/serviceaccount" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/crypto" "k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/contrib/mesos/pkg/profile" @@ -309,7 +310,7 @@ func (s *CMServer) Run(_ []string) error { if err != nil { return fmt.Errorf("error reading root-ca-file at %s: %v", s.RootCAFile, err) } - if _, err := util.CertsFromPEM(rootCA); err != nil { + if _, err := crypto.CertsFromPEM(rootCA); err != nil { return fmt.Errorf("error parsing root-ca-file at %s: %v", s.RootCAFile, err) } } else { diff --git a/pkg/api/copy_test.go b/pkg/api/copy_test.go index 194b5318a42..af81d027329 100644 --- a/pkg/api/copy_test.go +++ b/pkg/api/copy_test.go @@ -25,7 +25,7 @@ import ( "k8s.io/kubernetes/pkg/api/testapi" apitesting "k8s.io/kubernetes/pkg/api/testing" "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "github.com/google/gofuzz" ) @@ -54,7 +54,7 @@ func doDeepCopyTest(t *testing.T, kind unversioned.GroupVersionKind, f *fuzz.Fuz } if !reflect.DeepEqual(item, itemCopy) { - t.Errorf("\nexpected: %#v\n\ngot: %#v\n\ndiff: %v", item, itemCopy, util.ObjectGoPrintSideBySide(item, itemCopy)) + t.Errorf("\nexpected: %#v\n\ngot: %#v\n\ndiff: %v", item, itemCopy, diff.ObjectGoPrintSideBySide(item, itemCopy)) } } diff --git a/pkg/api/meta/help_test.go b/pkg/api/meta/help_test.go index fa221b67861..85ba2cbf6d5 100644 --- a/pkg/api/meta/help_test.go +++ b/pkg/api/meta/help_test.go @@ -25,7 +25,7 @@ import ( "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "github.com/google/gofuzz" ) @@ -224,7 +224,7 @@ func TestSetListToRuntimeObjectArray(t *testing.T) { } for i := range list { if e, a := list[i], pl.Items[i]; e != a { - t.Fatalf("%d: unmatched: %s", i, util.ObjectDiff(e, a)) + t.Fatalf("%d: unmatched: %s", i, diff.ObjectDiff(e, a)) } } } diff --git a/pkg/api/serialization_proto_test.go b/pkg/api/serialization_proto_test.go index d74c1865dd3..752a7160c93 100644 --- a/pkg/api/serialization_proto_test.go +++ b/pkg/api/serialization_proto_test.go @@ -31,7 +31,7 @@ import ( _ "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime/protobuf" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func init() { @@ -53,7 +53,7 @@ func TestProtobufRoundTrip(t *testing.T) { } if !api.Semantic.Equalities.DeepEqual(out, obj) { t.Logf("marshal\n%s", hex.Dump(data)) - t.Fatalf("Unmarshal is unequal\n%s", util.ObjectGoPrintSideBySide(out, obj)) + t.Fatalf("Unmarshal is unequal\n%s", diff.ObjectGoPrintSideBySide(out, obj)) } } diff --git a/pkg/api/serialization_test.go b/pkg/api/serialization_test.go index b89260f5cd1..6513c92d143 100644 --- a/pkg/api/serialization_test.go +++ b/pkg/api/serialization_test.go @@ -33,7 +33,7 @@ import ( "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "k8s.io/kubernetes/pkg/util/sets" ) @@ -76,7 +76,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) { return } if !api.Semantic.DeepEqual(item, obj2) { - t.Errorf("\n1: %v: diff: %v\nCodec: %v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, util.ObjectGoPrintDiff(item, obj2), codec, printer.Sprintf("%#v", item), string(data), printer.Sprintf("%#v", obj2)) + t.Errorf("\n1: %v: diff: %v\nCodec: %v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, diff.ObjectGoPrintDiff(item, obj2), codec, printer.Sprintf("%#v", item), string(data), printer.Sprintf("%#v", obj2)) return } @@ -86,7 +86,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) { return } if !api.Semantic.DeepEqual(item, obj3) { - t.Errorf("3: %v: diff: %v\nCodec: %v", name, util.ObjectDiff(item, obj3), codec) + t.Errorf("3: %v: diff: %v\nCodec: %v", name, diff.ObjectDiff(item, obj3), codec) return } } @@ -210,7 +210,7 @@ func TestEncode_Ptr(t *testing.T) { t.Fatalf("Got wrong type") } if !api.Semantic.DeepEqual(obj2, pod) { - t.Errorf("\nExpected:\n\n %#v,\n\nGot:\n\n %#vDiff: %v\n\n", pod, obj2, util.ObjectDiff(obj2, pod)) + t.Errorf("\nExpected:\n\n %#v,\n\nGot:\n\n %#vDiff: %v\n\n", pod, obj2, diff.ObjectDiff(obj2, pod)) } } diff --git a/pkg/api/v1/conversion_test.go b/pkg/api/v1/conversion_test.go index cb64f47d802..ac0b4e682f0 100644 --- a/pkg/api/v1/conversion_test.go +++ b/pkg/api/v1/conversion_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/kubernetes/pkg/api/unversioned" versioned "k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func TestPodLogOptions(t *testing.T) { @@ -99,7 +99,7 @@ func TestPodLogOptions(t *testing.T) { t.Fatal(err) } if !reflect.DeepEqual(convertedLogOptions, versionedLogOptions) { - t.Fatalf("Unexpected deserialization:\n%s", util.ObjectGoPrintSideBySide(versionedLogOptions, convertedLogOptions)) + t.Fatalf("Unexpected deserialization:\n%s", diff.ObjectGoPrintSideBySide(versionedLogOptions, convertedLogOptions)) } } @@ -111,7 +111,7 @@ func TestPodLogOptions(t *testing.T) { t.Fatal(err) } if !reflect.DeepEqual(convertedLogOptions, unversionedLogOptions) { - t.Fatalf("Unexpected deserialization:\n%s", util.ObjectGoPrintSideBySide(unversionedLogOptions, convertedLogOptions)) + t.Fatalf("Unexpected deserialization:\n%s", diff.ObjectGoPrintSideBySide(unversionedLogOptions, convertedLogOptions)) } } } diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index 1c7daaf12db..89d3a1765ad 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -44,6 +44,7 @@ import ( "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/version" "k8s.io/kubernetes/pkg/watch" @@ -1892,7 +1893,7 @@ func TestDeleteWithOptions(t *testing.T) { t.Errorf("Unexpected delete: %s, expected %s", simpleStorage.deleted, ID) } if !api.Semantic.DeepEqual(simpleStorage.deleteOptions, item) { - t.Errorf("unexpected delete options: %s", util.ObjectDiff(simpleStorage.deleteOptions, item)) + t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item)) } } diff --git a/pkg/apiserver/authenticator/authn.go b/pkg/apiserver/authenticator/authn.go index 2654e6f3aa9..b95767ad938 100644 --- a/pkg/apiserver/authenticator/authn.go +++ b/pkg/apiserver/authenticator/authn.go @@ -22,7 +22,7 @@ import ( "k8s.io/kubernetes/pkg/auth/authenticator" "k8s.io/kubernetes/pkg/auth/authenticator/bearertoken" "k8s.io/kubernetes/pkg/serviceaccount" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/crypto" "k8s.io/kubernetes/plugin/pkg/auth/authenticator/password/passwordfile" "k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/basicauth" "k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/keystone" @@ -159,7 +159,7 @@ func newServiceAccountAuthenticator(keyfile string, lookup bool, serviceAccountG // newAuthenticatorFromClientCAFile returns an authenticator.Request or an error func newAuthenticatorFromClientCAFile(clientCAFile string) (authenticator.Request, error) { - roots, err := util.CertPoolFromFile(clientCAFile) + roots, err := crypto.CertPoolFromFile(clientCAFile) if err != nil { return nil, err } diff --git a/pkg/apiserver/resthandler_test.go b/pkg/apiserver/resthandler_test.go index c0ad951eab0..8cebbf558e2 100644 --- a/pkg/apiserver/resthandler_test.go +++ b/pkg/apiserver/resthandler_test.go @@ -31,7 +31,7 @@ import ( "k8s.io/kubernetes/pkg/api/testapi" "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "k8s.io/kubernetes/pkg/util/strategicpatch" ) @@ -255,7 +255,7 @@ func (tc *patchTestCase) Run(t *testing.T) { reallyExpectedPod := expectedObj.(*api.Pod) if !reflect.DeepEqual(*reallyExpectedPod, *resultPod) { - t.Errorf("%s mismatch: %v\n", tc.name, util.ObjectGoPrintDiff(reallyExpectedPod, resultPod)) + t.Errorf("%s mismatch: %v\n", tc.name, diff.ObjectGoPrintDiff(reallyExpectedPod, resultPod)) return } } diff --git a/pkg/client/record/events_cache_test.go b/pkg/client/record/events_cache_test.go index 08699d9a6ce..ab88e5e5f76 100644 --- a/pkg/client/record/events_cache_test.go +++ b/pkg/client/record/events_cache_test.go @@ -25,6 +25,7 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func makeObjectReference(kind, name, namespace string) api.ObjectReference { @@ -118,7 +119,7 @@ func validateEvent(messagePrefix string, actualEvent *api.Event, expectedEvent * } recvEvent.Name = expectedEvent.Name if e, a := expectedEvent, &recvEvent; !reflect.DeepEqual(e, a) { - t.Errorf("%v - diff: %s", messagePrefix, util.ObjectGoPrintDiff(e, a)) + t.Errorf("%v - diff: %s", messagePrefix, diff.ObjectGoPrintDiff(e, a)) } recvEvent.FirstTimestamp = actualFirstTimestamp recvEvent.LastTimestamp = actualLastTimestamp diff --git a/pkg/client/restclient/client_test.go b/pkg/client/restclient/client_test.go index 1982890671f..182b936b76a 100644 --- a/pkg/client/restclient/client_test.go +++ b/pkg/client/restclient/client_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/kubernetes/pkg/api/testapi" "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" utiltesting "k8s.io/kubernetes/pkg/util/testing" ) @@ -114,7 +114,7 @@ func TestDoRequestFailed(t *testing.T) { expected.APIVersion = "v1" expected.Kind = "Status" if !reflect.DeepEqual(&expected, &actual) { - t.Errorf("Unexpected mis-match: %s", util.ObjectDiff(status, &actual)) + t.Errorf("Unexpected mis-match: %s", diff.ObjectDiff(status, &actual)) } } diff --git a/pkg/client/restclient/config.go b/pkg/client/restclient/config.go index b084a8eb2b8..cbddb2682d5 100644 --- a/pkg/client/restclient/config.go +++ b/pkg/client/restclient/config.go @@ -31,7 +31,7 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/crypto" "k8s.io/kubernetes/pkg/version" ) @@ -235,7 +235,7 @@ func InClusterConfig() (*Config, error) { } tlsClientConfig := TLSClientConfig{} rootCAFile := "/var/run/secrets/kubernetes.io/serviceaccount/" + api.ServiceAccountRootCAKey - if _, err := util.CertPoolFromFile(rootCAFile); err != nil { + if _, err := crypto.CertPoolFromFile(rootCAFile); err != nil { glog.Errorf("Expected to load root CA config from %s, but got err: %v", rootCAFile, err) } else { tlsClientConfig.CAFile = rootCAFile diff --git a/pkg/controller/node/nodecontroller_test.go b/pkg/controller/node/nodecontroller_test.go index 10dee92e049..0b69e5679bd 100644 --- a/pkg/controller/node/nodecontroller_test.go +++ b/pkg/controller/node/nodecontroller_test.go @@ -32,6 +32,7 @@ import ( unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned" fakecloud "k8s.io/kubernetes/pkg/cloudprovider/providers/fake" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/watch" ) @@ -736,10 +737,10 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) { t.Errorf("expected %v call, but got %v.", item.expectedRequestCount, item.fakeNodeHandler.RequestCount) } if len(item.fakeNodeHandler.UpdatedNodes) > 0 && !api.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) { - t.Errorf("Case[%d] unexpected nodes: %s", i, util.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0])) + t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0])) } if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !api.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) { - t.Errorf("Case[%d] unexpected nodes: %s", i, util.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0])) + t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0])) } } } diff --git a/pkg/conversion/converter_test.go b/pkg/conversion/converter_test.go index c639492a752..6dde9af9610 100644 --- a/pkg/conversion/converter_test.go +++ b/pkg/conversion/converter_test.go @@ -27,7 +27,7 @@ import ( "github.com/google/gofuzz" flag "github.com/spf13/pflag" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) var fuzzIters = flag.Int("fuzz-iters", 50, "How many fuzzing iterations to do.") @@ -835,12 +835,12 @@ func objDiff(a, b interface{}) string { if err != nil { panic("b") } - return util.StringDiff(string(ab), string(bb)) + return diff.StringDiff(string(ab), string(bb)) // An alternate diff attempt, in case json isn't showing you // the difference. (reflect.DeepEqual makes a distinction between // nil and empty slices, for example.) - //return util.StringDiff( + //return diff.StringDiff( // fmt.Sprintf("%#v", a), // fmt.Sprintf("%#v", b), //) diff --git a/pkg/genericapiserver/genericapiserver.go b/pkg/genericapiserver/genericapiserver.go index 23d82c58bb9..bf7c423117f 100644 --- a/pkg/genericapiserver/genericapiserver.go +++ b/pkg/genericapiserver/genericapiserver.go @@ -45,6 +45,7 @@ import ( "k8s.io/kubernetes/pkg/storage" "k8s.io/kubernetes/pkg/ui" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/crypto" utilnet "k8s.io/kubernetes/pkg/util/net" utilruntime "k8s.io/kubernetes/pkg/util/runtime" "k8s.io/kubernetes/pkg/util/sets" @@ -679,7 +680,7 @@ func (s *GenericAPIServer) Run(options *ServerRunOptions) { } if len(options.ClientCAFile) > 0 { - clientCAs, err := util.CertPoolFromFile(options.ClientCAFile) + clientCAs, err := crypto.CertPoolFromFile(options.ClientCAFile) if err != nil { glog.Fatalf("Unable to load client CA file: %v", err) } @@ -699,7 +700,7 @@ func (s *GenericAPIServer) Run(options *ServerRunOptions) { alternateDNS := []string{"kubernetes.default.svc", "kubernetes.default", "kubernetes"} // It would be nice to set a fqdn subject alt name, but only the kubelets know, the apiserver is clueless // alternateDNS = append(alternateDNS, "kubernetes.default.svc.CLUSTER.DNS.NAME") - if err := util.GenerateSelfSignedCert(s.ClusterIP.String(), options.TLSCertFile, options.TLSPrivateKeyFile, alternateIPs, alternateDNS); err != nil { + if err := crypto.GenerateSelfSignedCert(s.ClusterIP.String(), options.TLSCertFile, options.TLSPrivateKeyFile, alternateIPs, alternateDNS); err != nil { glog.Errorf("Unable to generate self signed cert: %v", err) } else { glog.Infof("Using self-signed cert (%v, %v)", options.TLSCertFile, options.TLSPrivateKeyFile) diff --git a/pkg/kubectl/cmd/config/config_test.go b/pkg/kubectl/cmd/config/config_test.go index 523543efe6a..045498dae45 100644 --- a/pkg/kubectl/cmd/config/config_test.go +++ b/pkg/kubectl/cmd/config/config_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/unversioned/clientcmd" clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func newRedFederalCowHammerConfig() clientcmdapi.Config { @@ -725,7 +725,7 @@ func (test configCommandTest) run(t *testing.T) string { testClearLocationOfOrigin(&actualConfig) if !api.Semantic.DeepEqual(test.expectedConfig, actualConfig) { - t.Errorf("diff: %v", util.ObjectDiff(test.expectedConfig, actualConfig)) + t.Errorf("diff: %v", diff.ObjectDiff(test.expectedConfig, actualConfig)) t.Errorf("expected: %#v\n actual: %#v", test.expectedConfig, actualConfig) } diff --git a/pkg/kubectl/cmd/config/navigation_step_parser_test.go b/pkg/kubectl/cmd/config/navigation_step_parser_test.go index 3ec3c40ff4c..2bca8d08920 100644 --- a/pkg/kubectl/cmd/config/navigation_step_parser_test.go +++ b/pkg/kubectl/cmd/config/navigation_step_parser_test.go @@ -22,7 +22,7 @@ import ( "testing" clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) type stepParserTest struct { @@ -90,7 +90,7 @@ func (test stepParserTest) run(t *testing.T) { } if !reflect.DeepEqual(test.expectedNavigationSteps, *actualSteps) { - t.Errorf("diff: %v", util.ObjectDiff(test.expectedNavigationSteps, *actualSteps)) + t.Errorf("diff: %v", diff.ObjectDiff(test.expectedNavigationSteps, *actualSteps)) t.Errorf("expected: %#v\n actual: %#v", test.expectedNavigationSteps, *actualSteps) } } diff --git a/pkg/kubectl/cmd/edit.go b/pkg/kubectl/cmd/edit.go index f43a662c76a..3b0b340f6cd 100644 --- a/pkg/kubectl/cmd/edit.go +++ b/pkg/kubectl/cmd/edit.go @@ -35,7 +35,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl/cmd/util/jsonmerge" "k8s.io/kubernetes/pkg/kubectl/resource" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/crlf" "k8s.io/kubernetes/pkg/util/strategicpatch" "k8s.io/kubernetes/pkg/util/yaml" @@ -181,7 +181,7 @@ outter: buf := &bytes.Buffer{} var w io.Writer = buf if windowsLineEndings { - w = util.NewCRLFWriter(w) + w = crlf.NewCRLFWriter(w) } if err := results.header.writeTo(w); err != nil { return preservedFile(err, results.file, out) diff --git a/pkg/kubectl/cmd/get_test.go b/pkg/kubectl/cmd/get_test.go index be7646bd9c6..1fff2650f38 100644 --- a/pkg/kubectl/cmd/get_test.go +++ b/pkg/kubectl/cmd/get_test.go @@ -35,7 +35,7 @@ import ( "k8s.io/kubernetes/pkg/client/restclient" "k8s.io/kubernetes/pkg/client/unversioned/fake" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch/json" ) @@ -633,7 +633,7 @@ func TestGetMultipleTypeObjectsWithDirectReference(t *testing.T) { expected := []runtime.Object{&svc.Items[0], node} actual := tf.Printer.(*testPrinter).Objects if !api.Semantic.DeepEqual(expected, actual) { - t.Errorf("unexpected object: %s", util.ObjectDiff(expected, actual)) + t.Errorf("unexpected object: %s", diff.ObjectDiff(expected, actual)) } if len(buf.String()) == 0 { t.Errorf("unexpected empty output") diff --git a/pkg/kubectl/resource_printer_test.go b/pkg/kubectl/resource_printer_test.go index 29a22a5ab41..ccc1f9b9daf 100644 --- a/pkg/kubectl/resource_printer_test.go +++ b/pkg/kubectl/resource_printer_test.go @@ -34,7 +34,7 @@ import ( kubectltesting "k8s.io/kubernetes/pkg/kubectl/testing" "k8s.io/kubernetes/pkg/runtime" yamlserializer "k8s.io/kubernetes/pkg/runtime/serializer/yaml" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/sets" @@ -182,7 +182,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data t.Fatal(err) } if !reflect.DeepEqual(testData, poutput) { - t.Errorf("Test data and unmarshaled data are not equal: %v", util.ObjectDiff(poutput, testData)) + t.Errorf("Test data and unmarshaled data are not equal: %v", diff.ObjectDiff(poutput, testData)) } obj := &api.Pod{ @@ -202,7 +202,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data t.Fatal(err) } if !reflect.DeepEqual(obj, &objOut) { - t.Errorf("Unexpected inequality:\n%v", util.ObjectDiff(obj, &objOut)) + t.Errorf("Unexpected inequality:\n%v", diff.ObjectDiff(obj, &objOut)) } } diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index 63391474c47..82954006b25 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -61,6 +61,7 @@ import ( "k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util/bandwidth" + "k8s.io/kubernetes/pkg/util/diff" "k8s.io/kubernetes/pkg/util/mount" utilruntime "k8s.io/kubernetes/pkg/util/runtime" "k8s.io/kubernetes/pkg/util/sets" @@ -2771,7 +2772,7 @@ func TestUpdateNewNodeStatus(t *testing.T) { } if !api.Semantic.DeepEqual(expectedNode, updatedNode) { - t.Errorf("unexpected objects: %s", util.ObjectDiff(expectedNode, updatedNode)) + t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode)) } } @@ -2846,7 +2847,7 @@ func TestUpdateNewNodeOutOfDiskStatusWithTransitionFrequency(t *testing.T) { } if !reflect.DeepEqual(expectedNodeOutOfDiskCondition, oodCondition) { - t.Errorf("unexpected objects: %s", util.ObjectDiff(expectedNodeOutOfDiskCondition, oodCondition)) + t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNodeOutOfDiskCondition, oodCondition)) } } @@ -3282,7 +3283,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) { LastTransitionTime: unversioned.Time{}, } if !api.Semantic.DeepEqual(expectedNode, updatedNode) { - t.Errorf("unexpected objects: %s", util.ObjectDiff(expectedNode, updatedNode)) + t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode)) } } diff --git a/pkg/kubelet/pleg/generic_test.go b/pkg/kubelet/pleg/generic_test.go index 4aff6f61678..3e3c0f24d43 100644 --- a/pkg/kubelet/pleg/generic_test.go +++ b/pkg/kubelet/pleg/generic_test.go @@ -28,6 +28,7 @@ import ( containertest "k8s.io/kubernetes/pkg/kubelet/container/testing" "k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) const ( @@ -86,7 +87,7 @@ func verifyEvents(t *testing.T, expected, actual []*PodLifecycleEvent) { sort.Sort(sortableEvents(expected)) sort.Sort(sortableEvents(actual)) if !reflect.DeepEqual(expected, actual) { - t.Errorf("Actual events differ from the expected; diff:\n %v", util.ObjectDiff(expected, actual)) + t.Errorf("Actual events differ from the expected; diff:\n %v", diff.ObjectDiff(expected, actual)) } } diff --git a/pkg/kubelet/status/manager.go b/pkg/kubelet/status/manager.go index 5503a5dcaaf..934360c37e5 100644 --- a/pkg/kubelet/status/manager.go +++ b/pkg/kubelet/status/manager.go @@ -32,7 +32,7 @@ import ( kubetypes "k8s.io/kubernetes/pkg/kubelet/types" "k8s.io/kubernetes/pkg/kubelet/util/format" "k8s.io/kubernetes/pkg/types" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "k8s.io/kubernetes/pkg/util/wait" ) @@ -453,7 +453,7 @@ func (m *manager) needsReconcile(uid types.UID, status api.PodStatus) bool { return false } glog.V(3).Infof("Pod status is inconsistent with cached status for pod %q, a reconciliation should be triggered:\n %+v", format.Pod(pod), - util.ObjectDiff(podStatus, status)) + diff.ObjectDiff(podStatus, status)) return true } diff --git a/pkg/registry/componentstatus/rest_test.go b/pkg/registry/componentstatus/rest_test.go index e98314b1087..526f1a07938 100644 --- a/pkg/registry/componentstatus/rest_test.go +++ b/pkg/registry/componentstatus/rest_test.go @@ -25,7 +25,7 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/apiserver" "k8s.io/kubernetes/pkg/probe" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "net/http" "net/url" "time" @@ -82,7 +82,7 @@ func TestList_NoError(t *testing.T) { Items: []api.ComponentStatus{*(createTestStatus("test1", api.ConditionTrue, "ok", ""))}, } if e, a := expect, got; !reflect.DeepEqual(e, a) { - t.Errorf("Got unexpected object. Diff: %s", util.ObjectDiff(e, a)) + t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) } } @@ -97,7 +97,7 @@ func TestList_FailedCheck(t *testing.T) { *(createTestStatus("test1", api.ConditionFalse, "", ""))}, } if e, a := expect, got; !reflect.DeepEqual(e, a) { - t.Errorf("Got unexpected object. Diff: %s", util.ObjectDiff(e, a)) + t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) } } @@ -112,7 +112,7 @@ func TestList_UnknownError(t *testing.T) { *(createTestStatus("test1", api.ConditionUnknown, "", "fizzbuzz error"))}, } if e, a := expect, got; !reflect.DeepEqual(e, a) { - t.Errorf("Got unexpected object. Diff: %s", util.ObjectDiff(e, a)) + t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) } } @@ -124,7 +124,7 @@ func TestGet_NoError(t *testing.T) { } expect := createTestStatus("test1", api.ConditionTrue, "ok", "") if e, a := expect, got; !reflect.DeepEqual(e, a) { - t.Errorf("Got unexpected object. Diff: %s", util.ObjectDiff(e, a)) + t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) } } diff --git a/pkg/registry/controller/etcd/etcd_test.go b/pkg/registry/controller/etcd/etcd_test.go index 8c2d0bc479f..b1c7e17ca06 100644 --- a/pkg/registry/controller/etcd/etcd_test.go +++ b/pkg/registry/controller/etcd/etcd_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/kubernetes/pkg/registry/registrytest" "k8s.io/kubernetes/pkg/runtime" etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) const ( @@ -273,7 +273,7 @@ func TestScaleGet(t *testing.T) { } got := obj.(*autoscaling.Scale) if !api.Semantic.DeepEqual(want, got) { - t.Errorf("unexpected scale: %s", util.ObjectDiff(want, got)) + t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got)) } } diff --git a/pkg/registry/deployment/etcd/etcd_test.go b/pkg/registry/deployment/etcd/etcd_test.go index be57ea8281a..ed2ad6c5848 100644 --- a/pkg/registry/deployment/etcd/etcd_test.go +++ b/pkg/registry/deployment/etcd/etcd_test.go @@ -32,7 +32,7 @@ import ( "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/storage/etcd/etcdtest" etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) const defaultReplicas = 100 @@ -216,7 +216,7 @@ func TestScaleGet(t *testing.T) { } got := obj.(*extensions.Scale) if !api.Semantic.DeepEqual(want, got) { - t.Errorf("unexpected scale: %s", util.ObjectDiff(want, got)) + t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got)) } } diff --git a/pkg/registry/event/strategy_test.go b/pkg/registry/event/strategy_test.go index bd9bc02e545..c5a685b249e 100644 --- a/pkg/registry/event/strategy_test.go +++ b/pkg/registry/event/strategy_test.go @@ -25,7 +25,7 @@ import ( apitesting "k8s.io/kubernetes/pkg/api/testing" "k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func testEvent(name string) *api.Event { @@ -65,7 +65,7 @@ func TestGetAttrs(t *testing.T) { t.Fatalf("Unexpected error %v", err) } if e, a := label, (labels.Set{}); !reflect.DeepEqual(e, a) { - t.Errorf("diff: %s", util.ObjectDiff(e, a)) + t.Errorf("diff: %s", diff.ObjectDiff(e, a)) } expect := fields.Set{ "metadata.name": "f0118", @@ -82,7 +82,7 @@ func TestGetAttrs(t *testing.T) { "type": api.EventTypeNormal, } if e, a := expect, field; !reflect.DeepEqual(e, a) { - t.Errorf("diff: %s", util.ObjectDiff(e, a)) + t.Errorf("diff: %s", diff.ObjectDiff(e, a)) } } diff --git a/pkg/registry/persistentvolume/etcd/etcd_test.go b/pkg/registry/persistentvolume/etcd/etcd_test.go index 74d26ed0ecb..b8f775d5c61 100644 --- a/pkg/registry/persistentvolume/etcd/etcd_test.go +++ b/pkg/registry/persistentvolume/etcd/etcd_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/storage/etcd/etcdtest" etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) { @@ -178,6 +178,6 @@ func TestUpdateStatus(t *testing.T) { pvOut := obj.(*api.PersistentVolume) // only compare the relevant change b/c metadata will differ if !api.Semantic.DeepEqual(pvIn.Status, pvOut.Status) { - t.Errorf("unexpected object: %s", util.ObjectDiff(pvIn.Status, pvOut.Status)) + t.Errorf("unexpected object: %s", diff.ObjectDiff(pvIn.Status, pvOut.Status)) } } diff --git a/pkg/registry/persistentvolumeclaim/etcd/etcd_test.go b/pkg/registry/persistentvolumeclaim/etcd/etcd_test.go index b51342fdb2e..a66b06dc248 100644 --- a/pkg/registry/persistentvolumeclaim/etcd/etcd_test.go +++ b/pkg/registry/persistentvolumeclaim/etcd/etcd_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/storage/etcd/etcdtest" etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) { @@ -179,6 +179,6 @@ func TestUpdateStatus(t *testing.T) { pvcOut := obj.(*api.PersistentVolumeClaim) // only compare relevant changes b/c of difference in metadata if !api.Semantic.DeepEqual(pvc.Status, pvcOut.Status) { - t.Errorf("unexpected object: %s", util.ObjectDiff(pvc.Status, pvcOut.Status)) + t.Errorf("unexpected object: %s", diff.ObjectDiff(pvc.Status, pvcOut.Status)) } } diff --git a/pkg/registry/pod/etcd/etcd_test.go b/pkg/registry/pod/etcd/etcd_test.go index df2307c25e9..1f70c7db167 100644 --- a/pkg/registry/pod/etcd/etcd_test.go +++ b/pkg/registry/pod/etcd/etcd_test.go @@ -35,7 +35,7 @@ import ( "k8s.io/kubernetes/pkg/storage" "k8s.io/kubernetes/pkg/storage/etcd/etcdtest" etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *etcdtesting.EtcdTestServer) { @@ -620,7 +620,7 @@ func TestEtcdUpdateNotScheduled(t *testing.T) { podOut := obj.(*api.Pod) // validChangedPod only changes the Labels, so were checking the update was valid if !api.Semantic.DeepEqual(podIn.Labels, podOut.Labels) { - t.Errorf("objects differ: %v", util.ObjectDiff(podOut, podIn)) + t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn)) } } @@ -688,7 +688,7 @@ func TestEtcdUpdateScheduled(t *testing.T) { podOut := obj.(*api.Pod) // Check to verify the Spec and Label updates match from change above. Those are the fields changed. if !api.Semantic.DeepEqual(podOut.Spec, podIn.Spec) || !api.Semantic.DeepEqual(podOut.Labels, podIn.Labels) { - t.Errorf("objects differ: %v", util.ObjectDiff(podOut, podIn)) + t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn)) } } @@ -770,6 +770,6 @@ func TestEtcdUpdateStatus(t *testing.T) { if !api.Semantic.DeepEqual(podOut.Spec, podIn.Spec) || !api.Semantic.DeepEqual(podOut.Labels, podIn.Labels) || !api.Semantic.DeepEqual(podOut.Status, podIn.Status) { - t.Errorf("objects differ: %v", util.ObjectDiff(podOut, podIn)) + t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn)) } } diff --git a/pkg/registry/replicaset/etcd/etcd_test.go b/pkg/registry/replicaset/etcd/etcd_test.go index 18cecd0111e..c6de66324c9 100644 --- a/pkg/registry/replicaset/etcd/etcd_test.go +++ b/pkg/registry/replicaset/etcd/etcd_test.go @@ -30,7 +30,7 @@ import ( "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/storage/etcd/etcdtest" etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) const defaultReplicas = 100 @@ -277,7 +277,7 @@ func TestScaleGet(t *testing.T) { t.Fatalf("error fetching scale for %s: %v", name, err) } if !api.Semantic.DeepEqual(got, want) { - t.Errorf("unexpected scale: %s", util.ObjectDiff(got, want)) + t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want)) } } diff --git a/pkg/registry/resourcequota/etcd/etcd_test.go b/pkg/registry/resourcequota/etcd/etcd_test.go index 3197f83e08c..323aa564647 100644 --- a/pkg/registry/resourcequota/etcd/etcd_test.go +++ b/pkg/registry/resourcequota/etcd/etcd_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/kubernetes/pkg/registry/registrytest" "k8s.io/kubernetes/pkg/storage/etcd/etcdtest" etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) { @@ -185,6 +185,6 @@ func TestUpdateStatus(t *testing.T) { rqOut := obj.(*api.ResourceQuota) // only compare the meaningful update b/c we can't compare due to metadata if !api.Semantic.DeepEqual(resourcequotaIn.Status, rqOut.Status) { - t.Errorf("unexpected object: %s", util.ObjectDiff(resourcequotaIn, rqOut)) + t.Errorf("unexpected object: %s", diff.ObjectDiff(resourcequotaIn, rqOut)) } } diff --git a/pkg/runtime/embedded_test.go b/pkg/runtime/embedded_test.go index 7875d9ffc0c..6a143fb086d 100644 --- a/pkg/runtime/embedded_test.go +++ b/pkg/runtime/embedded_test.go @@ -26,7 +26,7 @@ import ( "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime/serializer" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) type EmbeddedTest struct { @@ -169,7 +169,7 @@ func TestArrayOfRuntimeObject(t *testing.T) { // we want DecodeList to set type meta if possible, even on runtime.Unknown objects internal.Items[2].(*runtime.Unknown).TypeMeta = runtime.TypeMeta{Kind: "OtherTest", APIVersion: "unknown.group/unknown"} if e, a := internal.Items, list; !reflect.DeepEqual(e, a) { - t.Errorf("mismatched decoded: %s", util.ObjectGoPrintSideBySide(e, a)) + t.Errorf("mismatched decoded: %s", diff.ObjectGoPrintSideBySide(e, a)) } } diff --git a/pkg/runtime/scheme_test.go b/pkg/runtime/scheme_test.go index 4f48c0e39f1..f5a46d2fc12 100644 --- a/pkg/runtime/scheme_test.go +++ b/pkg/runtime/scheme_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/kubernetes/pkg/conversion" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime/serializer" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) var fuzzIters = flag.Int("fuzz-iters", 50, "How many fuzzing iterations to do.") @@ -239,7 +239,7 @@ func TestExternalToInternalMapping(t *testing.T) { if err != nil { t.Errorf("unexpected error '%v' (%v)", err, item.encoded) } else if e, a := item.obj, gotDecoded; !reflect.DeepEqual(e, a) { - t.Errorf("%d: unexpected objects:\n%s", i, util.ObjectGoPrintSideBySide(e, a)) + t.Errorf("%d: unexpected objects:\n%s", i, diff.ObjectGoPrintSideBySide(e, a)) } } } @@ -314,7 +314,7 @@ func TestExtensionMapping(t *testing.T) { if err != nil { t.Errorf("unexpected error '%v' (%v)", err, item.encoded) } else if e, a := item.expected, gotDecoded; !reflect.DeepEqual(e, a) { - t.Errorf("%d: unexpected objects:\n%s", i, util.ObjectGoPrintSideBySide(e, a)) + t.Errorf("%d: unexpected objects:\n%s", i, diff.ObjectGoPrintSideBySide(e, a)) } } } diff --git a/pkg/runtime/serializer/codec_test.go b/pkg/runtime/serializer/codec_test.go index 6c1b2ff9547..cc09a8760c4 100644 --- a/pkg/runtime/serializer/codec_test.go +++ b/pkg/runtime/serializer/codec_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/conversion" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "github.com/ghodss/yaml" "github.com/google/gofuzz" @@ -187,12 +187,12 @@ func objDiff(a, b interface{}) string { if err != nil { panic("b") } - return util.StringDiff(string(ab), string(bb)) + return diff.StringDiff(string(ab), string(bb)) // An alternate diff attempt, in case json isn't showing you // the difference. (reflect.DeepEqual makes a distinction between // nil and empty slices, for example.) - //return util.StringDiff( + //return diff.StringDiff( // fmt.Sprintf("%#v", a), // fmt.Sprintf("%#v", b), //) @@ -222,7 +222,7 @@ func runTest(t *testing.T, source interface{}) { return } if !semantic.DeepEqual(source, obj2) { - t.Errorf("1: %v: diff: %v", name, util.ObjectGoPrintSideBySide(source, obj2)) + t.Errorf("1: %v: diff: %v", name, diff.ObjectGoPrintSideBySide(source, obj2)) return } obj3 := reflect.New(reflect.TypeOf(source).Elem()).Interface() diff --git a/pkg/runtime/serializer/json/json_test.go b/pkg/runtime/serializer/json/json_test.go index eb74a26c979..f9fbf47a054 100644 --- a/pkg/runtime/serializer/json/json_test.go +++ b/pkg/runtime/serializer/json/json_test.go @@ -25,7 +25,7 @@ import ( "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime/serializer/json" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) type testDecodable struct { @@ -244,7 +244,7 @@ func TestDecode(t *testing.T) { } if !reflect.DeepEqual(test.expectedObject, obj) { - t.Errorf("%d: unexpected object:\n%s", i, util.ObjectGoPrintSideBySide(test.expectedObject, obj)) + t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintSideBySide(test.expectedObject, obj)) } } } diff --git a/pkg/runtime/serializer/versioning/versioning_test.go b/pkg/runtime/serializer/versioning/versioning_test.go index 3d7eba27e3c..ae2e5523b6a 100644 --- a/pkg/runtime/serializer/versioning/versioning_test.go +++ b/pkg/runtime/serializer/versioning/versioning_test.go @@ -24,7 +24,7 @@ import ( "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) type testDecodable struct { @@ -201,11 +201,11 @@ func TestDecode(t *testing.T) { switch { case test.expectedObject != nil: if !reflect.DeepEqual(test.expectedObject, obj) { - t.Errorf("%d: unexpected object:\n%s", i, util.ObjectGoPrintSideBySide(test.expectedObject, obj)) + t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintSideBySide(test.expectedObject, obj)) } case test.sameObject != nil: if test.sameObject != obj { - t.Errorf("%d: unexpected object:\n%s", i, util.ObjectGoPrintSideBySide(test.sameObject, obj)) + t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintSideBySide(test.sameObject, obj)) } case obj != nil: t.Errorf("%d: unexpected object: %#v", i, obj) diff --git a/pkg/util/crlf.go b/pkg/util/crlf/crlf.go similarity index 99% rename from pkg/util/crlf.go rename to pkg/util/crlf/crlf.go index 935785ce974..e098e860079 100644 --- a/pkg/util/crlf.go +++ b/pkg/util/crlf/crlf.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package crlf import ( "bytes" diff --git a/pkg/util/crypto.go b/pkg/util/crypto/crypto.go similarity index 99% rename from pkg/util/crypto.go rename to pkg/util/crypto/crypto.go index 42b890d1891..1085c0b300d 100644 --- a/pkg/util/crypto.go +++ b/pkg/util/crypto/crypto.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package crypto import ( "bytes" diff --git a/pkg/util/diff.go b/pkg/util/diff/diff.go similarity index 99% rename from pkg/util/diff.go rename to pkg/util/diff/diff.go index 4e203cb9372..e907f7f7bdb 100644 --- a/pkg/util/diff.go +++ b/pkg/util/diff/diff.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package diff import ( "bytes" diff --git a/pkg/util/deadlock-detector.go b/pkg/util/threading/deadlock-detector.go similarity index 99% rename from pkg/util/deadlock-detector.go rename to pkg/util/threading/deadlock-detector.go index b89fb23de3e..cb9afc18829 100644 --- a/pkg/util/deadlock-detector.go +++ b/pkg/util/threading/deadlock-detector.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package threading import ( "os" diff --git a/pkg/util/deadlock-detector_test.go b/pkg/util/threading/deadlock-detector_test.go similarity index 99% rename from pkg/util/deadlock-detector_test.go rename to pkg/util/threading/deadlock-detector_test.go index 51d11124583..5f6b3891394 100644 --- a/pkg/util/deadlock-detector_test.go +++ b/pkg/util/threading/deadlock-detector_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package threading import ( "sync" diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index 7fd236e1e72..a79fe291b4a 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -18,10 +18,12 @@ package util import ( "testing" + + "k8s.io/kubernetes/pkg/util/diff" ) func TestStringDiff(t *testing.T) { - diff := StringDiff("aaabb", "aaacc") + diff := diff.StringDiff("aaabb", "aaacc") expect := "aaa\n\nA: bb\n\nB: cc\n\n" if diff != expect { t.Errorf("diff returned %v", diff) diff --git a/plugin/pkg/auth/authenticator/token/oidc/oidc.go b/plugin/pkg/auth/authenticator/token/oidc/oidc.go index c9071b1d723..30a6b72192e 100644 --- a/plugin/pkg/auth/authenticator/token/oidc/oidc.go +++ b/plugin/pkg/auth/authenticator/token/oidc/oidc.go @@ -30,7 +30,7 @@ import ( "github.com/coreos/go-oidc/oidc" "github.com/golang/glog" "k8s.io/kubernetes/pkg/auth/user" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/crypto" "k8s.io/kubernetes/pkg/util/net" ) @@ -65,7 +65,7 @@ func New(issuerURL, clientID, caFile, usernameClaim, groupsClaim string) (*OIDCA } if caFile != "" { - roots, err = util.CertPoolFromFile(caFile) + roots, err = crypto.CertPoolFromFile(caFile) if err != nil { glog.Errorf("Failed to read the CA file: %v", err) } diff --git a/plugin/pkg/auth/authenticator/token/oidc/oidc_test.go b/plugin/pkg/auth/authenticator/token/oidc/oidc_test.go index a2e3559ce29..bd5fc8bcbf1 100644 --- a/plugin/pkg/auth/authenticator/token/oidc/oidc_test.go +++ b/plugin/pkg/auth/authenticator/token/oidc/oidc_test.go @@ -137,7 +137,7 @@ func (op *oidcProvider) generateExpiredToken(t *testing.T, iss, sub, aud string, } // generateSelfSignedCert generates a self-signed cert/key pairs and writes to the certPath/keyPath. -// This method is mostly identical to util.GenerateSelfSignedCert except for the 'IsCA' and 'KeyUsage' +// This method is mostly identical to crypto.GenerateSelfSignedCert except for the 'IsCA' and 'KeyUsage' // in the certificate template. (Maybe we can merge these two methods). func generateSelfSignedCert(t *testing.T, host, certPath, keyPath string) { priv, err := rsa.GenerateKey(rand.Reader, 2048) diff --git a/plugin/pkg/auth/authorizer/webhook/webhook_test.go b/plugin/pkg/auth/authorizer/webhook/webhook_test.go index 2690eb7c8bf..56da9d9813a 100644 --- a/plugin/pkg/auth/authorizer/webhook/webhook_test.go +++ b/plugin/pkg/auth/authorizer/webhook/webhook_test.go @@ -35,7 +35,7 @@ import ( "k8s.io/kubernetes/pkg/auth/authorizer" "k8s.io/kubernetes/pkg/auth/user" "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api/v1" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" ) func TestNewFromConfig(t *testing.T) { @@ -467,7 +467,7 @@ func TestWebhook(t *testing.T) { continue } if !reflect.DeepEqual(gotAttr, tt.want) { - t.Errorf("case %d: got != want:\n%s", i, util.ObjectGoPrintDiff(gotAttr, tt.want)) + t.Errorf("case %d: got != want:\n%s", i, diff.ObjectGoPrintDiff(gotAttr, tt.want)) } } } diff --git a/plugin/pkg/scheduler/scheduler_test.go b/plugin/pkg/scheduler/scheduler_test.go index 967eb87bfe0..5e0612162a8 100644 --- a/plugin/pkg/scheduler/scheduler_test.go +++ b/plugin/pkg/scheduler/scheduler_test.go @@ -30,7 +30,7 @@ import ( "k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/diff" "k8s.io/kubernetes/plugin/pkg/scheduler/algorithm" "k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates" "k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache" @@ -155,7 +155,7 @@ func TestScheduler(t *testing.T) { t.Errorf("%v: error: wanted %v, got %v", i, e, a) } if e, a := item.expectBind, gotBinding; !reflect.DeepEqual(e, a) { - t.Errorf("%v: error: %s", i, util.ObjectDiff(e, a)) + t.Errorf("%v: error: %s", i, diff.ObjectDiff(e, a)) } <-called events.Stop() @@ -268,7 +268,7 @@ func TestSchedulerForgetAssumedPodAfterDelete(t *testing.T) { Target: api.ObjectReference{Kind: "Node", Name: "machine1"}, } if ex, ac := expectBind, gotBinding; !reflect.DeepEqual(ex, ac) { - t.Errorf("Expected exact match on binding: %s", util.ObjectDiff(ex, ac)) + t.Errorf("Expected exact match on binding: %s", diff.ObjectDiff(ex, ac)) } <-called @@ -318,7 +318,7 @@ func TestSchedulerForgetAssumedPodAfterDelete(t *testing.T) { Target: api.ObjectReference{Kind: "Node", Name: "machine1"}, } if ex, ac := expectBind, gotBinding; !reflect.DeepEqual(ex, ac) { - t.Errorf("Expected exact match on binding: %s", util.ObjectDiff(ex, ac)) + t.Errorf("Expected exact match on binding: %s", diff.ObjectDiff(ex, ac)) } <-called events.Stop()