Skip to content

Commit f8e46c6

Browse files
authored
Merge pull request #1413 from pendo324/rosetta-fields-overridable
feat: allow rosetta fields to be overridden
2 parents cce3561 + e339944 commit f8e46c6

File tree

5 files changed

+48
-5
lines changed

5 files changed

+48
-5
lines changed

pkg/cidata/cidata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort
126126
SlirpGateway: networks.SlirpGateway,
127127
SlirpDNS: networks.SlirpDNS,
128128
SlirpIPAddress: networks.SlirpIPAddress,
129-
RosettaEnabled: y.Rosetta.Enabled,
130-
RosettaBinFmt: y.Rosetta.BinFmt,
129+
RosettaEnabled: *y.Rosetta.Enabled,
130+
RosettaBinFmt: *y.Rosetta.BinFmt,
131131
}
132132

133133
// change instance id on every boot so network config will be processed again

pkg/limayaml/defaults.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,26 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
540540

541541
caCerts := unique(append(append(d.CACertificates.Certs, y.CACertificates.Certs...), o.CACertificates.Certs...))
542542
y.CACertificates.Certs = caCerts
543+
544+
if y.Rosetta.Enabled == nil {
545+
y.Rosetta.Enabled = d.Rosetta.Enabled
546+
}
547+
if o.Rosetta.Enabled != nil {
548+
y.Rosetta.Enabled = o.Rosetta.Enabled
549+
}
550+
if y.Rosetta.Enabled == nil {
551+
y.Rosetta.Enabled = pointer.Bool(false)
552+
}
553+
554+
if y.Rosetta.BinFmt == nil {
555+
y.Rosetta.BinFmt = d.Rosetta.BinFmt
556+
}
557+
if o.Rosetta.BinFmt != nil {
558+
y.Rosetta.BinFmt = o.Rosetta.BinFmt
559+
}
560+
if y.Rosetta.BinFmt == nil {
561+
y.Rosetta.BinFmt = pointer.Bool(false)
562+
}
543563
}
544564

545565
func executeGuestTemplate(format string) (bytes.Buffer, error) {

pkg/limayaml/defaults_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ func TestFillDefault(t *testing.T) {
223223
},
224224
}
225225

226+
expect.Rosetta = Rosetta{
227+
Enabled: pointer.Bool(false),
228+
BinFmt: pointer.Bool(false),
229+
}
230+
226231
FillDefault(&y, &LimaYAML{}, &LimaYAML{}, filePath)
227232
assert.DeepEqual(t, &y, &expect, opts...)
228233

@@ -328,6 +333,10 @@ func TestFillDefault(t *testing.T) {
328333
"-----BEGIN CERTIFICATE-----\nYOUR-ORGS-TRUSTED-CA-CERT\n-----END CERTIFICATE-----\n",
329334
},
330335
},
336+
Rosetta: Rosetta{
337+
Enabled: pointer.Bool(true),
338+
BinFmt: pointer.Bool(true),
339+
},
331340
}
332341

333342
expect = d
@@ -350,6 +359,11 @@ func TestFillDefault(t *testing.T) {
350359
"-----BEGIN CERTIFICATE-----\nYOUR-ORGS-TRUSTED-CA-CERT\n-----END CERTIFICATE-----\n",
351360
}
352361

362+
expect.Rosetta = Rosetta{
363+
Enabled: pointer.Bool(true),
364+
BinFmt: pointer.Bool(true),
365+
}
366+
353367
y = LimaYAML{}
354368
FillDefault(&y, &d, &LimaYAML{}, filePath)
355369
assert.DeepEqual(t, &y, &expect, opts...)
@@ -497,6 +511,10 @@ func TestFillDefault(t *testing.T) {
497511
CACertificates: CACertificates{
498512
RemoveDefaults: pointer.Bool(true),
499513
},
514+
Rosetta: Rosetta{
515+
Enabled: pointer.Bool(false),
516+
BinFmt: pointer.Bool(false),
517+
},
500518
}
501519

502520
y = filledDefaults
@@ -543,6 +561,11 @@ func TestFillDefault(t *testing.T) {
543561
"-----BEGIN CERTIFICATE-----\nYOUR-ORGS-TRUSTED-CA-CERT\n-----END CERTIFICATE-----\n",
544562
}
545563

564+
expect.Rosetta = Rosetta{
565+
Enabled: pointer.Bool(false),
566+
BinFmt: pointer.Bool(false),
567+
}
568+
546569
FillDefault(&y, &d, &o, filePath)
547570
assert.DeepEqual(t, &y, &expect, opts...)
548571
}

pkg/limayaml/limayaml.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ const (
5555
)
5656

5757
type Rosetta struct {
58-
Enabled bool `yaml:"enabled" json:"enabled"`
59-
BinFmt bool `yaml:"binfmt" json:"binfmt"`
58+
Enabled *bool `yaml:"enabled" json:"enabled"`
59+
BinFmt *bool `yaml:"binfmt" json:"binfmt"`
6060
}
6161

6262
type File struct {

pkg/vz/vm_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ func attachFolderMounts(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineCo
404404
}
405405
}
406406

407-
if driver.Yaml.Rosetta.Enabled {
407+
if *driver.Yaml.Rosetta.Enabled {
408408
logrus.Info("Setting up Rosetta share")
409409
directorySharingDeviceConfig, err := createRosettaDirectoryShareConfiguration()
410410
if err != nil {

0 commit comments

Comments
 (0)