github.com/rish1988/moby@v25.0.2+incompatible/integration-cli/environment/environment.go (about)

     1  package environment // import "github.com/docker/docker/integration-cli/environment"
     2  
     3  import (
     4  	"context"
     5  	"os"
     6  	"os/exec"
     7  
     8  	"github.com/docker/docker/testutil/environment"
     9  )
    10  
    11  // DefaultClientBinary is the name of the docker binary
    12  var DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
    13  
    14  func init() {
    15  	if DefaultClientBinary == "" {
    16  		DefaultClientBinary = "docker"
    17  	}
    18  }
    19  
    20  // Execution contains information about the current test execution and daemon
    21  // under test
    22  type Execution struct {
    23  	environment.Execution
    24  	dockerBinary string
    25  }
    26  
    27  // DockerBinary returns the docker binary for this testing environment
    28  func (e *Execution) DockerBinary() string {
    29  	return e.dockerBinary
    30  }
    31  
    32  // New returns details about the testing environment
    33  func New(ctx context.Context) (*Execution, error) {
    34  	env, err := environment.New(ctx)
    35  	if err != nil {
    36  		return nil, err
    37  	}
    38  
    39  	dockerBinary, err := exec.LookPath(DefaultClientBinary)
    40  	if err != nil {
    41  		return nil, err
    42  	}
    43  
    44  	return &Execution{
    45  		Execution:    *env,
    46  		dockerBinary: dockerBinary,
    47  	}, nil
    48  }