unpack local image file (#803)

LocalFile in BundleConfig, to prefix file:// to Target image file
Unpack local image file

Signed-off-by: Santhosh <santhosh@spectrocloud.com>
This commit is contained in:
Santhosh 2023-02-02 22:24:16 +05:30 committed by Itxaka
parent 7d66776a34
commit 31eb6ec19d

View File

@ -10,11 +10,16 @@ import (
"github.com/kairos-io/kairos/pkg/utils" "github.com/kairos-io/kairos/pkg/utils"
) )
const (
filePrefix = "file://"
)
type BundleConfig struct { type BundleConfig struct {
Target string Target string
Repository string Repository string
DBPath string DBPath string
RootPath string RootPath string
LocalFile bool
} }
// BundleOption defines a configuration option for a bundle. // BundleOption defines a configuration option for a bundle.
@ -148,10 +153,15 @@ func (l *ContainerRunner) Install(config *BundleConfig) error {
} }
defer os.RemoveAll(tempDir) defer os.RemoveAll(tempDir)
target := config.Target
if config.LocalFile {
target = strings.Join([]string{filePrefix, target}, "")
}
out, err := utils.SH( out, err := utils.SH(
fmt.Sprintf( fmt.Sprintf(
`luet util unpack %s %s`, `luet util unpack %s %s`,
config.Target, target,
tempDir, tempDir,
), ),
) )
@ -171,11 +181,16 @@ type ContainerInstaller struct{}
func (l *ContainerInstaller) Install(config *BundleConfig) error { func (l *ContainerInstaller) Install(config *BundleConfig) error {
target := config.Target
if config.LocalFile {
target = strings.Join([]string{filePrefix, target}, "")
}
//mkdir -p test/etc/luet/repos.conf.d //mkdir -p test/etc/luet/repos.conf.d
out, err := utils.SH( out, err := utils.SH(
fmt.Sprintf( fmt.Sprintf(
`luet util unpack %s %s`, `luet util unpack %s %s`,
config.Target, target,
config.RootPath, config.RootPath,
), ),
) )