environment.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package environment
  2. import (
  3. "os"
  4. "os/exec"
  5. "github.com/docker/docker/internal/test/environment"
  6. )
  7. var (
  8. // DefaultClientBinary is the name of the docker binary
  9. DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
  10. )
  11. func init() {
  12. if DefaultClientBinary == "" {
  13. DefaultClientBinary = "docker"
  14. }
  15. }
  16. // Execution contains information about the current test execution and daemon
  17. // under test
  18. type Execution struct {
  19. environment.Execution
  20. dockerBinary string
  21. }
  22. // DockerBinary returns the docker binary for this testing environment
  23. func (e *Execution) DockerBinary() string {
  24. return e.dockerBinary
  25. }
  26. // New returns details about the testing environment
  27. func New() (*Execution, error) {
  28. env, err := environment.New()
  29. if err != nil {
  30. return nil, err
  31. }
  32. dockerBinary, err := exec.LookPath(DefaultClientBinary)
  33. if err != nil {
  34. return nil, err
  35. }
  36. return &Execution{
  37. Execution: *env,
  38. dockerBinary: dockerBinary,
  39. }, nil
  40. }
  41. // DockerBasePath is the base path of the docker folder (by default it is -/var/run/docker)
  42. // TODO: remove
  43. // Deprecated: use Execution.DaemonInfo.DockerRootDir
  44. func (e *Execution) DockerBasePath() string {
  45. return e.DaemonInfo.DockerRootDir
  46. }
  47. // ExperimentalDaemon tell whether the main daemon has
  48. // experimental features enabled or not
  49. // Deprecated: use DaemonInfo.ExperimentalBuild
  50. func (e *Execution) ExperimentalDaemon() bool {
  51. return e.DaemonInfo.ExperimentalBuild
  52. }
  53. // DaemonPlatform is held globally so that tests can make intelligent
  54. // decisions on how to configure themselves according to the platform
  55. // of the daemon. This is initialized in docker_utils by sending
  56. // a version call to the daemon and examining the response header.
  57. // Deprecated: use Execution.OSType
  58. func (e *Execution) DaemonPlatform() string {
  59. return e.OSType
  60. }
  61. // MinimalBaseImage is the image used for minimal builds (it depends on the platform)
  62. // Deprecated: use Execution.PlatformDefaults.BaseImage
  63. func (e *Execution) MinimalBaseImage() string {
  64. return e.PlatformDefaults.BaseImage
  65. }