From 357e91f057defa14007ba7b070f74adb364a2d10 Mon Sep 17 00:00:00 2001 From: David Eads Date: Tue, 28 May 2019 08:31:44 -0400 Subject: [PATCH 1/4] add find leaves script --- hack/find-leaves.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 hack/find-leaves.sh diff --git a/hack/find-leaves.sh b/hack/find-leaves.sh new file mode 100755 index 000000000000..d866b0f47d7f --- /dev/null +++ b/hack/find-leaves.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# this is all the dependencies we have +#go list -f '{{.Deps}}' github.com/openshift/origin/pkg/cmd/openshift-apiserver | xargs -n 1 echo | grep 'github.com/openshift/origin' | grep -v 'github.com/openshift/origin/vendor' | sort +all_packages=$(go list -f '{{.Deps}}' $1 | xargs -n 1 echo | grep 'github.com/openshift/origin' | grep -v 'github.com/openshift/origin/vendor' | sort) + +for package in ${all_packages} +do + curr_packages=$(go list -f '{{.Deps}}' ${package} | xargs -n 1 echo | grep 'github.com/openshift/origin' | grep -v 'github.com/openshift/origin/vendor' | sort) + if [ -z "${curr_packages}" ] + then + echo "${package} should move" + else + echo "${package} has deps" + fi +done From abf898581bdb7777b2cb39ebfb601bdf26ac5cc6 Mon Sep 17 00:00:00 2001 From: David Eads Date: Tue, 28 May 2019 10:07:34 -0400 Subject: [PATCH 2/4] bump(*): add openshift-apiserver --- vendor/github.com/openshift/openshift-apiserver | 1 + 1 file changed, 1 insertion(+) create mode 120000 vendor/github.com/openshift/openshift-apiserver diff --git a/vendor/github.com/openshift/openshift-apiserver b/vendor/github.com/openshift/openshift-apiserver new file mode 120000 index 000000000000..c38b3403f2d5 --- /dev/null +++ b/vendor/github.com/openshift/openshift-apiserver @@ -0,0 +1 @@ +../../../staging/src/github.com/openshift/openshift-apiserver/ \ No newline at end of file From 6539a7e5b0986aed9a873d9ebe0aeff02046fe72 Mon Sep 17 00:00:00 2001 From: David Eads Date: Tue, 28 May 2019 10:07:50 -0400 Subject: [PATCH 3/4] move easy leaf nodes --- pkg/apps/apiserver/registry/deploylog/rest.go | 2 +- .../apiserver/registry/clusterrole/proxy.go | 2 +- .../apiserver/registry/clusterrolebinding/proxy.go | 2 +- pkg/authorization/apiserver/registry/role/proxy.go | 2 +- .../apiserver/registry/rolebinding/proxy.go | 2 +- .../apiserver/admission/secretinjector/admission.go | 9 ++++----- .../apiserver/admission/secretinjector}/urlpattern.go | 2 +- .../admission/secretinjector}/urlpattern_test.go | 2 +- pkg/build/apiserver/registry/buildlog/rest.go | 2 +- pkg/image/apis/image/validation/whitelist/whitelister.go | 5 ++--- .../apis/image/validation/whitelist}/wildcard.go | 2 +- .../apis/image/validation/whitelist}/wildcard_test.go | 2 +- .../templateprocessing}/object.go | 2 +- .../templateprocessing}/object_test.go | 2 +- pkg/template/templateprocessing/template.go | 3 +-- .../openshift-apiserver/pkg}/apiserver/rest/streamer.go | 0 .../pkg}/client/impersonatingclient/impersonate.go | 0 .../pkg}/client/impersonatingclient/impersonate_rbac.go | 0 test/integration/scopes_test.go | 2 +- 19 files changed, 20 insertions(+), 23 deletions(-) rename pkg/{util/urlpattern => build/apiserver/admission/secretinjector}/urlpattern.go (99%) rename pkg/{util/urlpattern => build/apiserver/admission/secretinjector}/urlpattern_test.go (99%) rename pkg/{util/strings => image/apis/image/validation/whitelist}/wildcard.go (97%) rename pkg/{util/strings => image/apis/image/validation/whitelist}/wildcard_test.go (98%) rename pkg/{util/stringreplace => template/templateprocessing}/object.go (99%) rename pkg/{util/stringreplace => template/templateprocessing}/object_test.go (98%) rename {pkg => staging/src/github.com/openshift/openshift-apiserver/pkg}/apiserver/rest/streamer.go (100%) rename {pkg => staging/src/github.com/openshift/openshift-apiserver/pkg}/client/impersonatingclient/impersonate.go (100%) rename {pkg => staging/src/github.com/openshift/openshift-apiserver/pkg}/client/impersonatingclient/impersonate_rbac.go (100%) diff --git a/pkg/apps/apiserver/registry/deploylog/rest.go b/pkg/apps/apiserver/registry/deploylog/rest.go index 29b79c45939f..7740415504a8 100644 --- a/pkg/apps/apiserver/registry/deploylog/rest.go +++ b/pkg/apps/apiserver/registry/deploylog/rest.go @@ -29,7 +29,7 @@ import ( "github.com/openshift/api/apps" appsv1 "github.com/openshift/api/apps/v1" appsclient "github.com/openshift/client-go/apps/clientset/versioned/typed/apps/v1" - apiserverrest "github.com/openshift/origin/pkg/apiserver/rest" + apiserverrest "github.com/openshift/openshift-apiserver/pkg/apiserver/rest" appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/apis/apps/validation" appsutil "github.com/openshift/origin/pkg/apps/util" diff --git a/pkg/authorization/apiserver/registry/clusterrole/proxy.go b/pkg/authorization/apiserver/registry/clusterrole/proxy.go index 00a72ef03827..70b71686d78f 100644 --- a/pkg/authorization/apiserver/registry/clusterrole/proxy.go +++ b/pkg/authorization/apiserver/registry/clusterrole/proxy.go @@ -12,9 +12,9 @@ import ( "k8s.io/kubernetes/pkg/printers" printerstorage "k8s.io/kubernetes/pkg/printers/storage" + authclient "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" "github.com/openshift/origin/pkg/authorization/apiserver/registry/util" - authclient "github.com/openshift/origin/pkg/client/impersonatingclient" printersinternal "github.com/openshift/origin/pkg/printers/internalversion" utilregistry "github.com/openshift/origin/pkg/util/registry" ) diff --git a/pkg/authorization/apiserver/registry/clusterrolebinding/proxy.go b/pkg/authorization/apiserver/registry/clusterrolebinding/proxy.go index bdc41bb6b819..1cae11515867 100644 --- a/pkg/authorization/apiserver/registry/clusterrolebinding/proxy.go +++ b/pkg/authorization/apiserver/registry/clusterrolebinding/proxy.go @@ -12,9 +12,9 @@ import ( "k8s.io/kubernetes/pkg/printers" printerstorage "k8s.io/kubernetes/pkg/printers/storage" + authclient "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" "github.com/openshift/origin/pkg/authorization/apiserver/registry/util" - authclient "github.com/openshift/origin/pkg/client/impersonatingclient" printersinternal "github.com/openshift/origin/pkg/printers/internalversion" utilregistry "github.com/openshift/origin/pkg/util/registry" ) diff --git a/pkg/authorization/apiserver/registry/role/proxy.go b/pkg/authorization/apiserver/registry/role/proxy.go index 46cfe306c7c4..6daca813bc14 100644 --- a/pkg/authorization/apiserver/registry/role/proxy.go +++ b/pkg/authorization/apiserver/registry/role/proxy.go @@ -14,9 +14,9 @@ import ( "k8s.io/kubernetes/pkg/printers" printerstorage "k8s.io/kubernetes/pkg/printers/storage" + authclient "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" "github.com/openshift/origin/pkg/authorization/apiserver/registry/util" - authclient "github.com/openshift/origin/pkg/client/impersonatingclient" printersinternal "github.com/openshift/origin/pkg/printers/internalversion" utilregistry "github.com/openshift/origin/pkg/util/registry" ) diff --git a/pkg/authorization/apiserver/registry/rolebinding/proxy.go b/pkg/authorization/apiserver/registry/rolebinding/proxy.go index b2e17340aba7..dbed9611c902 100644 --- a/pkg/authorization/apiserver/registry/rolebinding/proxy.go +++ b/pkg/authorization/apiserver/registry/rolebinding/proxy.go @@ -14,9 +14,9 @@ import ( "k8s.io/kubernetes/pkg/printers" printerstorage "k8s.io/kubernetes/pkg/printers/storage" + authclient "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" "github.com/openshift/origin/pkg/authorization/apiserver/registry/util" - authclient "github.com/openshift/origin/pkg/client/impersonatingclient" printersinternal "github.com/openshift/origin/pkg/printers/internalversion" utilregistry "github.com/openshift/origin/pkg/util/registry" ) diff --git a/pkg/build/apiserver/admission/secretinjector/admission.go b/pkg/build/apiserver/admission/secretinjector/admission.go index 5a3a185380a3..ceefba1a5b17 100644 --- a/pkg/build/apiserver/admission/secretinjector/admission.go +++ b/pkg/build/apiserver/admission/secretinjector/admission.go @@ -14,10 +14,9 @@ import ( restclient "k8s.io/client-go/rest" api "k8s.io/kubernetes/pkg/apis/core" + authclient "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" buildapi "github.com/openshift/origin/pkg/build/apis/build" - authclient "github.com/openshift/origin/pkg/client/impersonatingclient" oadmission "github.com/openshift/origin/pkg/cmd/server/admission" - "github.com/openshift/origin/pkg/util/urlpattern" ) func Register(plugins *admission.Plugins) { @@ -76,7 +75,7 @@ func (si *secretInjector) admit(attr admission.Attributes, mutationAllowed bool) return nil } - patterns := []*urlpattern.URLPattern{} + patterns := []*URLPattern{} for _, secret := range secrets.Items { if secret.Type == corev1.SecretTypeBasicAuth && url.Scheme == "ssh" || secret.Type == corev1.SecretTypeSSHAuth && url.Scheme != "ssh" { @@ -90,7 +89,7 @@ func (si *secretInjector) admit(attr admission.Attributes, mutationAllowed bool) continue } - pattern, err := urlpattern.NewURLPattern(v) + pattern, err := NewURLPattern(v) if err != nil { klog.V(2).Infof(`secretinjector: buildconfig "%s/%s": unparseable annotation %q: %v`, namespace, bc.GetName(), k, err) continue @@ -102,7 +101,7 @@ func (si *secretInjector) admit(attr admission.Attributes, mutationAllowed bool) } } - if match := urlpattern.Match(patterns, url); match != nil { + if match := Match(patterns, url); match != nil { secretName := match.Cookie.(string) klog.V(4).Infof(`secretinjector: matched secret "%s/%s" to buildconfig "%s"`, namespace, secretName, bc.GetName()) if mutationAllowed { diff --git a/pkg/util/urlpattern/urlpattern.go b/pkg/build/apiserver/admission/secretinjector/urlpattern.go similarity index 99% rename from pkg/util/urlpattern/urlpattern.go rename to pkg/build/apiserver/admission/secretinjector/urlpattern.go index c052cb155876..f8a4354e2e94 100644 --- a/pkg/util/urlpattern/urlpattern.go +++ b/pkg/build/apiserver/admission/secretinjector/urlpattern.go @@ -1,4 +1,4 @@ -package urlpattern +package secretinjector import ( "errors" diff --git a/pkg/util/urlpattern/urlpattern_test.go b/pkg/build/apiserver/admission/secretinjector/urlpattern_test.go similarity index 99% rename from pkg/util/urlpattern/urlpattern_test.go rename to pkg/build/apiserver/admission/secretinjector/urlpattern_test.go index 5a5f54ec2871..3d20daf964b3 100644 --- a/pkg/util/urlpattern/urlpattern_test.go +++ b/pkg/build/apiserver/admission/secretinjector/urlpattern_test.go @@ -1,4 +1,4 @@ -package urlpattern +package secretinjector import ( "net/url" diff --git a/pkg/build/apiserver/registry/buildlog/rest.go b/pkg/build/apiserver/registry/buildlog/rest.go index 8e665963f873..f57a2d49eb7d 100644 --- a/pkg/build/apiserver/registry/buildlog/rest.go +++ b/pkg/build/apiserver/registry/buildlog/rest.go @@ -24,7 +24,7 @@ import ( "github.com/openshift/api/build" buildv1 "github.com/openshift/api/build/v1" buildtypedclient "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1" - apiserverrest "github.com/openshift/origin/pkg/apiserver/rest" + apiserverrest "github.com/openshift/openshift-apiserver/pkg/apiserver/rest" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildinternalhelpers "github.com/openshift/origin/pkg/build/apis/build/internal_helpers" "github.com/openshift/origin/pkg/build/apis/build/validation" diff --git a/pkg/image/apis/image/validation/whitelist/whitelister.go b/pkg/image/apis/image/validation/whitelist/whitelister.go index 7e1d9cd3ed46..b9a850cd7dcf 100644 --- a/pkg/image/apis/image/validation/whitelist/whitelister.go +++ b/pkg/image/apis/image/validation/whitelist/whitelister.go @@ -13,7 +13,6 @@ import ( openshiftcontrolplanev1 "github.com/openshift/api/openshiftcontrolplane/v1" imageapi "github.com/openshift/origin/pkg/image/apis/image" - stringsutil "github.com/openshift/origin/pkg/util/strings" ) // WhitelistTransport says whether the associated registry host shall be treated as secure or insecure. @@ -157,7 +156,7 @@ func (rw *registryWhitelister) AdmitDockerImageReference(ref *imageapi.DockerIma matchHost := func(h string) bool { for _, hp := range rw.whitelist { - if stringsutil.IsWildcardMatch(h, hp.host) { + if IsWildcardMatch(h, hp.host) { if len(port) == 0 { switch hp.port { case "80", "443", "*": @@ -166,7 +165,7 @@ func (rw *registryWhitelister) AdmitDockerImageReference(ref *imageapi.DockerIma continue } } - if stringsutil.IsWildcardMatch(port, hp.port) { + if IsWildcardMatch(port, hp.port) { return true } } diff --git a/pkg/util/strings/wildcard.go b/pkg/image/apis/image/validation/whitelist/wildcard.go similarity index 97% rename from pkg/util/strings/wildcard.go rename to pkg/image/apis/image/validation/whitelist/wildcard.go index aae0180ada54..7daa4fc3e5ff 100644 --- a/pkg/util/strings/wildcard.go +++ b/pkg/image/apis/image/validation/whitelist/wildcard.go @@ -1,4 +1,4 @@ -package strings +package whitelist // IsWildcardMatch matches the given input string against the provided pattern. The // pattern might contain '?' and '*' wildcards. diff --git a/pkg/util/strings/wildcard_test.go b/pkg/image/apis/image/validation/whitelist/wildcard_test.go similarity index 98% rename from pkg/util/strings/wildcard_test.go rename to pkg/image/apis/image/validation/whitelist/wildcard_test.go index 0139850e03c4..5f014ccd25e4 100644 --- a/pkg/util/strings/wildcard_test.go +++ b/pkg/image/apis/image/validation/whitelist/wildcard_test.go @@ -1,4 +1,4 @@ -package strings +package whitelist import "testing" diff --git a/pkg/util/stringreplace/object.go b/pkg/template/templateprocessing/object.go similarity index 99% rename from pkg/util/stringreplace/object.go rename to pkg/template/templateprocessing/object.go index 97d6d9286878..c7123110db25 100644 --- a/pkg/util/stringreplace/object.go +++ b/pkg/template/templateprocessing/object.go @@ -1,4 +1,4 @@ -package stringreplace +package templateprocessing import ( "encoding/json" diff --git a/pkg/util/stringreplace/object_test.go b/pkg/template/templateprocessing/object_test.go similarity index 98% rename from pkg/util/stringreplace/object_test.go rename to pkg/template/templateprocessing/object_test.go index 593448e51e86..b409f5ed5c14 100644 --- a/pkg/util/stringreplace/object_test.go +++ b/pkg/template/templateprocessing/object_test.go @@ -1,4 +1,4 @@ -package stringreplace +package templateprocessing import ( "fmt" diff --git a/pkg/template/templateprocessing/template.go b/pkg/template/templateprocessing/template.go index bec6e4e2cfc3..bb6dbfc1d778 100644 --- a/pkg/template/templateprocessing/template.go +++ b/pkg/template/templateprocessing/template.go @@ -15,7 +15,6 @@ import ( templateapi "github.com/openshift/origin/pkg/template/apis/template" . "github.com/openshift/origin/pkg/template/generator" "github.com/openshift/origin/pkg/util" - "github.com/openshift/origin/pkg/util/stringreplace" ) // match ${KEY}, KEY will be grouped @@ -197,7 +196,7 @@ func (p *Processor) EvaluateParameterSubstitution(params map[string]templateapi. // - ${PARAMETER_NAME} // func (p *Processor) SubstituteParameters(params map[string]templateapi.Parameter, item runtime.Object) (runtime.Object, error) { - stringreplace.VisitObjectStrings(item, func(in string) (string, bool) { + VisitObjectStrings(item, func(in string) (string, bool) { return p.EvaluateParameterSubstitution(params, in) }) return item, nil diff --git a/pkg/apiserver/rest/streamer.go b/staging/src/github.com/openshift/openshift-apiserver/pkg/apiserver/rest/streamer.go similarity index 100% rename from pkg/apiserver/rest/streamer.go rename to staging/src/github.com/openshift/openshift-apiserver/pkg/apiserver/rest/streamer.go diff --git a/pkg/client/impersonatingclient/impersonate.go b/staging/src/github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient/impersonate.go similarity index 100% rename from pkg/client/impersonatingclient/impersonate.go rename to staging/src/github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient/impersonate.go diff --git a/pkg/client/impersonatingclient/impersonate_rbac.go b/staging/src/github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient/impersonate_rbac.go similarity index 100% rename from pkg/client/impersonatingclient/impersonate_rbac.go rename to staging/src/github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient/impersonate_rbac.go diff --git a/test/integration/scopes_test.go b/test/integration/scopes_test.go index dab8a957afea..9ddc4cb0590d 100644 --- a/test/integration/scopes_test.go +++ b/test/integration/scopes_test.go @@ -23,12 +23,12 @@ import ( authorizationv1typedclient "github.com/openshift/client-go/authorization/clientset/versioned/typed/authorization/v1" buildv1client "github.com/openshift/client-go/build/clientset/versioned" projectclient "github.com/openshift/client-go/project/clientset/versioned" + "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" "github.com/openshift/origin/pkg/authorization/apis/authorization/rbacconversion" authorizationapiv1 "github.com/openshift/origin/pkg/authorization/apis/authorization/v1" "github.com/openshift/origin/pkg/authorization/authorizer/scope" buildapi "github.com/openshift/origin/pkg/build/apis/build" - "github.com/openshift/origin/pkg/client/impersonatingclient" oauthapi "github.com/openshift/origin/pkg/oauth/apis/oauth" oauthclient "github.com/openshift/origin/pkg/oauth/generated/internalclientset/typed/oauth/internalversion" userapi "github.com/openshift/origin/pkg/user/apis/user" From 81004ced0085e2d8053361eb4b3f73d5669c14f3 Mon Sep 17 00:00:00 2001 From: David Eads Date: Tue, 28 May 2019 09:18:25 -0400 Subject: [PATCH 4/4] sweep pkg/util for easy moves --- hack/import-restrictions.json | 6 +- .../oauth}/rankedset/rankedset.go | 0 .../oauth}/rankedset/rankedset_test.go | 0 .../authentication/oauth/timeoutvalidator.go | 2 +- .../apiserver/registry/clusterrole/proxy.go | 2 +- .../registry/clusterrolebinding/proxy.go | 2 +- .../apiserver/registry}/registry/wrapper.go | 0 .../apiserver/registry/role/proxy.go | 2 +- .../apiserver/registry/rolebinding/proxy.go | 2 +- pkg/network/node/healthcheck.go | 5 +- pkg/network/node/metrics.go | 3 +- pkg/network/node/node.go | 2 +- pkg/{util => network/node}/ovs/OWNERS | 0 pkg/{util => network/node}/ovs/doc.go | 0 pkg/{util => network/node}/ovs/fake_ovs.go | 0 .../node}/ovs/fake_ovs_test.go | 0 pkg/{util => network/node}/ovs/ovs.go | 0 pkg/{util => network/node}/ovs/ovs_test.go | 0 .../node}/ovs/ovsclient/ovsclient.go | 0 pkg/{util => network/node}/ovs/parse.go | 0 pkg/{util => network/node}/ovs/parse_test.go | 0 pkg/network/node/ovscontroller.go | 2 +- pkg/network/node/ovscontroller_test.go | 2 +- pkg/network/node/vxlan_monitor.go | 2 +- pkg/network/node/vxlan_monitor_test.go | 2 +- .../oauth/external/github/github.go | 2 +- .../oauth/external/github}/links/links.go | 0 .../external/github}/links/links_test.go | 0 .../cli/rsync}/fsnotification/doc.go | 0 .../rsync}/fsnotification/fsnotification.go | 0 pkg/oc/cli/rsync/rsync.go | 2 +- pkg/oc/cli/status/status.go | 2 +- pkg/oc/lib/describe/chaindescriber.go | 2 +- pkg/{util => oc/lib}/dot/dot.go | 0 pkg/{util => oc/lib}/dot/dot_test.go | 0 pkg/oc/lib/newapp/app/imageref.go | 4 +- pkg/oc/lib/newapp/app/pipeline.go | 2 +- pkg/oc/lib/newapp/appjson/appjson.go | 2 +- pkg/oc/lib/newapp/cmd/describe.go | 2 +- pkg/oc/lib/newapp/cmd/resolve.go | 2 +- pkg/{util => oc/lib/newapp}/docker/doc.go | 0 .../lib/newapp}/docker/dockerfile/doc.go | 0 .../newapp}/docker/dockerfile/dockerfile.go | 0 .../docker/dockerfile/dockerfile_test.go | 0 .../newapp}/docker/dockerfile/instructions.go | 0 .../docker/dockerfile/instructions_test.go | 0 .../newapp}/docker/dockerfile/shell_parser.go | 0 .../lib/newapp}/portutils/common.go | 0 .../lib/newapp}/portutils/common_test.go | 0 pkg/util/glog/glog.go | 103 ------- pkg/util/httpproxy/doc.go | 2 - pkg/util/httpproxy/upgradeawareproxy.go | 270 ------------------ pkg/util/jsonmerge/jsonmerge.go | 161 ----------- pkg/util/jsonmerge/jsonmerge_test.go | 59 ---- pkg/util/ratelimiter/ratelimiter.go | 61 ---- pkg/util/ratelimiter/ratelimiter_test.go | 80 ------ pkg/util/rest/mapper.go | 1 - 57 files changed, 25 insertions(+), 766 deletions(-) rename pkg/{util => apiserver/authentication/oauth}/rankedset/rankedset.go (100%) rename pkg/{util => apiserver/authentication/oauth}/rankedset/rankedset_test.go (100%) rename pkg/{util => authorization/apiserver/registry}/registry/wrapper.go (100%) rename pkg/{util => network/node}/ovs/OWNERS (100%) rename pkg/{util => network/node}/ovs/doc.go (100%) rename pkg/{util => network/node}/ovs/fake_ovs.go (100%) rename pkg/{util => network/node}/ovs/fake_ovs_test.go (100%) rename pkg/{util => network/node}/ovs/ovs.go (100%) rename pkg/{util => network/node}/ovs/ovs_test.go (100%) rename pkg/{util => network/node}/ovs/ovsclient/ovsclient.go (100%) rename pkg/{util => network/node}/ovs/parse.go (100%) rename pkg/{util => network/node}/ovs/parse_test.go (100%) rename pkg/{util/http => oauthserver/oauth/external/github}/links/links.go (100%) rename pkg/{util/http => oauthserver/oauth/external/github}/links/links_test.go (100%) rename pkg/{util => oc/cli/rsync}/fsnotification/doc.go (100%) rename pkg/{util => oc/cli/rsync}/fsnotification/fsnotification.go (100%) rename pkg/{util => oc/lib}/dot/dot.go (100%) rename pkg/{util => oc/lib}/dot/dot_test.go (100%) rename pkg/{util => oc/lib/newapp}/docker/doc.go (100%) rename pkg/{util => oc/lib/newapp}/docker/dockerfile/doc.go (100%) rename pkg/{util => oc/lib/newapp}/docker/dockerfile/dockerfile.go (100%) rename pkg/{util => oc/lib/newapp}/docker/dockerfile/dockerfile_test.go (100%) rename pkg/{util => oc/lib/newapp}/docker/dockerfile/instructions.go (100%) rename pkg/{util => oc/lib/newapp}/docker/dockerfile/instructions_test.go (100%) rename pkg/{util => oc/lib/newapp}/docker/dockerfile/shell_parser.go (100%) rename pkg/{util => oc/lib/newapp}/portutils/common.go (100%) rename pkg/{util => oc/lib/newapp}/portutils/common_test.go (100%) delete mode 100644 pkg/util/glog/glog.go delete mode 100644 pkg/util/httpproxy/doc.go delete mode 100644 pkg/util/httpproxy/upgradeawareproxy.go delete mode 100644 pkg/util/jsonmerge/jsonmerge.go delete mode 100644 pkg/util/jsonmerge/jsonmerge_test.go delete mode 100644 pkg/util/ratelimiter/ratelimiter.go delete mode 100644 pkg/util/ratelimiter/ratelimiter_test.go delete mode 100644 pkg/util/rest/mapper.go diff --git a/hack/import-restrictions.json b/hack/import-restrictions.json index 70958310e75d..7e0592b41da1 100644 --- a/hack/import-restrictions.json +++ b/hack/import-restrictions.json @@ -431,7 +431,6 @@ "github.com/openshift/origin/pkg/cmd/server/apis/config/install", "github.com/openshift/origin/pkg/cmd/server/apis/config/latest", "github.com/openshift/origin/pkg/serviceaccounts/oauthclient", - "github.com/openshift/origin/pkg/util/http/links", "github.com/openshift/origin/pkg/util/httprequest" ] }, @@ -566,13 +565,9 @@ "github.com/openshift/origin/pkg/unidling/util", "github.com/openshift/origin/pkg/user/apis/user/install", "github.com/openshift/origin/pkg/util", - "github.com/openshift/origin/pkg/util/docker/dockerfile", - "github.com/openshift/origin/pkg/util/dot", "github.com/openshift/origin/pkg/util/errors", - "github.com/openshift/origin/pkg/util/fsnotification", "github.com/openshift/origin/pkg/util/netutils", "github.com/openshift/origin/pkg/util/parallel", - "github.com/openshift/origin/pkg/util/portutils", "github.com/openshift/origin/pkg/version", "vendor/github.com/openshift/library-go/pkg/image/reference", @@ -586,6 +581,7 @@ "vendor/k8s.io/kubernetes/pkg/controller", "vendor/k8s.io/kubernetes/pkg/controller/deployment/util", "vendor/k8s.io/kubernetes/pkg/credentialprovider", + "vendor/github.com/pkg/errors", "vendor/github.com/openshift/library-go/pkg/git" ] diff --git a/pkg/util/rankedset/rankedset.go b/pkg/apiserver/authentication/oauth/rankedset/rankedset.go similarity index 100% rename from pkg/util/rankedset/rankedset.go rename to pkg/apiserver/authentication/oauth/rankedset/rankedset.go diff --git a/pkg/util/rankedset/rankedset_test.go b/pkg/apiserver/authentication/oauth/rankedset/rankedset_test.go similarity index 100% rename from pkg/util/rankedset/rankedset_test.go rename to pkg/apiserver/authentication/oauth/rankedset/rankedset_test.go diff --git a/pkg/apiserver/authentication/oauth/timeoutvalidator.go b/pkg/apiserver/authentication/oauth/timeoutvalidator.go index fe3d281d36b8..7673397f8812 100644 --- a/pkg/apiserver/authentication/oauth/timeoutvalidator.go +++ b/pkg/apiserver/authentication/oauth/timeoutvalidator.go @@ -15,7 +15,7 @@ import ( userv1 "github.com/openshift/api/user/v1" oauthclient "github.com/openshift/client-go/oauth/clientset/versioned/typed/oauth/v1" oauthclientlister "github.com/openshift/client-go/oauth/listers/oauth/v1" - "github.com/openshift/origin/pkg/util/rankedset" + "github.com/openshift/origin/pkg/apiserver/authentication/oauth/rankedset" ) var errTimedout = errors.New("token timed out") diff --git a/pkg/authorization/apiserver/registry/clusterrole/proxy.go b/pkg/authorization/apiserver/registry/clusterrole/proxy.go index 70b71686d78f..5b2756718061 100644 --- a/pkg/authorization/apiserver/registry/clusterrole/proxy.go +++ b/pkg/authorization/apiserver/registry/clusterrole/proxy.go @@ -14,9 +14,9 @@ import ( authclient "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" + utilregistry "github.com/openshift/origin/pkg/authorization/apiserver/registry/registry" "github.com/openshift/origin/pkg/authorization/apiserver/registry/util" printersinternal "github.com/openshift/origin/pkg/printers/internalversion" - utilregistry "github.com/openshift/origin/pkg/util/registry" ) type REST struct { diff --git a/pkg/authorization/apiserver/registry/clusterrolebinding/proxy.go b/pkg/authorization/apiserver/registry/clusterrolebinding/proxy.go index 1cae11515867..2697b4356862 100644 --- a/pkg/authorization/apiserver/registry/clusterrolebinding/proxy.go +++ b/pkg/authorization/apiserver/registry/clusterrolebinding/proxy.go @@ -14,9 +14,9 @@ import ( authclient "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" + utilregistry "github.com/openshift/origin/pkg/authorization/apiserver/registry/registry" "github.com/openshift/origin/pkg/authorization/apiserver/registry/util" printersinternal "github.com/openshift/origin/pkg/printers/internalversion" - utilregistry "github.com/openshift/origin/pkg/util/registry" ) type REST struct { diff --git a/pkg/util/registry/wrapper.go b/pkg/authorization/apiserver/registry/registry/wrapper.go similarity index 100% rename from pkg/util/registry/wrapper.go rename to pkg/authorization/apiserver/registry/registry/wrapper.go diff --git a/pkg/authorization/apiserver/registry/role/proxy.go b/pkg/authorization/apiserver/registry/role/proxy.go index 6daca813bc14..61f6bdc0667b 100644 --- a/pkg/authorization/apiserver/registry/role/proxy.go +++ b/pkg/authorization/apiserver/registry/role/proxy.go @@ -16,9 +16,9 @@ import ( authclient "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" + utilregistry "github.com/openshift/origin/pkg/authorization/apiserver/registry/registry" "github.com/openshift/origin/pkg/authorization/apiserver/registry/util" printersinternal "github.com/openshift/origin/pkg/printers/internalversion" - utilregistry "github.com/openshift/origin/pkg/util/registry" ) type REST struct { diff --git a/pkg/authorization/apiserver/registry/rolebinding/proxy.go b/pkg/authorization/apiserver/registry/rolebinding/proxy.go index dbed9611c902..3176f304cb62 100644 --- a/pkg/authorization/apiserver/registry/rolebinding/proxy.go +++ b/pkg/authorization/apiserver/registry/rolebinding/proxy.go @@ -16,9 +16,9 @@ import ( authclient "github.com/openshift/openshift-apiserver/pkg/client/impersonatingclient" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" + utilregistry "github.com/openshift/origin/pkg/authorization/apiserver/registry/registry" "github.com/openshift/origin/pkg/authorization/apiserver/registry/util" printersinternal "github.com/openshift/origin/pkg/printers/internalversion" - utilregistry "github.com/openshift/origin/pkg/util/registry" ) type REST struct { diff --git a/pkg/network/node/healthcheck.go b/pkg/network/node/healthcheck.go index f669b016b453..f4a4434953df 100644 --- a/pkg/network/node/healthcheck.go +++ b/pkg/network/node/healthcheck.go @@ -4,12 +4,11 @@ import ( "fmt" "time" - "k8s.io/klog" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilwait "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/klog" - "github.com/openshift/origin/pkg/util/ovs/ovsclient" + "github.com/openshift/origin/pkg/network/node/ovs/ovsclient" ) const ( diff --git a/pkg/network/node/metrics.go b/pkg/network/node/metrics.go index 2f33558cc31f..7e26b3cacc06 100644 --- a/pkg/network/node/metrics.go +++ b/pkg/network/node/metrics.go @@ -12,10 +12,11 @@ import ( "sync" "time" - "github.com/openshift/origin/pkg/util/ovs" "github.com/prometheus/client_golang/prometheus" utilruntime "k8s.io/apimachinery/pkg/util/runtime" + + "github.com/openshift/origin/pkg/network/node/ovs" ) const ( diff --git a/pkg/network/node/node.go b/pkg/network/node/node.go index 40dadd061018..b4d059710123 100644 --- a/pkg/network/node/node.go +++ b/pkg/network/node/node.go @@ -40,8 +40,8 @@ import ( "github.com/openshift/origin/pkg/network" "github.com/openshift/origin/pkg/network/common" "github.com/openshift/origin/pkg/network/node/cniserver" + "github.com/openshift/origin/pkg/network/node/ovs" "github.com/openshift/origin/pkg/util/netutils" - "github.com/openshift/origin/pkg/util/ovs" ) const hostLocalDataDir = "/var/lib/cni/networks" diff --git a/pkg/util/ovs/OWNERS b/pkg/network/node/ovs/OWNERS similarity index 100% rename from pkg/util/ovs/OWNERS rename to pkg/network/node/ovs/OWNERS diff --git a/pkg/util/ovs/doc.go b/pkg/network/node/ovs/doc.go similarity index 100% rename from pkg/util/ovs/doc.go rename to pkg/network/node/ovs/doc.go diff --git a/pkg/util/ovs/fake_ovs.go b/pkg/network/node/ovs/fake_ovs.go similarity index 100% rename from pkg/util/ovs/fake_ovs.go rename to pkg/network/node/ovs/fake_ovs.go diff --git a/pkg/util/ovs/fake_ovs_test.go b/pkg/network/node/ovs/fake_ovs_test.go similarity index 100% rename from pkg/util/ovs/fake_ovs_test.go rename to pkg/network/node/ovs/fake_ovs_test.go diff --git a/pkg/util/ovs/ovs.go b/pkg/network/node/ovs/ovs.go similarity index 100% rename from pkg/util/ovs/ovs.go rename to pkg/network/node/ovs/ovs.go diff --git a/pkg/util/ovs/ovs_test.go b/pkg/network/node/ovs/ovs_test.go similarity index 100% rename from pkg/util/ovs/ovs_test.go rename to pkg/network/node/ovs/ovs_test.go diff --git a/pkg/util/ovs/ovsclient/ovsclient.go b/pkg/network/node/ovs/ovsclient/ovsclient.go similarity index 100% rename from pkg/util/ovs/ovsclient/ovsclient.go rename to pkg/network/node/ovs/ovsclient/ovsclient.go diff --git a/pkg/util/ovs/parse.go b/pkg/network/node/ovs/parse.go similarity index 100% rename from pkg/util/ovs/parse.go rename to pkg/network/node/ovs/parse.go diff --git a/pkg/util/ovs/parse_test.go b/pkg/network/node/ovs/parse_test.go similarity index 100% rename from pkg/util/ovs/parse_test.go rename to pkg/network/node/ovs/parse_test.go diff --git a/pkg/network/node/ovscontroller.go b/pkg/network/node/ovscontroller.go index cce4042df679..84ebc5c9ddaf 100644 --- a/pkg/network/node/ovscontroller.go +++ b/pkg/network/node/ovscontroller.go @@ -14,7 +14,7 @@ import ( networkapi "github.com/openshift/api/network/v1" "github.com/openshift/origin/pkg/network/common" - "github.com/openshift/origin/pkg/util/ovs" + "github.com/openshift/origin/pkg/network/node/ovs" corev1 "k8s.io/api/core/v1" kerrors "k8s.io/apimachinery/pkg/util/errors" diff --git a/pkg/network/node/ovscontroller_test.go b/pkg/network/node/ovscontroller_test.go index a9835cc9b344..f6984b96c0cb 100644 --- a/pkg/network/node/ovscontroller_test.go +++ b/pkg/network/node/ovscontroller_test.go @@ -11,7 +11,7 @@ import ( "testing" networkapi "github.com/openshift/api/network/v1" - "github.com/openshift/origin/pkg/util/ovs" + "github.com/openshift/origin/pkg/network/node/ovs" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/network/node/vxlan_monitor.go b/pkg/network/node/vxlan_monitor.go index a1ad927fc6f2..01345a09ecf0 100644 --- a/pkg/network/node/vxlan_monitor.go +++ b/pkg/network/node/vxlan_monitor.go @@ -15,7 +15,7 @@ import ( utilwait "k8s.io/apimachinery/pkg/util/wait" "github.com/openshift/origin/pkg/network/common" - "github.com/openshift/origin/pkg/util/ovs" + "github.com/openshift/origin/pkg/network/node/ovs" ) // egressVXLANMonitor monitors the health of automatic egress IPs by periodically checking diff --git a/pkg/network/node/vxlan_monitor_test.go b/pkg/network/node/vxlan_monitor_test.go index ae77668f2fed..19a3a715ea28 100644 --- a/pkg/network/node/vxlan_monitor_test.go +++ b/pkg/network/node/vxlan_monitor_test.go @@ -5,7 +5,7 @@ package node import ( "testing" - "github.com/openshift/origin/pkg/util/ovs" + "github.com/openshift/origin/pkg/network/node/ovs" ) func packetsIn(ovsif ovs.Interface, counts map[string]int, nodeIP string) { diff --git a/pkg/oauthserver/oauth/external/github/github.go b/pkg/oauthserver/oauth/external/github/github.go index 9f4274ff84ed..1c3e55c170da 100644 --- a/pkg/oauthserver/oauth/external/github/github.go +++ b/pkg/oauthserver/oauth/external/github/github.go @@ -14,7 +14,7 @@ import ( authapi "github.com/openshift/origin/pkg/oauthserver/api" "github.com/openshift/origin/pkg/oauthserver/oauth/external" - "github.com/openshift/origin/pkg/util/http/links" + "github.com/openshift/origin/pkg/oauthserver/oauth/external/github/links" ) const ( diff --git a/pkg/util/http/links/links.go b/pkg/oauthserver/oauth/external/github/links/links.go similarity index 100% rename from pkg/util/http/links/links.go rename to pkg/oauthserver/oauth/external/github/links/links.go diff --git a/pkg/util/http/links/links_test.go b/pkg/oauthserver/oauth/external/github/links/links_test.go similarity index 100% rename from pkg/util/http/links/links_test.go rename to pkg/oauthserver/oauth/external/github/links/links_test.go diff --git a/pkg/util/fsnotification/doc.go b/pkg/oc/cli/rsync/fsnotification/doc.go similarity index 100% rename from pkg/util/fsnotification/doc.go rename to pkg/oc/cli/rsync/fsnotification/doc.go diff --git a/pkg/util/fsnotification/fsnotification.go b/pkg/oc/cli/rsync/fsnotification/fsnotification.go similarity index 100% rename from pkg/util/fsnotification/fsnotification.go rename to pkg/oc/cli/rsync/fsnotification/fsnotification.go diff --git a/pkg/oc/cli/rsync/rsync.go b/pkg/oc/cli/rsync/rsync.go index 8d90890a4a1b..4a94c2638cdc 100644 --- a/pkg/oc/cli/rsync/rsync.go +++ b/pkg/oc/cli/rsync/rsync.go @@ -17,7 +17,7 @@ import ( kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/kubectl/util/templates" - "github.com/openshift/origin/pkg/util/fsnotification" + "github.com/openshift/origin/pkg/oc/cli/rsync/fsnotification" ) const ( diff --git a/pkg/oc/cli/status/status.go b/pkg/oc/cli/status/status.go index f9b662518e69..6d6595618ccd 100644 --- a/pkg/oc/cli/status/status.go +++ b/pkg/oc/cli/status/status.go @@ -20,7 +20,7 @@ import ( routev1client "github.com/openshift/client-go/route/clientset/versioned/typed/route/v1" loginutil "github.com/openshift/oc/pkg/helpers/project" "github.com/openshift/origin/pkg/oc/lib/describe" - dotutil "github.com/openshift/origin/pkg/util/dot" + dotutil "github.com/openshift/origin/pkg/oc/lib/dot" ) // StatusRecommendedName is the recommended command name. diff --git a/pkg/oc/lib/describe/chaindescriber.go b/pkg/oc/lib/describe/chaindescriber.go index 9122029d409d..bad77d726f28 100644 --- a/pkg/oc/lib/describe/chaindescriber.go +++ b/pkg/oc/lib/describe/chaindescriber.go @@ -15,12 +15,12 @@ import ( imagev1 "github.com/openshift/api/image/v1" buildv1client "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1" + dotutil "github.com/openshift/origin/pkg/oc/lib/dot" buildedges "github.com/openshift/origin/pkg/oc/lib/graph/buildgraph" buildanalysis "github.com/openshift/origin/pkg/oc/lib/graph/buildgraph/analysis" buildgraph "github.com/openshift/origin/pkg/oc/lib/graph/buildgraph/nodes" osgraph "github.com/openshift/origin/pkg/oc/lib/graph/genericgraph" imagegraph "github.com/openshift/origin/pkg/oc/lib/graph/imagegraph/nodes" - dotutil "github.com/openshift/origin/pkg/util/dot" "github.com/openshift/origin/pkg/util/parallel" ) diff --git a/pkg/util/dot/dot.go b/pkg/oc/lib/dot/dot.go similarity index 100% rename from pkg/util/dot/dot.go rename to pkg/oc/lib/dot/dot.go diff --git a/pkg/util/dot/dot_test.go b/pkg/oc/lib/dot/dot_test.go similarity index 100% rename from pkg/util/dot/dot_test.go rename to pkg/oc/lib/dot/dot_test.go diff --git a/pkg/oc/lib/newapp/app/imageref.go b/pkg/oc/lib/newapp/app/imageref.go index 6e5de6944ecf..aaf4b9a6a102 100644 --- a/pkg/oc/lib/newapp/app/imageref.go +++ b/pkg/oc/lib/newapp/app/imageref.go @@ -20,8 +20,8 @@ import ( "github.com/openshift/origin/pkg/api/apihelpers" imageapi "github.com/openshift/origin/pkg/image/apis/image" imageutil "github.com/openshift/origin/pkg/image/util" - "github.com/openshift/origin/pkg/util/docker/dockerfile" - "github.com/openshift/origin/pkg/util/portutils" + "github.com/openshift/origin/pkg/oc/lib/newapp/docker/dockerfile" + "github.com/openshift/origin/pkg/oc/lib/newapp/portutils" ) // ImageRefGenerator is an interface for generating ImageRefs diff --git a/pkg/oc/lib/newapp/app/pipeline.go b/pkg/oc/lib/newapp/app/pipeline.go index 05e42acfd9eb..e1e1f029b767 100644 --- a/pkg/oc/lib/newapp/app/pipeline.go +++ b/pkg/oc/lib/newapp/app/pipeline.go @@ -29,8 +29,8 @@ import ( "github.com/openshift/origin/pkg/api/legacy" imageapi "github.com/openshift/origin/pkg/image/apis/image" "github.com/openshift/origin/pkg/oc/lib/newapp" + "github.com/openshift/origin/pkg/oc/lib/newapp/docker/dockerfile" routeapi "github.com/openshift/origin/pkg/route/apis/route" - "github.com/openshift/origin/pkg/util/docker/dockerfile" ) // A PipelineBuilder creates Pipeline instances. diff --git a/pkg/oc/lib/newapp/appjson/appjson.go b/pkg/oc/lib/newapp/appjson/appjson.go index 48a480f59640..cc6eb2b00f42 100644 --- a/pkg/oc/lib/newapp/appjson/appjson.go +++ b/pkg/oc/lib/newapp/appjson/appjson.go @@ -21,7 +21,7 @@ import ( templatev1 "github.com/openshift/api/template/v1" "github.com/openshift/origin/pkg/oc/lib/newapp" "github.com/openshift/origin/pkg/oc/lib/newapp/app" - "github.com/openshift/origin/pkg/util/docker/dockerfile" + "github.com/openshift/origin/pkg/oc/lib/newapp/docker/dockerfile" ) type EnvVarOrString struct { diff --git a/pkg/oc/lib/newapp/cmd/describe.go b/pkg/oc/lib/newapp/cmd/describe.go index 65ca8f0616b2..fa602f111ed9 100644 --- a/pkg/oc/lib/newapp/cmd/describe.go +++ b/pkg/oc/lib/newapp/cmd/describe.go @@ -17,7 +17,7 @@ import ( "github.com/openshift/origin/pkg/oc/lib/describe" "github.com/openshift/origin/pkg/oc/lib/newapp" "github.com/openshift/origin/pkg/oc/lib/newapp/app" - "github.com/openshift/origin/pkg/util/portutils" + "github.com/openshift/origin/pkg/oc/lib/newapp/portutils" ) func displayName(meta metav1.ObjectMeta) string { diff --git a/pkg/oc/lib/newapp/cmd/resolve.go b/pkg/oc/lib/newapp/cmd/resolve.go index b4acd03ffca8..afeffbd89e9d 100644 --- a/pkg/oc/lib/newapp/cmd/resolve.go +++ b/pkg/oc/lib/newapp/cmd/resolve.go @@ -11,7 +11,7 @@ import ( "github.com/openshift/library-go/pkg/git" "github.com/openshift/origin/pkg/oc/lib/newapp" "github.com/openshift/origin/pkg/oc/lib/newapp/app" - dockerfileutil "github.com/openshift/origin/pkg/util/docker/dockerfile" + dockerfileutil "github.com/openshift/origin/pkg/oc/lib/newapp/docker/dockerfile" ) // Resolvers are used to identify source repositories, images, or templates in different contexts diff --git a/pkg/util/docker/doc.go b/pkg/oc/lib/newapp/docker/doc.go similarity index 100% rename from pkg/util/docker/doc.go rename to pkg/oc/lib/newapp/docker/doc.go diff --git a/pkg/util/docker/dockerfile/doc.go b/pkg/oc/lib/newapp/docker/dockerfile/doc.go similarity index 100% rename from pkg/util/docker/dockerfile/doc.go rename to pkg/oc/lib/newapp/docker/dockerfile/doc.go diff --git a/pkg/util/docker/dockerfile/dockerfile.go b/pkg/oc/lib/newapp/docker/dockerfile/dockerfile.go similarity index 100% rename from pkg/util/docker/dockerfile/dockerfile.go rename to pkg/oc/lib/newapp/docker/dockerfile/dockerfile.go diff --git a/pkg/util/docker/dockerfile/dockerfile_test.go b/pkg/oc/lib/newapp/docker/dockerfile/dockerfile_test.go similarity index 100% rename from pkg/util/docker/dockerfile/dockerfile_test.go rename to pkg/oc/lib/newapp/docker/dockerfile/dockerfile_test.go diff --git a/pkg/util/docker/dockerfile/instructions.go b/pkg/oc/lib/newapp/docker/dockerfile/instructions.go similarity index 100% rename from pkg/util/docker/dockerfile/instructions.go rename to pkg/oc/lib/newapp/docker/dockerfile/instructions.go diff --git a/pkg/util/docker/dockerfile/instructions_test.go b/pkg/oc/lib/newapp/docker/dockerfile/instructions_test.go similarity index 100% rename from pkg/util/docker/dockerfile/instructions_test.go rename to pkg/oc/lib/newapp/docker/dockerfile/instructions_test.go diff --git a/pkg/util/docker/dockerfile/shell_parser.go b/pkg/oc/lib/newapp/docker/dockerfile/shell_parser.go similarity index 100% rename from pkg/util/docker/dockerfile/shell_parser.go rename to pkg/oc/lib/newapp/docker/dockerfile/shell_parser.go diff --git a/pkg/util/portutils/common.go b/pkg/oc/lib/newapp/portutils/common.go similarity index 100% rename from pkg/util/portutils/common.go rename to pkg/oc/lib/newapp/portutils/common.go diff --git a/pkg/util/portutils/common_test.go b/pkg/oc/lib/newapp/portutils/common_test.go similarity index 100% rename from pkg/util/portutils/common_test.go rename to pkg/oc/lib/newapp/portutils/common_test.go diff --git a/pkg/util/glog/glog.go b/pkg/util/glog/glog.go deleted file mode 100644 index fad20966b394..000000000000 --- a/pkg/util/glog/glog.go +++ /dev/null @@ -1,103 +0,0 @@ -package glog - -import ( - "fmt" - "io" - "strings" - - "k8s.io/klog" -) - -// Logger is a simple interface that is roughly equivalent to klog. -type Logger interface { - Is(level int) bool - V(level int) Logger - Infof(format string, args ...interface{}) -} - -// ToFile creates a logger that will log any items at level or below to file, and defer -// any other output to glog (no matter what the level is.) -func ToFile(w io.Writer, level int) Logger { - return file{w, level} -} - -var ( - // None implements the Logger interface but does nothing with the log output - None Logger = discard{} - // Log implements the Logger interface for Glog - Log Logger = glogger{} -) - -// discard is a Logger that outputs nothing. -type discard struct{} - -func (discard) Is(level int) bool { return false } -func (discard) V(level int) Logger { return None } -func (discard) Infof(_ string, _ ...interface{}) {} - -// glogger outputs log messages to glog -type glogger struct{} - -func (glogger) Is(level int) bool { - return bool(klog.V(klog.Level(level))) -} - -func (glogger) V(level int) Logger { - return gverbose{klog.V(klog.Level(level))} -} - -func (glogger) Infof(format string, args ...interface{}) { - klog.InfoDepth(2, fmt.Sprintf(format, args...)) -} - -// gverbose handles klog.V(x) calls -type gverbose struct { - klog.Verbose -} - -func (gverbose) Is(level int) bool { - return bool(klog.V(klog.Level(level))) -} - -func (gverbose) V(level int) Logger { - if klog.V(klog.Level(level)) { - return Log - } - return None -} - -func (g gverbose) Infof(format string, args ...interface{}) { - if g.Verbose { - klog.InfoDepth(2, fmt.Sprintf(format, args...)) - } -} - -// file logs the provided messages at level or below to the writer, or delegates -// to klog. -type file struct { - w io.Writer - level int -} - -func (f file) Is(level int) bool { - return level <= f.level || bool(klog.V(klog.Level(level))) -} - -func (f file) V(level int) Logger { - // only log things that glog allows - if !klog.V(klog.Level(level)) { - return None - } - // send anything above our level to glog - if level > f.level { - return Log - } - return f -} - -func (f file) Infof(format string, args ...interface{}) { - fmt.Fprintf(f.w, format, args...) - if !strings.HasSuffix(format, "\n") { - fmt.Fprintln(f.w) - } -} diff --git a/pkg/util/httpproxy/doc.go b/pkg/util/httpproxy/doc.go deleted file mode 100644 index 86cdeac7183a..000000000000 --- a/pkg/util/httpproxy/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package httpproxy contains an upgrade-aware HTTP single-host reverse proxy. -package httpproxy diff --git a/pkg/util/httpproxy/upgradeawareproxy.go b/pkg/util/httpproxy/upgradeawareproxy.go deleted file mode 100644 index fab6fc33d73d..000000000000 --- a/pkg/util/httpproxy/upgradeawareproxy.go +++ /dev/null @@ -1,270 +0,0 @@ -package httpproxy - -import ( - "bufio" - "crypto/tls" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "net/http/httputil" - "net/url" - "strings" - "time" - - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apimachinery/third_party/forked/golang/netutil" - restclient "k8s.io/client-go/rest" - - "k8s.io/klog" -) - -// UpgradeAwareSingleHostReverseProxy is capable of proxying both regular HTTP -// connections and those that require upgrading (e.g. web sockets). It implements -// the http.RoundTripper and http.Handler interfaces. -type UpgradeAwareSingleHostReverseProxy struct { - clientConfig *restclient.Config - backendAddr *url.URL - transport http.RoundTripper - reverseProxy *httputil.ReverseProxy -} - -// NewUpgradeAwareSingleHostReverseProxy creates a new UpgradeAwareSingleHostReverseProxy. -func NewUpgradeAwareSingleHostReverseProxy(clientConfig *restclient.Config, backendAddr *url.URL) (*UpgradeAwareSingleHostReverseProxy, error) { - transport, err := restclient.TransportFor(clientConfig) - if err != nil { - return nil, err - } - reverseProxy := httputil.NewSingleHostReverseProxy(backendAddr) - reverseProxy.FlushInterval = 200 * time.Millisecond - p := &UpgradeAwareSingleHostReverseProxy{ - clientConfig: clientConfig, - backendAddr: backendAddr, - transport: transport, - reverseProxy: reverseProxy, - } - p.reverseProxy.Transport = p - return p, nil -} - -// RoundTrip sends the request to the backend and strips off the CORS headers -// before returning the response. -func (p *UpgradeAwareSingleHostReverseProxy) RoundTrip(req *http.Request) (*http.Response, error) { - resp, err := p.transport.RoundTrip(req) - if err != nil { - return resp, err - } - - removeCORSHeaders(resp) - removeChallengeHeaders(resp) - if resp.StatusCode == http.StatusUnauthorized { - utilruntime.HandleError(fmt.Errorf("got unauthorized error from backend for: %s %s", req.Method, req.URL)) - // Internal error, backend didn't recognize proxy identity - // Surface as a server error to the client - // TODO do we need to do more than this? - resp = &http.Response{ - StatusCode: http.StatusInternalServerError, - Status: http.StatusText(http.StatusInternalServerError), - Body: ioutil.NopCloser(strings.NewReader("Internal Server Error")), - ContentLength: -1, - } - } - - // TODO do we need to strip off anything else? - - return resp, err -} - -// borrowed from net/http/httputil/reverseproxy.go -func singleJoiningSlash(a, b string) string { - aslash := strings.HasSuffix(a, "/") - bslash := strings.HasPrefix(b, "/") - switch { - case aslash && bslash: - return a + b[1:] - case !aslash && !bslash: - return a + "/" + b - } - return a + b -} - -func (p *UpgradeAwareSingleHostReverseProxy) newProxyRequest(req *http.Request) (*http.Request, error) { - // TODO is this the best way to clone the original request and create - // the new request for the backend? Do we need to copy anything else? - // - backendURL := *p.backendAddr - // if backendAddr is http://host/base and req is for /foo, the resulting path - // for backendURL should be /base/foo - backendURL.Path = singleJoiningSlash(backendURL.Path, req.URL.Path) - backendURL.RawQuery = req.URL.RawQuery - - newReq, err := http.NewRequest(req.Method, backendURL.String(), req.Body) - if err != nil { - return nil, err - } - // TODO is this the right way to copy headers? - newReq.Header = req.Header - - // TODO do we need to exclude any other headers? - removeAuthHeaders(newReq) - - return newReq, nil -} - -func (p *UpgradeAwareSingleHostReverseProxy) isUpgradeRequest(req *http.Request) bool { - for _, h := range req.Header[http.CanonicalHeaderKey("Connection")] { - if strings.Contains(strings.ToLower(h), "upgrade") { - return true - } - } - return false -} - -// ServeHTTP inspects the request and either proxies an upgraded connection directly, -// or uses httputil.ReverseProxy to proxy the normal request. -func (p *UpgradeAwareSingleHostReverseProxy) ServeHTTP(w http.ResponseWriter, req *http.Request) { - newReq, err := p.newProxyRequest(req) - if err != nil { - klog.Errorf("Error creating backend request: %s", err) - // TODO do we need to do more than this? - w.WriteHeader(http.StatusInternalServerError) - return - } - - if !p.isUpgradeRequest(req) { - p.reverseProxy.ServeHTTP(w, newReq) - return - } - - p.serveUpgrade(w, newReq) -} - -func (p *UpgradeAwareSingleHostReverseProxy) dialBackend(req *http.Request) (net.Conn, error) { - dialAddr := netutil.CanonicalAddr(req.URL) - - switch p.backendAddr.Scheme { - case "http": - return net.Dial("tcp", dialAddr) - case "https": - tlsConfig, err := restclient.TLSConfigFor(p.clientConfig) - if err != nil { - return nil, err - } - tlsConn, err := tls.Dial("tcp", dialAddr, tlsConfig) - if err != nil { - return nil, err - } - hostToVerify, _, err := net.SplitHostPort(dialAddr) - if err != nil { - return nil, err - } - err = tlsConn.VerifyHostname(hostToVerify) - return tlsConn, err - default: - return nil, fmt.Errorf("unknown scheme: %s", p.backendAddr.Scheme) - } -} - -func (p *UpgradeAwareSingleHostReverseProxy) serveUpgrade(w http.ResponseWriter, req *http.Request) { - backendConn, err := p.dialBackend(req) - if err != nil { - klog.Errorf("Error connecting to backend: %s", err) - // TODO do we need to do more than this? - w.WriteHeader(http.StatusServiceUnavailable) - return - } - defer backendConn.Close() - - addAuthHeaders(req, p.clientConfig) - - err = req.Write(backendConn) - if err != nil { - klog.Errorf("Error writing request to backend: %s", err) - return - } - - resp, err := http.ReadResponse(bufio.NewReader(backendConn), req) - if err != nil { - klog.Errorf("Error reading response from backend: %s", err) - w.WriteHeader(http.StatusInternalServerError) - w.Write([]byte("Internal Server Error")) - return - } - - if resp.StatusCode == http.StatusUnauthorized { - klog.Errorf("Got unauthorized error from backend for: %s %s", req.Method, req.URL) - w.WriteHeader(http.StatusInternalServerError) - w.Write([]byte("Internal Server Error")) - return - } - - requestHijackedConn, _, err := w.(http.Hijacker).Hijack() - if err != nil { - klog.Errorf("Error hijacking request connection: %s", err) - return - } - defer requestHijackedConn.Close() - - // NOTE: from this point forward, we own the connection and we can't use - // w.Header(), w.Write(), or w.WriteHeader any more - - removeCORSHeaders(resp) - removeChallengeHeaders(resp) - err = resp.Write(requestHijackedConn) - if err != nil { - klog.Errorf("Error writing backend response to client: %s", err) - return - } - - done := make(chan struct{}, 2) - - go func() { - _, err := io.Copy(backendConn, requestHijackedConn) - if err != nil && !strings.Contains(err.Error(), "use of closed network connection") { - utilruntime.HandleError(fmt.Errorf("error proxying data from client to backend: %v", err)) - } - done <- struct{}{} - }() - - go func() { - _, err := io.Copy(requestHijackedConn, backendConn) - if err != nil && !strings.Contains(err.Error(), "use of closed network connection") { - utilruntime.HandleError(fmt.Errorf("error proxying data from backend to client: %v", err)) - } - done <- struct{}{} - }() - - <-done -} - -// removeAuthHeaders strips authorization headers from an incoming client -// This should be called on all requests before proxying -func removeAuthHeaders(req *http.Request) { - req.Header.Del("Authorization") -} - -// removeChallengeHeaders strips WWW-Authenticate headers from backend responses -// This should be called on all responses before returning -func removeChallengeHeaders(resp *http.Response) { - resp.Header.Del("WWW-Authenticate") -} - -// removeCORSHeaders strip CORS headers sent from the backend -// This should be called on all responses before returning -func removeCORSHeaders(resp *http.Response) { - resp.Header.Del("Access-Control-Allow-Credentials") - resp.Header.Del("Access-Control-Allow-Headers") - resp.Header.Del("Access-Control-Allow-Methods") - resp.Header.Del("Access-Control-Allow-Origin") -} - -// addAuthHeaders adds basic/bearer auth from the given config (if specified) -// This should be run on any requests not handled by the transport returned from TransportFor(config) -func addAuthHeaders(req *http.Request, clientConfig *restclient.Config) { - if clientConfig.BearerToken != "" { - req.Header.Set("Authorization", "Bearer "+clientConfig.BearerToken) - } else if clientConfig.Username != "" || clientConfig.Password != "" { - req.SetBasicAuth(clientConfig.Username, clientConfig.Password) - } -} diff --git a/pkg/util/jsonmerge/jsonmerge.go b/pkg/util/jsonmerge/jsonmerge.go deleted file mode 100644 index f6f311fcbc2c..000000000000 --- a/pkg/util/jsonmerge/jsonmerge.go +++ /dev/null @@ -1,161 +0,0 @@ -package jsonmerge - -import ( - "encoding/json" - "fmt" - "reflect" - - "github.com/evanphx/json-patch" - "k8s.io/klog" - - "k8s.io/apimachinery/pkg/util/yaml" -) - -// Delta represents a change between two JSON documents. -type Delta struct { - original []byte - edit []byte - - preconditions []PreconditionFunc -} - -// PreconditionFunc is a test to verify that an incompatible change -// has occurred before an Apply can be successful. -type PreconditionFunc func(interface{}) bool - -// AddPreconditions adds precondition checks to a change which must -// be satisfied before an Apply is considered successful. If a -// precondition returns false, the Apply is failed with -// ErrPreconditionFailed. -func (d *Delta) AddPreconditions(fns ...PreconditionFunc) { - d.preconditions = append(d.preconditions, fns...) -} - -// RequireKeyUnchanged creates a precondition function that fails -// if the provided key is present in the diff (indicating its value -// has changed). -func RequireKeyUnchanged(key string) PreconditionFunc { - return func(diff interface{}) bool { - m, ok := diff.(map[string]interface{}) - if !ok { - return true - } - // the presence of key in a diff means that its value has been changed, therefore - // we should fail the precondition. - _, ok = m[key] - return !ok - } -} - -// NewDelta accepts two JSON or YAML documents and calculates the difference -// between them. It returns a Delta object which can be used to resolve -// conflicts against a third version with a common parent, or an error -// if either document is in error. -func NewDelta(from, to []byte) (*Delta, error) { - d := &Delta{} - before, err := yaml.ToJSON(from) - if err != nil { - return nil, err - } - after, err := yaml.ToJSON(to) - if err != nil { - return nil, err - } - diff, err := jsonpatch.CreateMergePatch(before, after) - if err != nil { - return nil, err - } - klog.V(6).Infof("Patch created from:\n%s\n%s\n%s", string(before), string(after), string(diff)) - d.original = before - d.edit = diff - return d, nil -} - -// Apply attempts to apply the changes described by Delta onto latest, -// returning an error if the changes cannot be applied cleanly. -// IsConflicting will be true if the changes overlap, otherwise a -// generic error will be returned. -func (d *Delta) Apply(latest []byte) ([]byte, error) { - base, err := yaml.ToJSON(latest) - if err != nil { - return nil, err - } - changes, err := jsonpatch.CreateMergePatch(d.original, base) - if err != nil { - return nil, err - } - diff1 := make(map[string]interface{}) - if err := json.Unmarshal(d.edit, &diff1); err != nil { - return nil, err - } - diff2 := make(map[string]interface{}) - if err := json.Unmarshal(changes, &diff2); err != nil { - return nil, err - } - for _, fn := range d.preconditions { - if !fn(diff1) || !fn(diff2) { - return nil, ErrPreconditionFailed - } - } - - klog.V(6).Infof("Testing for conflict between:\n%s\n%s", string(d.edit), string(changes)) - if hasConflicts(diff1, diff2) { - return nil, ErrConflict - } - return jsonpatch.MergePatch(base, d.edit) -} - -// IsConflicting returns true if the provided error indicates a -// conflict exists between the original changes and the applied -// changes. -func IsConflicting(err error) bool { - return err == ErrConflict -} - -// IsPreconditionFailed returns true if the provided error indicates -// a Delta precondition did not succeed. -func IsPreconditionFailed(err error) bool { - return err == ErrPreconditionFailed -} - -var ErrPreconditionFailed = fmt.Errorf("a precondition failed") -var ErrConflict = fmt.Errorf("changes are in conflict") - -// hasConflicts returns true if the left and right JSON interface objects overlap with -// different values in any key. The code will panic if an unrecognized type is passed -// (anything not returned by a JSON decode). All keys are required to be strings. -func hasConflicts(left, right interface{}) bool { - switch typedLeft := left.(type) { - case map[string]interface{}: - switch typedRight := right.(type) { - case map[string]interface{}: - for key, leftValue := range typedLeft { - if rightValue, ok := typedRight[key]; ok && hasConflicts(leftValue, rightValue) { - return true - } - } - return false - default: - return true - } - case []interface{}: - switch typedRight := right.(type) { - case []interface{}: - if len(typedLeft) != len(typedRight) { - return true - } - for i := range typedLeft { - if hasConflicts(typedLeft[i], typedRight[i]) { - return true - } - } - return false - default: - return true - } - case string, float64, bool, int, int64, nil: - return !reflect.DeepEqual(left, right) - default: - panic(fmt.Sprintf("unknown type: %v", reflect.TypeOf(left))) - } -} diff --git a/pkg/util/jsonmerge/jsonmerge_test.go b/pkg/util/jsonmerge/jsonmerge_test.go deleted file mode 100644 index 2f85d47c5542..000000000000 --- a/pkg/util/jsonmerge/jsonmerge_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package jsonmerge - -import ( - "testing" -) - -func TestHasConflicts(t *testing.T) { - testCases := []struct { - A interface{} - B interface{} - Ret bool - }{ - {A: "hello", B: "hello", Ret: false}, // 0 - {A: "hello", B: "hell", Ret: true}, - {A: "hello", B: nil, Ret: true}, - {A: "hello", B: 1, Ret: true}, - {A: "hello", B: float64(1.0), Ret: true}, - {A: "hello", B: false, Ret: true}, - - {A: "hello", B: []interface{}{}, Ret: true}, // 6 - {A: []interface{}{1}, B: []interface{}{}, Ret: true}, - {A: []interface{}{}, B: []interface{}{}, Ret: false}, - {A: []interface{}{1}, B: []interface{}{1}, Ret: false}, - {A: map[string]interface{}{}, B: []interface{}{1}, Ret: true}, - - {A: map[string]interface{}{}, B: map[string]interface{}{"a": 1}, Ret: false}, // 11 - {A: map[string]interface{}{"a": 1}, B: map[string]interface{}{"a": 1}, Ret: false}, - {A: map[string]interface{}{"a": 1}, B: map[string]interface{}{"a": 2}, Ret: true}, - {A: map[string]interface{}{"a": 1}, B: map[string]interface{}{"b": 2}, Ret: false}, - - { // 15 - A: map[string]interface{}{"a": []interface{}{1}}, - B: map[string]interface{}{"a": []interface{}{1}}, - Ret: false, - }, - { - A: map[string]interface{}{"a": []interface{}{1}}, - B: map[string]interface{}{"a": []interface{}{}}, - Ret: true, - }, - { - A: map[string]interface{}{"a": []interface{}{1}}, - B: map[string]interface{}{"a": 1}, - Ret: true, - }, - } - - for i, testCase := range testCases { - out := hasConflicts(testCase.A, testCase.B) - if out != testCase.Ret { - t.Errorf("%d: expected %t got %t", i, testCase.Ret, out) - continue - } - out = hasConflicts(testCase.B, testCase.A) - if out != testCase.Ret { - t.Errorf("%d: expected reversed %t got %t", i, testCase.Ret, out) - } - } -} diff --git a/pkg/util/ratelimiter/ratelimiter.go b/pkg/util/ratelimiter/ratelimiter.go deleted file mode 100644 index 5d23537823e0..000000000000 --- a/pkg/util/ratelimiter/ratelimiter.go +++ /dev/null @@ -1,61 +0,0 @@ -package ratelimiter - -import ( - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - utilwait "k8s.io/apimachinery/pkg/util/wait" - kcache "k8s.io/client-go/tools/cache" - "k8s.io/client-go/util/flowcontrol" -) - -// HandlerFunc defines function signature for a RateLimitedFunction. -type HandlerFunc func() error - -// RateLimitedFunction is a rate limited function controlling how often the function/handler is invoked. -type RateLimitedFunction struct { - // Handler is the function to rate limit calls to. - Handler HandlerFunc - - // Internal queue of requests to be processed. - queue kcache.Queue - - // Rate limiting configuration. - flowcontrol.RateLimiter -} - -// NewRateLimitedFunction creates a new rate limited function. -func NewRateLimitedFunction(keyFunc kcache.KeyFunc, interval int, handlerFunc HandlerFunc) *RateLimitedFunction { - fifo := kcache.NewFIFO(keyFunc) - - qps := float32(1000.0) // Call rate per second (SLA). - if interval > 0 { - qps = float32(1.0 / float32(interval)) - } - - limiter := flowcontrol.NewTokenBucketRateLimiter(qps, 1) - - return &RateLimitedFunction{handlerFunc, fifo, limiter} -} - -// RunUntil begins processes the resources from queue asynchronously until -// stopCh is closed. -func (rlf *RateLimitedFunction) RunUntil(stopCh <-chan struct{}) { - go utilwait.Until(rlf.pop, 0, stopCh) -} - -// handleOne processes a request in the queue invoking the rate limited -// function. -func (rlf *RateLimitedFunction) pop() { - rlf.RateLimiter.Accept() - if _, err := rlf.queue.Pop(func(_ interface{}) error { - return rlf.Handler() - }); err != nil { - utilruntime.HandleError(err) - } -} - -// Invoke adds a request if its not already present and returns immediately -// unless the rate limited function is actually running, in which case it will -// block until the current run completes -func (rlf *RateLimitedFunction) Invoke(resource interface{}) { - rlf.queue.AddIfNotPresent(resource) -} diff --git a/pkg/util/ratelimiter/ratelimiter_test.go b/pkg/util/ratelimiter/ratelimiter_test.go deleted file mode 100644 index 54e214803058..000000000000 --- a/pkg/util/ratelimiter/ratelimiter_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package ratelimiter - -import ( - "sync" - "testing" - "time" -) - -type handler struct { - _counter int - sync.Mutex -} - -func (h *handler) handle() error { - h.Lock() - defer h.Unlock() - h._counter += 1 - return nil -} - -func (h *handler) counter() int { - h.Lock() - defer h.Unlock() - return h._counter -} - -func TestRateLimitedFunction(t *testing.T) { - tests := []struct { - Name string - Interval int - Times int - }{ - { - Name: "unrated", - Interval: 0, - Times: 5, - }, - { - Name: "3PO", - Interval: 3, - Times: 10, - }, - { - Name: "five-fer", - Interval: 5, - Times: 20, - }, - } - - keyFunc := func(_ interface{}) (string, error) { - return "ratelimitertest", nil - } - - for _, tc := range tests { - h := &handler{} - quit := make(chan struct{}) - rlf := NewRateLimitedFunction(keyFunc, tc.Interval, h.handle) - rlf.RunUntil(quit) - - for i := 0; i < tc.Times; i++ { - go func(rlf *RateLimitedFunction, idx, interval int) { - if interval > 0 { - rlf.Invoke(rlf) - } else { - rlf.Invoke(idx) - } - }(rlf, i, tc.Interval) - } - - select { - case <-time.After(time.Duration(tc.Interval+2) * time.Second): - close(quit) - counter := h.counter() - if tc.Interval > 0 && counter >= tc.Times/2 { - t.Errorf("For coalesced calls, expected number of invocations to be atleast half. Expected: < %v Got: %v", - tc.Times/2, counter) - } - } - } -} diff --git a/pkg/util/rest/mapper.go b/pkg/util/rest/mapper.go deleted file mode 100644 index 0062e0ca87d9..000000000000 --- a/pkg/util/rest/mapper.go +++ /dev/null @@ -1 +0,0 @@ -package rest