Skip to content

Commit 8a95967

Browse files
authored
Clean docker-compose log from output (#1330)
Remove progress information from docker-compose pull/up commands, being able to enable or disable it through an environment variable
1 parent 38a31f8 commit 8a95967

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ env:
22
SETUP_GVM_VERSION: 'v0.5.0' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151
33
DOCKER_COMPOSE_VERSION: "v2.17.2"
44
ELASTIC_PACKAGE_COMPOSE_DISABLE_ANSI: "true"
5+
ELASTIC_PACKAGE_COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION: "true"
56
KIND_VERSION: 'v0.17.0'
67
K8S_VERSION: 'v1.26.0'
78

internal/compose/compose.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@ const (
3232
waitForHealthyInterval = 1 * time.Second
3333
)
3434

35-
var DisableANSIComposeEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_ANSI")
35+
var (
36+
DisableANSIComposeEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_ANSI")
37+
DisablePullProgressInformationEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION")
38+
)
3639

3740
// Project represents a Docker Compose project.
3841
type Project struct {
3942
name string
4043
composeFilePaths []string
4144

42-
dockerComposeV1 bool
43-
disableANSI bool
45+
dockerComposeV1 bool
46+
disableANSI bool
47+
disablePullProgressInformation bool
4448
}
4549

4650
// Config represents a Docker Compose configuration file.
@@ -193,14 +197,19 @@ func NewProject(name string, paths ...string) (*Project, error) {
193197
c.disableANSI = true
194198
}
195199

200+
v, ok = os.LookupEnv(DisablePullProgressInformationEnv)
201+
if ok && strings.ToLower(v) != "false" {
202+
c.disablePullProgressInformation = true
203+
}
204+
196205
return &c, nil
197206
}
198207

199208
// Up brings up a Docker Compose project.
200209
func (p *Project) Up(opts CommandOptions) error {
201210
args := p.baseArgs()
202211
args = append(args, "up")
203-
if p.disableANSI {
212+
if p.disablePullProgressInformation {
204213
args = append(args, "--quiet-pull")
205214
}
206215
args = append(args, opts.ExtraArgs...)
@@ -278,6 +287,9 @@ func (p *Project) Config(opts CommandOptions) (*Config, error) {
278287
func (p *Project) Pull(opts CommandOptions) error {
279288
args := p.baseArgs()
280289
args = append(args, "pull")
290+
if p.disablePullProgressInformation {
291+
args = append(args, "--quiet")
292+
}
281293
args = append(args, opts.ExtraArgs...)
282294
args = append(args, opts.Services...)
283295

internal/stack/compose.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/elastic/elastic-package/internal/compose"
1212
"github.com/elastic/elastic-package/internal/docker"
1313
"github.com/elastic/elastic-package/internal/install"
14-
"github.com/elastic/elastic-package/internal/logger"
1514
)
1615

1716
type ServiceStatus struct {
@@ -205,7 +204,6 @@ func dockerComposeStatus() ([]ServiceStatus, error) {
205204
if err != nil {
206205
return nil, err
207206
}
208-
logger.Debugf("Adding Service: \"%v\"", service.Name)
209207
services = append(services, *service)
210208
}
211209

0 commit comments

Comments
 (0)