mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-08-25 18:19:36 +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{}
|
type OCIImageExtractor struct{}
|
||||||
|
|
||||||
func (e OCIImageExtractor) Install(config *BundleConfig) error {
|
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
|
// 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)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ExtractOCIImage will extract a given targetImage into a given targetDestination and pull from the local repo if set.
|
// 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 {
|
func ExtractOCIImage(targetImage, targetDestination, targetPlatform string, isLocal bool) error {
|
||||||
platform, err := v1.ParsePlatform(fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH))
|
var platform *v1.Platform
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if targetPlatform != "" {
|
||||||
|
platform, err = v1.ParsePlatform(targetPlatform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
ref, err := name.ParseReference(targetImage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/denisbrodbeck/machineid"
|
"github.com/denisbrodbeck/machineid"
|
||||||
@ -246,3 +247,8 @@ func GetInterfaceIP(in string) string {
|
|||||||
}
|
}
|
||||||
return ""
|
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