Skip to content

Commit

Permalink
fixed linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rashadism committed Apr 1, 2024
1 parent 81dad56 commit ab68c2e
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

Check warning on line 472 in pkg/client/create_builder.go

View check run for this annotation

Codecov / codecov/patch

pkg/client/create_builder.go#L469-L472

Added lines #L469 - L472 were not covered by tests
}

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
}

Check warning on line 479 in pkg/client/create_builder.go

View check run for this annotation

Codecov / codecov/patch

pkg/client/create_builder.go#L475-L479

Added lines #L475 - L479 were not covered by tests

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
}

Check warning on line 484 in pkg/client/create_builder.go

View check run for this annotation

Codecov / codecov/patch

pkg/client/create_builder.go#L481-L484

Added lines #L481 - L484 were not covered by tests
Expand Down

0 comments on commit ab68c2e

Please sign in to comment.