flags.go 858 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package context
  2. import (
  3. "path/filepath"
  4. "github.com/mitchellh/go-homedir"
  5. "github.com/urfave/cli"
  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. EnvVar: "DOCKER_CONFIG",
  19. Value: filepath.Join(home(), configFileDir),
  20. Destination: &ConfigDir,
  21. }
  22. ContextFlag = cli.StringFlag{
  23. Name: "context, c",
  24. 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\")",
  25. EnvVar: "DOCKER_CONTEXT",
  26. Destination: &ContextName,
  27. }
  28. )
  29. func home() string {
  30. home, _ := homedir.Dir()
  31. return home
  32. }