Skip to content

Commit d74abc1

Browse files
committed
Allow setting the arch of the image to be pulled
because when we are on amd64 host, the auroraboot image is amd64 but we may want to pull and build artifacts for arm64 (e.g. when building rpi raw images). Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
1 parent 02cb529 commit d74abc1

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

deployer/steps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (d *Deployer) StepDumpSource() error {
9797
// Ops to generate from container image
9898
return d.Add(constants.OpDumpSource,
9999
herd.EnableIf(d.fromImage),
100-
herd.WithDeps(constants.OpPrepareDirs), herd.WithCallback(ops.DumpSource(d.Artifact.ContainerImage, d.tmpRootFs)))
100+
herd.WithDeps(constants.OpPrepareDirs), herd.WithCallback(ops.DumpSource(d.Artifact.ContainerImage, d.tmpRootFs, d.Config.Arch)))
101101
}
102102

103103
func (d *Deployer) StepGenISO() error {

pkg/ops/container.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@ import (
1313
// or simply copies the directory to the destination.
1414
// Supports these prefixes:
1515
// https://github.com/kairos-io/kairos-agent/blob/1e81cdef38677c8a36cae50d3334559976f66481/pkg/types/v1/common.go#L30-L33
16-
func DumpSource(image string, dstFunc valueGetOnCall) func(ctx context.Context) error {
16+
func DumpSource(image string, dstFunc valueGetOnCall, arch string) func(ctx context.Context) error {
1717
return func(ctx context.Context) error {
1818
dst := dstFunc()
1919
if image == "" {
2020
return fmt.Errorf("image source is empty, cannot dump to %s", dst)
2121
}
22-
cfg := NewConfig(
22+
opts := []GenericOptions{
2323
WithImageExtractor(v1.OCIImageExtractor{}),
2424
WithLogger(internal.Log),
25-
)
25+
}
26+
if arch != "" {
27+
opts = append(opts, WithArch(arch))
28+
}
29+
cfg := NewConfig(opts...)
2630
e := elemental.NewElemental(cfg)
2731

2832
imgSource, err := v1.NewSrcFromURI(image)

pkg/ops/iso.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,3 +756,16 @@ func WithImageExtractor(extractor v1types.ImageExtractor) func(r *agentconfig.Co
756756
return nil
757757
}
758758
}
759+
760+
func WithArch(arch string) func(r *agentconfig.Config) error {
761+
return func(r *agentconfig.Config) error {
762+
if arch != "" {
763+
convertedArch, err := utils.GolangArchToArch(arch)
764+
if err != nil {
765+
return fmt.Errorf("invalid architecture %s: %w", arch, err)
766+
}
767+
r.Arch = convertedArch
768+
}
769+
return nil
770+
}
771+
}

pkg/schema/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type Config struct {
2727

2828
ListenAddr string `yaml:"listen_addr"`
2929

30+
// Architecture to use for container image pulling (e.g., "amd64", "arm64")
31+
Arch string `yaml:"arch"`
32+
3033
// ISO block configuration
3134
ISO ISO `yaml:"iso"`
3235

0 commit comments

Comments
 (0)