Exemple #1
0
func newAuthProvider(c *cli.Context) (dockerauth.AuthProvider, error) {
	awsSession := newConfigProvider(c)
	provider := dockerauth.NewMultiAuthProvider()
	provider.AddProvider(dockerauth.NewECRAuthProvider(func(region string) dockerauth.ECR {
		return ecr.New(awsSession, &aws.Config{Region: aws.String(region)})
	}))

	if dockerConfigPath := c.String(FlagDockerAuth); dockerConfigPath != "" {
		dockerConfigFile, err := os.Open(dockerConfigPath)
		if err != nil {
			return nil, err
		}

		defer dockerConfigFile.Close()

		dockerConfigProvider, err := dockerauth.NewDockerConfigAuthProvider(dockerConfigFile)
		if err != nil {
			return nil, err
		}

		provider.AddProvider(dockerConfigProvider)
	}

	return provider, nil
}
Exemple #2
0
func newClient(authProvider dockerauth.AuthProvider, c *docker.Client) (*Client, error) {
	if authProvider == nil {
		authProvider = dockerauth.NewMultiAuthProvider()
	}

	env, err := c.Version()
	if err != nil {
		return nil, fmt.Errorf("error getting Docker version: %v", err)
	}

	apiVersion, err := docker.NewAPIVersion(env.Get("ApiVersion"))
	if err != nil {
		return nil, err
	}

	return &Client{
		AuthProvider: authProvider,
		Client:       c,
		apiVersion:   apiVersion,
	}, nil
}
Exemple #3
0
func newAuthProvider(c *cli.Context) (dockerauth.AuthProvider, error) {
	provider := dockerauth.NewMultiAuthProvider()
	provider.AddProvider(dockerauth.NewECRAuthProvider(ecr.New(newConfigProvider(c))))

	if dockerConfigPath := c.String(FlagDockerAuth); dockerConfigPath != "" {
		dockerConfigFile, err := os.Open(dockerConfigPath)
		if err != nil {
			return nil, err
		}

		defer dockerConfigFile.Close()

		dockerConfigProvider, err := dockerauth.NewDockerConfigAuthProvider(dockerConfigFile)
		if err != nil {
			return nil, err
		}

		provider.AddProvider(dockerConfigProvider)
	}

	return provider, nil
}
Exemple #4
0
func newClient(authProvider dockerauth.AuthProvider, c *docker.Client) *Client {
	if authProvider == nil {
		authProvider = dockerauth.NewMultiAuthProvider()
	}
	return &Client{AuthProvider: authProvider, Client: c}
}