Skip to content

Commit

Permalink
Merge pull request #18 from wandb/platform-command
Browse files Browse the repository at this point in the history
fix: allow platform specification
  • Loading branch information
adityachoudhari26 authored Jul 1, 2024
2 parents 9c0ce8f + b540fa2 commit 997e98b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion cmd/wsm/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func downloadChartImages(
}

func DownloadCmd() *cobra.Command {
var platform string

cmd := &cobra.Command{
Use: "download",
Run: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -93,7 +95,7 @@ func DownloadCmd() *cobra.Command {
cb := func(pkg string) {
path := "bundle/images/" + pkg
_ = os.MkdirAll(path, 0755)
err := images.Download(pkg, path+"/image.tgz")
err := images.Download(pkg, path+"/image.tgz", platform)
if err != nil {
fmt.Println(err)
}
Expand All @@ -106,5 +108,7 @@ func DownloadCmd() *cobra.Command {
},
}

cmd.Flags().StringVarP(&platform, "platform", "p", "linux/amd64", "Platform to download images for")

return cmd
}
8 changes: 4 additions & 4 deletions pkg/images/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (
"github.com/containers/image/v5/types"
)

func Download(image string, filename string) error {
func Download(image string, filename string, platform string) error {
if _, err := exec.LookPath("docker"); err == nil {
return DownloadUsingDocker(image, filename)
return DownloadUsingDocker(image, filename, platform)
}

return fmt.Errorf("no supported container runtime found")
}

func DownloadUsingDocker(image string, filename string) error {
cmdPull := exec.Command("docker", "pull", image)
func DownloadUsingDocker(image string, filename string, platform string) error {
cmdPull := exec.Command("docker", "pull", "--platform", platform, image)
err := cmdPull.Run()
if err != nil {
return fmt.Errorf("failed to pull image using docker %s: %v", image, err)
Expand Down

0 comments on commit 997e98b

Please sign in to comment.