Skip to content

Commit

Permalink
Merge branch 'buildpacks:main' into bugfix/jjbustamante/issue-1922
Browse files Browse the repository at this point in the history
  • Loading branch information
jjbustamante authored May 17, 2024
2 parents f833975 + 884dd18 commit 9c95d67
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion acceptance/testdata/pack_fixtures/report_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pack:
Version: {{ .Version }}
OS/Arch: {{ .OS }}/{{ .Arch }}

Default Lifecycle Version: 0.19.3
Default Lifecycle Version: 0.19.6

Supported Platform APIs: 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 0.11, 0.12, 0.13

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Microsoft/go-winio v0.6.2
github.com/apex/log v1.9.0
github.com/buildpacks/imgutil v0.0.0-20240507132533-9f7b96c3d09d
github.com/buildpacks/lifecycle v0.19.4
github.com/buildpacks/lifecycle v0.19.6
github.com/docker/cli v26.1.1+incompatible
github.com/docker/docker v26.1.1+incompatible
github.com/docker/go-connections v0.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/buildpacks/imgutil v0.0.0-20240507132533-9f7b96c3d09d h1:GVRuY/C8j4pjOddeeZelbKKLMMX+dYR3TlxE4L1hECU=
github.com/buildpacks/imgutil v0.0.0-20240507132533-9f7b96c3d09d/go.mod h1:n2R6VRuWsAX3cyHCp/u0Z4WJcixny0gYg075J39owrk=
github.com/buildpacks/lifecycle v0.19.4 h1:lATTWyMs4m4+3+n6PgvmB0lBgut2+b8eZ+iu/wXwhrI=
github.com/buildpacks/lifecycle v0.19.4/go.mod h1:sWrBJzf/7dWrcHrWiV/P2+3jS8G8Ki5tczq8jO3XVRQ=
github.com/buildpacks/lifecycle v0.19.6 h1:/bmfMs35aSkxyzYDF+iHl9VnYmUBBbHBmnvo8XNEINk=
github.com/buildpacks/lifecycle v0.19.6/go.mod h1:sWrBJzf/7dWrcHrWiV/P2+3jS8G8Ki5tczq8jO3XVRQ=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
Expand Down
2 changes: 1 addition & 1 deletion internal/builder/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// A snapshot of the latest tested lifecycle version values
const (
DefaultLifecycleVersion = "0.19.3"
DefaultLifecycleVersion = "0.19.6"
DefaultBuildpackAPIVersion = "0.2"
)

Expand Down
22 changes: 19 additions & 3 deletions pkg/blob/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,36 @@ type Logger interface {
Writer() io.Writer
}

type DownloaderOption func(d *downloader)

func WithClient(client *http.Client) DownloaderOption {
return func(d *downloader) {
d.client = client
}
}

type Downloader interface {
Download(ctx context.Context, pathOrURI string) (Blob, error)
}

type downloader struct {
logger Logger
baseCacheDir string
client *http.Client
}

func NewDownloader(logger Logger, baseCacheDir string) Downloader {
return &downloader{
func NewDownloader(logger Logger, baseCacheDir string, opts ...DownloaderOption) Downloader {
d := &downloader{
logger: logger,
baseCacheDir: baseCacheDir,
client: http.DefaultClient,
}

for _, opt := range opts {
opt(d)
}

return d
}

func (d *downloader) Download(ctx context.Context, pathOrURI string) (Blob, error) {
Expand Down Expand Up @@ -146,7 +162,7 @@ func (d *downloader) downloadAsStream(ctx context.Context, uri string, etag stri
req.Header.Set("If-None-Match", etag)
}

resp, err := (&http.Client{}).Do(req) //nolint:bodyclose
resp, err := d.client.Do(req) //nolint:bodyclose
if err != nil {
return nil, "", err
}
Expand Down

0 comments on commit 9c95d67

Please sign in to comment.