docker.go 874 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package cmd
  2. import (
  3. "context"
  4. "os"
  5. api "github.com/porter-dev/porter/api/client"
  6. ptypes "github.com/porter-dev/porter/api/types"
  7. "github.com/porter-dev/porter/cli/cmd/config"
  8. "github.com/spf13/cobra"
  9. )
  10. var dockerCmd = &cobra.Command{
  11. Use: "docker",
  12. Short: "Commands to configure Docker for a project",
  13. }
  14. var configureCmd = &cobra.Command{
  15. Use: "configure",
  16. Short: "Configures the host's Docker instance",
  17. Run: func(cmd *cobra.Command, args []string) {
  18. err := checkLoginAndRun(cmd.Context(), args, dockerConfig)
  19. if err != nil {
  20. os.Exit(1)
  21. }
  22. },
  23. }
  24. func init() {
  25. rootCmd.AddCommand(dockerCmd)
  26. dockerCmd.AddCommand(configureCmd)
  27. }
  28. func dockerConfig(ctx context.Context, user *ptypes.GetAuthenticatedUserResponse, client api.Client, cliConf config.CLIConfig, args []string) error {
  29. return config.SetDockerConfig(ctx, client, cliConf.Project)
  30. }