github.com/ttys3/engine@v17.12.1-ce-rc2+incompatible/integration-cli/environment/environment.go (about)

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