docker.go 993 B

123456789101112131415161718192021222324252627282930313233343536
  1. package commands
  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. func registerCommand_Docker(cliConf config.CLIConfig) *cobra.Command {
  11. dockerCmd := &cobra.Command{
  12. Use: "docker",
  13. Short: "Commands to configure Docker for a project",
  14. }
  15. configureCmd := &cobra.Command{
  16. Use: "configure",
  17. Short: "Configures the host's Docker instance",
  18. Run: func(cmd *cobra.Command, args []string) {
  19. err := checkLoginAndRunWithConfig(cmd, cliConf, args, dockerConfig)
  20. if err != nil {
  21. os.Exit(1)
  22. }
  23. },
  24. }
  25. dockerCmd.AddCommand(configureCmd)
  26. return dockerCmd
  27. }
  28. func dockerConfig(ctx context.Context, user *ptypes.GetAuthenticatedUserResponse, client api.Client, cliConf config.CLIConfig, featureFlags config.FeatureFlags, cmd *cobra.Command, args []string) error {
  29. return config.SetDockerConfig(ctx, client, cliConf.Project)
  30. }