Skip to content

Commit

Permalink
Translate the host arch into limayaml arch
Browse files Browse the repository at this point in the history
Signed-off-by: Anders F Björklund <[email protected]>
  • Loading branch information
afbjorklund committed Dec 13, 2021
1 parent 88029fe commit 2a7b7ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions pkg/limayaml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
if o.Arch != nil {
y.Arch = o.Arch
}
y.Arch = pointer.String(resolveArch(y.Arch))
y.Arch = pointer.String(ResolveArch(y.Arch))

y.Images = append(append(o.Images, y.Images...), d.Images...)
for i := range y.Images {
Expand Down Expand Up @@ -400,13 +400,21 @@ func FillPortForwardDefaults(rule *PortForward, instDir string) {
}
}

func resolveArch(s *string) Arch {
func NewArch(arch string) Arch {
switch arch {
case "amd64":
return X8664
case "arm64":
return AARCH64
default:
logrus.Warnf("Unknown arch: %s", arch)
return arch
}
}

func ResolveArch(s *string) Arch {
if s == nil || *s == "" || *s == "default" {
if runtime.GOARCH == "amd64" {
return X8664
} else {
return AARCH64
}
return NewArch(runtime.GOARCH)
}
return *s
}
2 changes: 1 addition & 1 deletion pkg/store/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func AddGlobalFields(inst *Instance) (FormatData, error) {
// Add HostOS
data.HostOS = runtime.GOOS
// Add HostArch
data.HostArch = runtime.GOARCH
data.HostArch = limayaml.NewArch(runtime.GOARCH)
// Add IdentityFile
configDir, err := dirnames.LimaConfigDir()
if err != nil {
Expand Down

0 comments on commit 2a7b7ed

Please sign in to comment.