mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
vendor update for CSI 0.3.0
This commit is contained in:
4
vendor/k8s.io/kubernetes/pkg/credentialprovider/azure/BUILD
generated
vendored
4
vendor/k8s.io/kubernetes/pkg/credentialprovider/azure/BUILD
generated
vendored
@ -16,7 +16,7 @@ go_library(
|
||||
deps = [
|
||||
"//pkg/cloudprovider/providers/azure/auth:go_default_library",
|
||||
"//pkg/credentialprovider:go_default_library",
|
||||
"//vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry:go_default_library",
|
||||
"//vendor/github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry:go_default_library",
|
||||
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
|
||||
"//vendor/github.com/Azure/go-autorest/autorest/adal:go_default_library",
|
||||
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",
|
||||
@ -32,7 +32,7 @@ go_test(
|
||||
srcs = ["azure_credentials_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry:go_default_library",
|
||||
"//vendor/github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry:go_default_library",
|
||||
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
|
||||
],
|
||||
)
|
||||
|
57
vendor/k8s.io/kubernetes/pkg/credentialprovider/azure/azure_credentials.go
generated
vendored
57
vendor/k8s.io/kubernetes/pkg/credentialprovider/azure/azure_credentials.go
generated
vendored
@ -17,18 +17,20 @@ limitations under the License.
|
||||
package azure
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/arm/containerregistry"
|
||||
"github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/adal"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/azure/auth"
|
||||
"k8s.io/kubernetes/pkg/credentialprovider"
|
||||
)
|
||||
@ -48,9 +50,46 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
func getContextWithCancel() (context.Context, context.CancelFunc) {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
|
||||
// RegistriesClient is a testable interface for the ACR client List operation.
|
||||
type RegistriesClient interface {
|
||||
List() (containerregistry.RegistryListResult, error)
|
||||
List(ctx context.Context) ([]containerregistry.Registry, error)
|
||||
}
|
||||
|
||||
// azRegistriesClient implements RegistriesClient.
|
||||
type azRegistriesClient struct {
|
||||
client containerregistry.RegistriesClient
|
||||
}
|
||||
|
||||
func newAzRegistriesClient(subscriptionID, endpoint string, token *adal.ServicePrincipalToken) *azRegistriesClient {
|
||||
registryClient := containerregistry.NewRegistriesClient(subscriptionID)
|
||||
registryClient.BaseURI = endpoint
|
||||
registryClient.Authorizer = autorest.NewBearerAuthorizer(token)
|
||||
|
||||
return &azRegistriesClient{
|
||||
client: registryClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (az *azRegistriesClient) List(ctx context.Context) ([]containerregistry.Registry, error) {
|
||||
iterator, err := az.client.ListComplete(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]containerregistry.Registry, 0)
|
||||
for ; iterator.NotDone(); err = iterator.Next() {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result = append(result, iterator.Value())
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// NewACRProvider parses the specified configFile and returns a DockerConfigProvider
|
||||
@ -128,26 +167,24 @@ func (a *acrProvider) Enabled() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
registryClient := containerregistry.NewRegistriesClient(a.config.SubscriptionID)
|
||||
registryClient.BaseURI = a.environment.ResourceManagerEndpoint
|
||||
registryClient.Authorizer = autorest.NewBearerAuthorizer(a.servicePrincipalToken)
|
||||
a.registryClient = registryClient
|
||||
|
||||
a.registryClient = newAzRegistriesClient(a.config.SubscriptionID, a.environment.ResourceManagerEndpoint, a.servicePrincipalToken)
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *acrProvider) Provide() credentialprovider.DockerConfig {
|
||||
cfg := credentialprovider.DockerConfig{}
|
||||
ctx, cancel := getContextWithCancel()
|
||||
defer cancel()
|
||||
|
||||
glog.V(4).Infof("listing registries")
|
||||
res, err := a.registryClient.List()
|
||||
result, err := a.registryClient.List(ctx)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to list registries: %v", err)
|
||||
return cfg
|
||||
}
|
||||
|
||||
for ix := range *res.Value {
|
||||
loginServer := getLoginServer((*res.Value)[ix])
|
||||
for ix := range result {
|
||||
loginServer := getLoginServer(result[ix])
|
||||
var cred *credentialprovider.DockerConfigEntry
|
||||
|
||||
if a.config.UseManagedIdentityExtension {
|
||||
|
45
vendor/k8s.io/kubernetes/pkg/credentialprovider/azure/azure_credentials_test.go
generated
vendored
45
vendor/k8s.io/kubernetes/pkg/credentialprovider/azure/azure_credentials_test.go
generated
vendored
@ -18,17 +18,18 @@ package azure
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/arm/containerregistry"
|
||||
"github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry"
|
||||
"github.com/Azure/go-autorest/autorest/to"
|
||||
)
|
||||
|
||||
type fakeClient struct {
|
||||
results containerregistry.RegistryListResult
|
||||
results []containerregistry.Registry
|
||||
}
|
||||
|
||||
func (f *fakeClient) List() (containerregistry.RegistryListResult, error) {
|
||||
func (f *fakeClient) List(ctx context.Context) ([]containerregistry.Registry, error) {
|
||||
return f.results, nil
|
||||
}
|
||||
|
||||
@ -38,25 +39,23 @@ func Test(t *testing.T) {
|
||||
"aadClientId": "foo",
|
||||
"aadClientSecret": "bar"
|
||||
}`
|
||||
result := containerregistry.RegistryListResult{
|
||||
Value: &[]containerregistry.Registry{
|
||||
{
|
||||
Name: to.StringPtr("foo"),
|
||||
RegistryProperties: &containerregistry.RegistryProperties{
|
||||
LoginServer: to.StringPtr("foo-microsoft.azurecr.io"),
|
||||
},
|
||||
result := []containerregistry.Registry{
|
||||
{
|
||||
Name: to.StringPtr("foo"),
|
||||
RegistryProperties: &containerregistry.RegistryProperties{
|
||||
LoginServer: to.StringPtr("foo-microsoft.azurecr.io"),
|
||||
},
|
||||
{
|
||||
Name: to.StringPtr("bar"),
|
||||
RegistryProperties: &containerregistry.RegistryProperties{
|
||||
LoginServer: to.StringPtr("bar-microsoft.azurecr.io"),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: to.StringPtr("bar"),
|
||||
RegistryProperties: &containerregistry.RegistryProperties{
|
||||
LoginServer: to.StringPtr("bar-microsoft.azurecr.io"),
|
||||
},
|
||||
{
|
||||
Name: to.StringPtr("baz"),
|
||||
RegistryProperties: &containerregistry.RegistryProperties{
|
||||
LoginServer: to.StringPtr("baz-microsoft.azurecr.io"),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: to.StringPtr("baz"),
|
||||
RegistryProperties: &containerregistry.RegistryProperties{
|
||||
LoginServer: to.StringPtr("baz-microsoft.azurecr.io"),
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -71,8 +70,8 @@ func Test(t *testing.T) {
|
||||
|
||||
creds := provider.Provide()
|
||||
|
||||
if len(creds) != len(*result.Value) {
|
||||
t.Errorf("Unexpected list: %v, expected length %d", creds, len(*result.Value))
|
||||
if len(creds) != len(result) {
|
||||
t.Errorf("Unexpected list: %v, expected length %d", creds, len(result))
|
||||
}
|
||||
for _, cred := range creds {
|
||||
if cred.Username != "foo" {
|
||||
@ -82,7 +81,7 @@ func Test(t *testing.T) {
|
||||
t.Errorf("expected 'bar' for password, saw: %v", cred.Username)
|
||||
}
|
||||
}
|
||||
for _, val := range *result.Value {
|
||||
for _, val := range result {
|
||||
registryName := getLoginServer(val)
|
||||
if _, found := creds[registryName]; !found {
|
||||
t.Errorf("Missing expected registry: %s", registryName)
|
||||
|
Reference in New Issue
Block a user