Skip to content

Commit

Permalink
fix(logging): simplify logs, remove excess messages
Browse files Browse the repository at this point in the history
- hide push image layer messages when using Buildah mode (show in verbose);

- hide synchronization messages (show in verbose);

Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Jan 27, 2023
1 parent 67aa79b commit 1d75db1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cmd/werf/common/synchronization.go
Expand Up @@ -132,13 +132,13 @@ func GetSynchronization(ctx context.Context, cmdData *CmdData, projectName strin

getHttpParamsFunc := func(synchronization string, stagesStorage storage.StagesStorage) (*SynchronizationParams, error) {
var address string
if err := logboek.Default().LogProcess(fmt.Sprintf("Getting client id for the http synchronization server")).
if err := logboek.Info().LogProcess(fmt.Sprintf("Getting client id for the http synchronization server")).
DoError(func() error {
if clientID, err := synchronization_server.GetOrCreateClientID(ctx, projectName, synchronization_server.NewSynchronizationClient(synchronization), stagesStorage); err != nil {
return fmt.Errorf("unable to get synchronization client id: %w", err)
} else {
address = fmt.Sprintf("%s/%s", synchronization, clientID)
logboek.Default().LogF("Using clientID %q for http synchronization server at address %s\n", clientID, address)
logboek.Info().LogF("Using clientID %q for http synchronization server at address %s\n", clientID, address)
return nil
}
}); err != nil {
Expand Down
28 changes: 24 additions & 4 deletions pkg/container_backend/buildah_backend.go
Expand Up @@ -586,29 +586,49 @@ func (runtime *BuildahBackend) GetImageInfo(ctx context.Context, ref string, opt
}

func (runtime *BuildahBackend) Rmi(ctx context.Context, ref string, opts RmiOpts) error {
var logWriter io.Writer
if logboek.Context(ctx).Info().IsAccepted() {
logWriter = logboek.Context(ctx).OutStream()
}

return runtime.buildah.Rmi(ctx, ref, buildah.RmiOpts{
Force: true,
CommonOpts: buildah.CommonOpts{
LogWriter: logboek.Context(ctx).OutStream(),
LogWriter: logWriter,
},
})
}

func (runtime *BuildahBackend) Pull(ctx context.Context, ref string, opts PullOpts) error {
var logWriter io.Writer
if logboek.Context(ctx).Info().IsAccepted() {
logWriter = logboek.Context(ctx).OutStream()
}

return runtime.buildah.Pull(ctx, ref, buildah.PullOpts{
LogWriter: logboek.Context(ctx).OutStream(),
LogWriter: logWriter,
})
}

func (runtime *BuildahBackend) Tag(ctx context.Context, ref, newRef string, opts TagOpts) error {
var logWriter io.Writer
if logboek.Context(ctx).Info().IsAccepted() {
logWriter = logboek.Context(ctx).OutStream()
}

return runtime.buildah.Tag(ctx, ref, newRef, buildah.TagOpts{
LogWriter: logboek.Context(ctx).OutStream(),
LogWriter: logWriter,
})
}

func (runtime *BuildahBackend) Push(ctx context.Context, ref string, opts PushOpts) error {
var logWriter io.Writer
if logboek.Context(ctx).Info().IsAccepted() {
logWriter = logboek.Context(ctx).OutStream()
}

return runtime.buildah.Push(ctx, ref, buildah.PushOpts{
LogWriter: logboek.Context(ctx).OutStream(),
LogWriter: logWriter,
})
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/bundles/publish.go
Expand Up @@ -20,7 +20,7 @@ func Publish(ctx context.Context, bundle *chart_extender.Bundle, bundleRef strin

loader.GlobalLoadOptions = &loader.LoadOptions{}

if err := logboek.Context(ctx).LogProcess("Saving bundle to the local chart helm cache").DoError(func() error {
if err := logboek.Context(ctx).Default().LogProcess("Saving bundle to the local chart helm cache").DoError(func() error {
path, err := filepath.Abs(bundle.Dir)
if err != nil {
return err
Expand Down

0 comments on commit 1d75db1

Please sign in to comment.