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