mirror of https://github.com/docker/compose.git
Also remove map[string]string for azure login (tenantId param)
This commit is contained in:
parent
97d408d25d
commit
43b54ef75a
|
@ -23,6 +23,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
clilogin "github.com/docker/api/cli/cmd/login"
|
||||
|
||||
acicontext "github.com/docker/api/cli/cmd/context"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance"
|
||||
|
@ -353,8 +355,9 @@ type aciCloudService struct {
|
|||
loginService login.AzureLoginService
|
||||
}
|
||||
|
||||
func (cs *aciCloudService) Login(ctx context.Context, params map[string]string) error {
|
||||
return cs.loginService.Login(ctx, params[login.TenantIDLoginParam])
|
||||
func (cs *aciCloudService) Login(ctx context.Context, params interface{}) error {
|
||||
createOpts := params.(clilogin.AzureLoginOpts)
|
||||
return cs.loginService.Login(ctx, createOpts.TenantID)
|
||||
}
|
||||
|
||||
func (cs *aciCloudService) Logout(ctx context.Context) error {
|
||||
|
|
|
@ -45,9 +45,6 @@ const (
|
|||
// v1 scope like "https://management.azure.com/.default" for ARM access
|
||||
scopes = "offline_access https://management.azure.com/.default"
|
||||
clientID = "04b07795-8ddb-461a-bbee-02f9e1bf7b46" // Azure CLI client id
|
||||
|
||||
// TenantIDLoginParam
|
||||
TenantIDLoginParam = "tenantId"
|
||||
)
|
||||
|
||||
type (
|
||||
|
|
|
@ -2,27 +2,26 @@ package login
|
|||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/api/azure/login"
|
||||
)
|
||||
|
||||
type azureLoginOpts struct {
|
||||
tenantID string
|
||||
// AzureLoginOpts azure login options
|
||||
type AzureLoginOpts struct {
|
||||
TenantID string
|
||||
}
|
||||
|
||||
// AzureLoginCommand returns the azure login command
|
||||
func AzureLoginCommand() *cobra.Command {
|
||||
opts := azureLoginOpts{}
|
||||
opts := AzureLoginOpts{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "azure",
|
||||
Short: "Log in to azure",
|
||||
Args: cobra.MaximumNArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return cloudLogin(cmd, "aci", map[string]string{login.TenantIDLoginParam: opts.tenantID})
|
||||
return cloudLogin(cmd, "aci", opts)
|
||||
},
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
flags.StringVar(&opts.tenantID, "tenant-id", "", "Specify tenant ID to use from your azure account")
|
||||
flags.StringVar(&opts.TenantID, "tenant-id", "", "Specify tenant ID to use from your azure account")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ func runLogin(cmd *cobra.Command, args []string) error {
|
|||
return mobycli.ExecCmd(cmd)
|
||||
}
|
||||
|
||||
func cloudLogin(cmd *cobra.Command, backendType string, params map[string]string) error {
|
||||
func cloudLogin(cmd *cobra.Command, backendType string, params interface{}) error {
|
||||
ctx := cmd.Context()
|
||||
cs, err := client.GetCloudService(ctx, backendType)
|
||||
if err != nil {
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// Service cloud specific services
|
||||
type Service interface {
|
||||
// Login login to cloud provider
|
||||
Login(ctx context.Context, params map[string]string) error
|
||||
Login(ctx context.Context, params interface{}) error
|
||||
// Logout logout from cloud provider
|
||||
Logout(ctx context.Context) error
|
||||
// CreateContextData create data for cloud context
|
||||
|
@ -45,7 +45,7 @@ func (cs notImplementedCloudService) Logout(ctx context.Context) error {
|
|||
return errdefs.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs notImplementedCloudService) Login(ctx context.Context, params map[string]string) error {
|
||||
func (cs notImplementedCloudService) Login(ctx context.Context, params interface{}) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue