Skip to content

Commit

Permalink
Allow specifying platform as part of download
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-cmsoft committed Dec 2, 2024
1 parent 11b4332 commit 94c84d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func Test_UploadCmd_ValidateArgs_Response(t *testing.T) {
if err != nil {
t.Errorf("uploadCmd.validateArgs() error = %v", err)
}
if config.directory != path.Join(workDir, validDirectory) {
if config.source != path.Join(workDir, validDirectory) {
t.Errorf("uploadCmd.validateArgs() config = %v", config)
}
})
Expand Down
9 changes: 2 additions & 7 deletions pkg/oci/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import (
"archive/tar"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/remote"
"io"
"os"
"path"
"path/filepath"
"runtime"
)

type Downloader struct {
Expand All @@ -30,14 +28,11 @@ func NewDownloader(source name.Tag, destination string) (Downloader, error) {
// Download executes the download of the OCI artifact into memory, untars it and write it to a directory.
// This will need to be updated at some point when we are working with OCI artifacts rather than images,
// to take slightly different actions based on the artifact type we receive from the registry (image / binary / fs)
func (dl *Downloader) Download() error {
func (dl *Downloader) Download(option ...remote.Option) error {
opts := []remote.Option{
remote.WithAuthFromKeychain(authn.DefaultKeychain),
remote.WithPlatform(v1.Platform{
Architecture: runtime.GOARCH,
OS: runtime.GOOS,
}),
}
opts = append(opts, option...)
img, err := remote.Image(dl.reference, opts...)
if err != nil {
return err
Expand Down

0 comments on commit 94c84d1

Please sign in to comment.