flags.go 908 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package context
  2. import (
  3. "path/filepath"
  4. "github.com/mitchellh/go-homedir"
  5. "github.com/urfave/cli/v2"
  6. )
  7. const (
  8. // ConfigFileName is the name of config file
  9. ConfigFileName = "config.json"
  10. configFileDir = ".docker"
  11. )
  12. var (
  13. ConfigDir string
  14. ContextName string
  15. ConfigFlag = cli.StringFlag{
  16. Name: "config",
  17. Usage: "Location of client config files `DIRECTORY`",
  18. EnvVars: []string{"DOCKER_CONFIG"},
  19. Value: filepath.Join(home(), configFileDir),
  20. Destination: &ConfigDir,
  21. }
  22. ContextFlag = cli.StringFlag{
  23. Name: "context",
  24. Aliases: []string{"c"},
  25. Usage: "Name of the context `CONTEXT` to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with \"docker context use\")",
  26. EnvVars: []string{"DOCKER_CONTEXT"},
  27. Destination: &ContextName,
  28. }
  29. )
  30. func home() string {
  31. home, _ := homedir.Dir()
  32. return home
  33. }