From 06c5d8a902c59938c3bd123c1f16fb7fada45350 Mon Sep 17 00:00:00 2001 From: Ulysses Souza Date: Sun, 31 Oct 2021 02:01:30 +0200 Subject: [PATCH] Refactoring Signed-off-by: Ulysses Souza --- pkg/compose/build_classic.go | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/pkg/compose/build_classic.go b/pkg/compose/build_classic.go index b63f3d36..ed12ccd2 100644 --- a/pkg/compose/build_classic.go +++ b/pkg/compose/build_classic.go @@ -114,7 +114,7 @@ func (s *composeService) doBuildClassicSimpleImage(ctx context.Context, options } if err := build.ValidateContextDirectory(contextDir, excludes); err != nil { - return "", errors.Errorf("error checking context: '%s'.", err) + return "", errors.Wrap(err, "checking context") } // And canonicalize dockerfile name to a platform-independent one @@ -123,7 +123,7 @@ func (s *composeService) doBuildClassicSimpleImage(ctx context.Context, options excludes = build.TrimBuildFilesFromExcludes(excludes, relDockerfile, false) buildCtx, err = archive.TarWithOptions(contextDir, &archive.TarOptions{ ExcludePatterns: excludes, - ChownOpts: &idtools.Identity{UID: 0, GID: 0}, + ChownOpts: &idtools.Identity{}, }) if err != nil { return "", err @@ -156,7 +156,10 @@ func (s *composeService) doBuildClassicSimpleImage(ctx context.Context, options } configFile := s.configFile - creds, _ := configFile.GetAllCredentials() + creds, err := configFile.GetAllCredentials() + if err != nil { + return "", err + } authConfigs := make(map[string]dockertypes.AuthConfig, len(creds)) for k, auth := range creds { authConfigs[k] = dockertypes.AuthConfig(auth) @@ -240,24 +243,7 @@ func imageBuildOptions(options buildx.Options) dockertypes.ImageBuildOptions { func toMapStringStringPtr(source map[string]string) map[string]*string { dest := make(map[string]*string) for k, v := range source { - v := v dest[k] = &v } return dest } - -// lastProgressOutput is the same as progress.Output except -// that it only output with the last update. It is used in -// non terminal scenarios to suppress verbose messages -type lastProgressOutput struct { - output progress.Output -} - -// WriteProgress formats progress information from a ProgressReader. -func (out *lastProgressOutput) WriteProgress(prog progress.Progress) error { - if !prog.LastUpdate { - return nil - } - - return out.output.WriteProgress(prog) -}