diff --git a/bundles/bundles.go b/bundles/bundles.go index 677600e..ff2085d 100644 --- a/bundles/bundles.go +++ b/bundles/bundles.go @@ -153,7 +153,7 @@ func NewBundleInstaller(bc BundleConfig) (BundleInstaller, error) { type OCIImageExtractor struct{} func (e OCIImageExtractor) Install(config *BundleConfig) error { - return utils.ExtractOCIImage(config.Target, config.RootPath, config.LocalFile) + return utils.ExtractOCIImage(config.Target, config.RootPath, utils.GetCurrentPlatform(), config.LocalFile) } // OCIImageRunner will extract an OCI image and then run its run.sh @@ -166,7 +166,7 @@ func (e OCIImageRunner) Install(config *BundleConfig) error { } defer os.RemoveAll(tempDir) - err = utils.ExtractOCIImage(config.Target, tempDir, config.LocalFile) + err = utils.ExtractOCIImage(config.Target, tempDir, utils.GetCurrentPlatform(), config.LocalFile) if err != nil { return err } diff --git a/utils/image.go b/utils/image.go index e937b46..27510b1 100644 --- a/utils/image.go +++ b/utils/image.go @@ -15,10 +15,20 @@ import ( ) // ExtractOCIImage will extract a given targetImage into a given targetDestination and pull from the local repo if set. -func ExtractOCIImage(targetImage, targetDestination string, isLocal bool) error { - platform, err := v1.ParsePlatform(fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) - if err != nil { - return err +func ExtractOCIImage(targetImage, targetDestination, targetPlatform string, isLocal bool) error { + var platform *v1.Platform + var err error + + if targetPlatform != "" { + platform, err = v1.ParsePlatform(targetPlatform) + if err != nil { + return err + } + } else { + platform, err = v1.ParsePlatform(fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) + if err != nil { + return err + } } ref, err := name.ParseReference(targetImage) diff --git a/utils/utils.go b/utils/utils.go index fbfe522..372ba1b 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -11,6 +11,7 @@ import ( "os" "os/exec" "os/signal" + "runtime" "strings" "github.com/denisbrodbeck/machineid" @@ -246,3 +247,8 @@ func GetInterfaceIP(in string) string { } return "" } + +// GetCurrentPlatform returns the current platform in docker style `linux/amd64` for use with image utils +func GetCurrentPlatform() string { + return fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) +}