diff --git a/azure/backend.go b/azure/backend.go index e6c2e78e6..d8b7fb482 100644 --- a/azure/backend.go +++ b/azure/backend.go @@ -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 { diff --git a/azure/login/login.go b/azure/login/login.go index 7117ccb76..59dd3cd87 100644 --- a/azure/login/login.go +++ b/azure/login/login.go @@ -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 ( diff --git a/cli/cmd/login/azurelogin.go b/cli/cmd/login/azurelogin.go index 8c7e7824f..00d795003 100644 --- a/cli/cmd/login/azurelogin.go +++ b/cli/cmd/login/azurelogin.go @@ -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 } diff --git a/cli/cmd/login/login.go b/cli/cmd/login/login.go index 79dc912f4..0fee72222 100644 --- a/cli/cmd/login/login.go +++ b/cli/cmd/login/login.go @@ -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 { diff --git a/context/cloud/api.go b/context/cloud/api.go index 87d4c40f8..84c2c242f 100644 --- a/context/cloud/api.go +++ b/context/cloud/api.go @@ -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 }