diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 315fe470b..469b58d7e 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,6 +1,7 @@ env: SETUP_GVM_VERSION: 'v0.5.0' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151 DOCKER_COMPOSE_VERSION: "1.25.5" # "v2.15.1" + ELASTIC_PACKAGE_COMPOSE_DISABLE_ANSI: "true" KIND_VERSION: 'v0.17.0' K8S_VERSION: 'v1.26.0' diff --git a/internal/compose/compose.go b/internal/compose/compose.go index a97a50112..99a07a497 100644 --- a/internal/compose/compose.go +++ b/internal/compose/compose.go @@ -19,6 +19,7 @@ import ( "gopkg.in/yaml.v3" "github.com/elastic/elastic-package/internal/docker" + "github.com/elastic/elastic-package/internal/environment" "github.com/elastic/elastic-package/internal/logger" "github.com/elastic/elastic-package/internal/signal" ) @@ -30,12 +31,15 @@ const ( waitForHealthyInterval = 1 * time.Second ) +var DisableANSIComposeEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_ANSI") + // Project represents a Docker Compose project. type Project struct { name string composeFilePaths []string dockerComposeV1 bool + disableANSI bool } // Config represents a Docker Compose configuration file. @@ -179,6 +183,12 @@ func NewProject(name string, paths ...string) (*Project, error) { logger.Debugf("Determined Docker Compose version: %v, the tool will use Compose V1", ver) c.dockerComposeV1 = true } + + v, ok := os.LookupEnv(DisableANSIComposeEnv) + if !c.dockerComposeV1 && ok && strings.ToLower(v) != "false" { + c.disableANSI = true + } + return &c, nil } @@ -186,6 +196,9 @@ func NewProject(name string, paths ...string) (*Project, error) { func (p *Project) Up(opts CommandOptions) error { args := p.baseArgs() args = append(args, "up") + if p.disableANSI { + args = append(args, "--quiet-pull") + } args = append(args, opts.ExtraArgs...) args = append(args, opts.Services...) @@ -364,6 +377,10 @@ func (p *Project) baseArgs() []string { args = append(args, "-f", path) } + if p.disableANSI { + args = append(args, "--ansi", "never") + } + args = append(args, "-p", p.name) return args }