Skip to content

Commit

Permalink
fixed linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: Rashad Sirajudeen <[email protected]>
  • Loading branch information
rashadism committed Apr 1, 2024
1 parent b06c29c commit fca6909
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions pkg/client/create_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"io"
"os"
OS "os"
"path/filepath"
"sort"
"strings"
Expand Down Expand Up @@ -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",
Expand All @@ -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)
Expand All @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit fca6909

Please sign in to comment.