mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-04-28 03:20:52 +00:00
Allow setting the platform of the image to download (#15)
This commit is contained in:
parent
60c5f9c587
commit
40db3d970e
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user