diff --git a/pkg/client/create_builder.go b/pkg/client/create_builder.go index e33e0dbac..81337dacb 100644 --- a/pkg/client/create_builder.go +++ b/pkg/client/create_builder.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "os" - OS "os" "path/filepath" "sort" "strings" @@ -209,7 +208,7 @@ func (c *Client) createBaseBuilder(ctx context.Context, opts CreateBuilderOption return bldr, nil } -func (c *Client) fetchLifecycle(ctx context.Context, config pubbldr.LifecycleConfig, relativeBaseDir, os string, architecture string) (builder.Lifecycle, error) { +func (c *Client) fetchLifecycle(ctx context.Context, config pubbldr.LifecycleConfig, relativeBaseDir, o string, architecture string) (builder.Lifecycle, error) { if config.Version != "" && config.URI != "" { return nil, errors.Errorf( "%s can only declare %s or %s, not both", @@ -220,7 +219,7 @@ func (c *Client) fetchLifecycle(ctx context.Context, config pubbldr.LifecycleCon var uri string var err error switch { - case isDockerUri(config.URI): + case isDockerURI(config.URI): var lifecycleImage imgutil.Image var blob blob.Blob imageName := buildpack.ParsePackageLocator(config.URI) @@ -237,7 +236,7 @@ func (c *Client) fetchLifecycle(ctx context.Context, config pubbldr.LifecycleCon return nil, err } defer lifecycleImageReader.Close() - lifecycleImageWriter, err := OS.Create(lifecycleImageTar) + lifecycleImageWriter, err := os.Create(lifecycleImageTar) if err != nil { return nil, err } @@ -285,14 +284,14 @@ func (c *Client) fetchLifecycle(ctx context.Context, config pubbldr.LifecycleCon return nil, errors.Wrapf(err, "%s must be a valid semver", style.Symbol("lifecycle.version")) } - uri = uriFromLifecycleVersion(*v, os, architecture) + uri = uriFromLifecycleVersion(*v, o, architecture) case config.URI != "": uri, err = paths.FilePathToURI(config.URI, relativeBaseDir) if err != nil { return nil, err } default: - uri = uriFromLifecycleVersion(*semver.MustParse(builder.DefaultLifecycleVersion), os, architecture) + uri = uriFromLifecycleVersion(*semver.MustParse(builder.DefaultLifecycleVersion), o, architecture) } blob, err := c.downloader.Download(ctx, uri) @@ -429,8 +428,8 @@ func uriFromLifecycleVersion(version semver.Version, os string, architecture str return fmt.Sprintf("https://github.com/buildpacks/lifecycle/releases/download/v%s/lifecycle-v%s+linux.%s.tgz", version.String(), version.String(), arch) } -func isDockerUri(URI string) bool { - return strings.HasPrefix(URI, fromDockerPrefix) +func isDockerURI(uri string) bool { + return strings.HasPrefix(uri, fromDockerPrefix) } func stripTopLevelDir(inputTarFile string) (string, error) { @@ -473,15 +472,13 @@ func stripTopLevelDir(inputTarFile string) (string, error) { continue } - if strings.HasPrefix(header.Name, topLevelDirName) { - header.Name = strings.TrimPrefix(header.Name, topLevelDirName) - } + header.Name = strings.TrimPrefix(header.Name, topLevelDirName) if err := tarWriter.WriteHeader(header); err != nil { return "", err } - if header.Typeflag == tar.TypeReg || header.Typeflag == tar.TypeRegA { + if header.Typeflag == tar.TypeReg { if _, err := io.CopyBuffer(tarWriter, tarReader, buf); err != nil { return "", err }