azurelogin.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. Copyright 2020 Docker, Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package login
  14. import (
  15. "github.com/spf13/cobra"
  16. "github.com/docker/compose-cli/aci"
  17. )
  18. // AzureLoginCommand returns the azure login command
  19. func AzureLoginCommand() *cobra.Command {
  20. opts := aci.LoginParams{}
  21. cmd := &cobra.Command{
  22. Use: "azure",
  23. Short: "Log in to azure",
  24. Args: cobra.MaximumNArgs(0),
  25. RunE: func(cmd *cobra.Command, args []string) error {
  26. if err := opts.Validate(); err != nil {
  27. return err
  28. }
  29. return cloudLogin(cmd, "aci", opts)
  30. },
  31. }
  32. flags := cmd.Flags()
  33. flags.StringVar(&opts.TenantID, "tenant-id", "", "Specify tenant ID to use")
  34. flags.StringVar(&opts.ClientID, "client-id", "", "Client ID for Service principal login")
  35. flags.StringVar(&opts.ClientSecret, "client-secret", "", "Client secret for Service principal login")
  36. return cmd
  37. }