From 4a4db358a332ded599d6608764b28c8598538280 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 13 Dec 2019 10:18:06 +0100 Subject: [PATCH] =?UTF-8?q?Separate=20credentialprovider=20into=20files=20?= =?UTF-8?q?with=20buildtag=20=F0=9F=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each files for each provider (aws, azure, gcp, …) have a "negative" build tag, this means by default, no behaviour change, they are all compiled — but they can be disabled using `disable-…`. This allows a library to depend on k8schain but not having those automatic import, or at least choose the one to enable/disable. Signed-off-by: Vincent Demeester --- pkg/authn/k8schain/k8schain.go | 8 -------- pkg/authn/k8schain/k8schain_aws.go | 21 +++++++++++++++++++++ pkg/authn/k8schain/k8schain_azure.go | 21 +++++++++++++++++++++ pkg/authn/k8schain/k8schain_gcp.go | 21 +++++++++++++++++++++ 4 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 pkg/authn/k8schain/k8schain_aws.go create mode 100644 pkg/authn/k8schain/k8schain_azure.go create mode 100644 pkg/authn/k8schain/k8schain_gcp.go diff --git a/pkg/authn/k8schain/k8schain.go b/pkg/authn/k8schain/k8schain.go index 8c28f5eaf..9e0ccd660 100644 --- a/pkg/authn/k8schain/k8schain.go +++ b/pkg/authn/k8schain/k8schain.go @@ -23,14 +23,6 @@ import ( "k8s.io/client-go/rest" "k8s.io/kubernetes/pkg/credentialprovider" credentialprovidersecrets "k8s.io/kubernetes/pkg/credentialprovider/secrets" - - // Credential providers - _ "k8s.io/kubernetes/pkg/credentialprovider/aws" - _ "k8s.io/kubernetes/pkg/credentialprovider/azure" - _ "k8s.io/kubernetes/pkg/credentialprovider/gcp" - // TODO(mattmoor): This doesn't seem to build, figure out why `dep ensure` - // is not working and add constraints. - // _ "k8s.io/kubernetes/pkg/credentialprovider/rancher" ) // Options holds configuration data for guiding credential resolution. diff --git a/pkg/authn/k8schain/k8schain_aws.go b/pkg/authn/k8schain/k8schain_aws.go new file mode 100644 index 000000000..57ef1853d --- /dev/null +++ b/pkg/authn/k8schain/k8schain_aws.go @@ -0,0 +1,21 @@ +// +build !disable_aws +// Copyright 2019 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package k8schain + +import ( + // aws credential provider + _ "k8s.io/kubernetes/pkg/credentialprovider/aws" +) diff --git a/pkg/authn/k8schain/k8schain_azure.go b/pkg/authn/k8schain/k8schain_azure.go new file mode 100644 index 000000000..a9710ef6b --- /dev/null +++ b/pkg/authn/k8schain/k8schain_azure.go @@ -0,0 +1,21 @@ +// +build !disable_azure +// Copyright 2019 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package k8schain + +import ( + // azure credential provider + _ "k8s.io/kubernetes/pkg/credentialprovider/azure" +) diff --git a/pkg/authn/k8schain/k8schain_gcp.go b/pkg/authn/k8schain/k8schain_gcp.go new file mode 100644 index 000000000..cb8e1f8b6 --- /dev/null +++ b/pkg/authn/k8schain/k8schain_gcp.go @@ -0,0 +1,21 @@ +// +build !disable_gcp +// Copyright 2019 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package k8schain + +import ( + // gcp credential provider + _ "k8s.io/kubernetes/pkg/credentialprovider/gcp" +)