diff --git a/cmd/libs/go2idl/client-gen/generators/generator_for_clientset.go b/cmd/libs/go2idl/client-gen/generators/generator_for_clientset.go index 97d2add24bd..4198b3ffe16 100644 --- a/cmd/libs/go2idl/client-gen/generators/generator_for_clientset.go +++ b/cmd/libs/go2idl/client-gen/generators/generator_for_clientset.go @@ -64,6 +64,8 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) { } imports = append(imports, "github.com/golang/glog") imports = append(imports, "k8s.io/kubernetes/pkg/util/flowcontrol") + // import solely to initialize client auth plugins. + imports = append(imports, "_ \"k8s.io/kubernetes/plugin/pkg/client/auth\"") return } diff --git a/pkg/client/clientset_generated/release_1_5/import_known_versions.go b/pkg/client/clientset_generated/release_1_5/import_known_versions.go index 024a8b2c94b..0f94212588e 100644 --- a/pkg/client/clientset_generated/release_1_5/import_known_versions.go +++ b/pkg/client/clientset_generated/release_1_5/import_known_versions.go @@ -22,11 +22,15 @@ import ( _ "k8s.io/kubernetes/pkg/api/install" "k8s.io/kubernetes/pkg/apimachinery/registered" + _ "k8s.io/kubernetes/pkg/apis/apps/install" + _ "k8s.io/kubernetes/pkg/apis/authentication/install" _ "k8s.io/kubernetes/pkg/apis/authorization/install" _ "k8s.io/kubernetes/pkg/apis/autoscaling/install" _ "k8s.io/kubernetes/pkg/apis/batch/install" + _ "k8s.io/kubernetes/pkg/apis/certificates/install" _ "k8s.io/kubernetes/pkg/apis/extensions/install" _ "k8s.io/kubernetes/pkg/apis/policy/install" + _ "k8s.io/kubernetes/pkg/apis/rbac/install" _ "k8s.io/kubernetes/pkg/apis/storage/install" ) diff --git a/plugin/pkg/client/auth/gcp/gcp.go b/plugin/pkg/client/auth/gcp/gcp.go index b7137ec52de..57fd98c35e0 100644 --- a/plugin/pkg/client/auth/gcp/gcp.go +++ b/plugin/pkg/client/auth/gcp/gcp.go @@ -24,8 +24,6 @@ import ( "golang.org/x/net/context" "golang.org/x/oauth2" "golang.org/x/oauth2/google" - - clientreporestclient "k8s.io/client-go/1.5/rest" "k8s.io/kubernetes/pkg/client/restclient" ) @@ -33,9 +31,6 @@ func init() { if err := restclient.RegisterAuthProviderPlugin("gcp", newGCPAuthProvider); err != nil { glog.Fatalf("Failed to register gcp auth plugin: %v", err) } - if err := clientreporestclient.RegisterAuthProviderPlugin("gcp", newGCPAuthProviderForClientRepo); err != nil { - glog.Fatalf("Failed to register gcp auth plugin: %v", err) - } } type gcpAuthProvider struct { @@ -51,15 +46,6 @@ func newGCPAuthProvider(_ string, gcpConfig map[string]string, persister restcli return &gcpAuthProvider{ts, persister}, nil } -// newGCPAuthProviderForClientRepo is the same as newGCPAuthProvider, but is programmed against client-go's interface -func newGCPAuthProviderForClientRepo(_ string, gcpConfig map[string]string, persister clientreporestclient.AuthProviderConfigPersister) (clientreporestclient.AuthProvider, error) { - ts, err := newCachedTokenSource(gcpConfig["access-token"], gcpConfig["expiry"], persister) - if err != nil { - return nil, err - } - return &gcpAuthProvider{ts, persister}, nil -} - func (g *gcpAuthProvider) WrapTransport(rt http.RoundTripper) http.RoundTripper { return &oauth2.Transport{ Source: g.tokenSource, diff --git a/plugin/pkg/client/auth/plugins.go b/plugin/pkg/client/auth/plugins.go index 17d3ad42788..21813b05812 100644 --- a/plugin/pkg/client/auth/plugins.go +++ b/plugin/pkg/client/auth/plugins.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package plugins +package auth import ( // Initialize all known client auth plugins. diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/import_known_versions.go b/staging/src/k8s.io/client-go/1.5/kubernetes/import_known_versions.go index 47f75a45fb9..62b2f4e6256 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/import_known_versions.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/import_known_versions.go @@ -22,6 +22,7 @@ import ( _ "k8s.io/client-go/1.5/pkg/api/install" "k8s.io/client-go/1.5/pkg/apimachinery/registered" + _ "k8s.io/client-go/1.5/pkg/apis/apps/install" _ "k8s.io/client-go/1.5/pkg/apis/authorization/install" _ "k8s.io/client-go/1.5/pkg/apis/autoscaling/install" _ "k8s.io/client-go/1.5/pkg/apis/batch/install" diff --git a/staging/src/k8s.io/client-go/copy.sh b/staging/src/k8s.io/client-go/copy.sh index 1f09cdb9aba..54dff86fb91 100755 --- a/staging/src/k8s.io/client-go/copy.sh +++ b/staging/src/k8s.io/client-go/copy.sh @@ -55,6 +55,8 @@ mkcp "/pkg/client/typed" "/pkg/client" mkcp "/pkg/client/unversioned/auth" "/pkg/client/unversioned" mkcp "/pkg/client/unversioned/clientcmd" "/pkg/client/unversioned" mkcp "/pkg/client/unversioned/portforward" "/pkg/client/unversioned" + +mkcp "/plugin/pkg/client/auth" "/plugin/pkg/client" # remove this test because it imports the internal clientset rm "${CLIENT_REPO_TEMP}"/pkg/client/unversioned/portforward/portforward_test.go @@ -126,17 +128,18 @@ function mvfolder { local src_package="${src##*/}" local dst_package="${dst##*/}" find "${CLIENT_REPO}" -type f -name "*.go" -print0 | xargs -0 sed -i "s,package ${src_package},package ${dst_package},g" - # rewrite imports - # the first rule is to convert import lines like `restclient "k8s.io/client-go/pkg/client/restclient"`, - # where a package alias is the same the package name. - find "${CLIENT_REPO}" -type f -name "*.go" -print0 | \ - xargs -0 sed -i "s,${src_package} \"${CLIENT_REPO_FROM_SRC}/${src},${dst_package} \"${CLIENT_REPO_FROM_SRC}/${dst},g" - find "${CLIENT_REPO}" -type f -name "*.go" -print0 | \ - xargs -0 sed -i "s,\"${CLIENT_REPO_FROM_SRC}/${src},\"${CLIENT_REPO_FROM_SRC}/${dst},g" - # rewrite import invocation - if [ "${src_package}" != "${dst_package}" ]; then - find "${CLIENT_REPO}" -type f -name "*.go" -print0 | xargs -0 sed -i "s,\<${src_package}\.\([a-zA-Z]\),${dst_package}\.\1,g" - fi + + { grep -Rl "\"${CLIENT_REPO_FROM_SRC}/${src}" "${CLIENT_REPO}" || true ; } | while read -r target ; do + # rewrite imports + # the first rule is to convert import lines like `restclient "k8s.io/client-go/pkg/client/restclient"`, + # where a package alias is the same the package name. + sed -i "s,\<${src_package} \"${CLIENT_REPO_FROM_SRC}/${src},${dst_package} \"${CLIENT_REPO_FROM_SRC}/${dst},g" "${target}" + sed -i "s,\"${CLIENT_REPO_FROM_SRC}/${src},\"${CLIENT_REPO_FROM_SRC}/${dst},g" "${target}" + # rewrite import invocation + if [ "${src_package}" != "${dst_package}" ]; then + sed -i "s,\<${src_package}\.\([a-zA-Z]\),${dst_package}\.\1,g" "${target}" + fi + done } mvfolder "pkg/client/clientset_generated/${CLIENTSET}" kubernetes @@ -151,6 +154,7 @@ mvfolder pkg/client/unversioned/clientcmd tools/clientcmd mvfolder pkg/client/unversioned/portforward tools/portforward mvfolder pkg/client/metrics tools/metrics mvfolder pkg/client/testing/core testing +mvfolder pkg/client/testing/cache tools/cache/testing if [ "$(find "${CLIENT_REPO}"/pkg/client -type f -name "*.go")" ]; then echo "${CLIENT_REPO}/pkg/client is expected to be empty" exit 1