Skip to content

Commit 1f00288

Browse files
committed
Rename basedOn → base
Signed-off-by: Jan Dubois <[email protected]>
1 parent a346728 commit 1f00288

File tree

8 files changed

+34
-34
lines changed

8 files changed

+34
-34
lines changed

pkg/limatmpl/abs.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ func (tmpl *Template) useAbsLocators() error {
2525
if err != nil {
2626
return err
2727
}
28-
for i, baseLocator := range tmpl.Config.BasedOn {
28+
for i, baseLocator := range tmpl.Config.Base {
2929
locator, err := absPath(baseLocator, basePath)
3030
if err != nil {
3131
return err
3232
}
3333
if i == 0 {
34-
// basedOn can either be a single string, or a list of strings
35-
tmpl.expr.WriteString(fmt.Sprintf("| ($a.basedOn | select(type == \"!!str\")) |= %q\n", locator))
36-
tmpl.expr.WriteString(fmt.Sprintf("| ($a.basedOn | select(type == \"!!seq\") | .[0]) |= %q\n", locator))
34+
// base can either be a single string, or a list of strings
35+
tmpl.expr.WriteString(fmt.Sprintf("| ($a.base | select(type == \"!!str\")) |= %q\n", locator))
36+
tmpl.expr.WriteString(fmt.Sprintf("| ($a.base | select(type == \"!!seq\") | .[0]) |= %q\n", locator))
3737
} else {
38-
tmpl.expr.WriteString(fmt.Sprintf("| $a.basedOn[%d] = %q\n", i, locator))
38+
tmpl.expr.WriteString(fmt.Sprintf("| $a.base[%d] = %q\n", i, locator))
3939
}
4040
}
4141
for i, p := range tmpl.Config.Probes {

pkg/limatmpl/abs_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,46 @@ type useAbsLocatorsTestCase struct {
1818

1919
var useAbsLocatorsTestCases = []useAbsLocatorsTestCase{
2020
{
21-
"Template without basedOn or script file",
21+
"Template without base or script file",
2222
"template://foo",
2323
`arch: aarch64`,
2424
`arch: aarch64`,
2525
},
2626
{
2727
"Single string base template",
2828
"template://foo",
29-
`basedOn: bar.yaml`,
30-
`basedOn: template://bar.yaml`,
29+
`base: bar.yaml`,
30+
`base: template://bar.yaml`,
3131
},
3232
{
3333
"Flow style array of one base template",
3434
"template://foo",
35-
`basedOn: [bar.yaml]`,
36-
`basedOn: ['template://bar.yaml']`,
35+
`base: [bar.yaml]`,
36+
`base: ['template://bar.yaml']`,
3737
},
3838
{
3939
"Block style array of one base template",
4040
"template://foo",
4141
`
42-
basedOn:
42+
base:
4343
- bar.yaml
4444
`,
4545
`
46-
basedOn:
46+
base:
4747
- template://bar.yaml`,
4848
},
4949
{
5050
"Block style of four base templates",
5151
"template://foo",
5252
`
53-
basedOn:
53+
base:
5454
- bar.yaml
5555
- template://my
5656
- https://example.com/my.yaml
5757
- baz.yaml
5858
`,
5959
`
60-
basedOn:
60+
base:
6161
- template://bar.yaml
6262
- template://my
6363
- https://example.com/my.yaml

pkg/limatmpl/embed.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/sirupsen/logrus"
1616
)
1717

18-
// Embed will recursively resolve all "basedOn" dependencies and update the
18+
// Embed will recursively resolve all "base" dependencies and update the
1919
// template with the merged result. It also inlines all external provisioning
2020
// and probe scripts.
2121
func (tmpl *Template) Embed(ctx context.Context) error {
@@ -51,19 +51,19 @@ func (tmpl *Template) embed(ctx context.Context, defaultBase bool, seen map[stri
5151
if err := tmpl.Unmarshal(); err != nil {
5252
return err
5353
}
54-
basedOn := tmpl.Config.BasedOn
54+
bases := tmpl.Config.Base
5555
if defaultBase {
56-
// Prepend $LIMA_HOME/_config/base.yaml to basedOn list.
56+
// Prepend $LIMA_HOME/_config/base.yaml to bases list.
5757
configDir, err := dirnames.LimaConfigDir()
5858
if err != nil {
5959
return err
6060
}
6161
defaultBaseFilename := filepath.Join(configDir, filenames.Base)
6262
if _, err := os.Stat(defaultBaseFilename); err == nil {
63-
basedOn = append([]string{defaultBaseFilename}, basedOn...)
63+
bases = append([]string{defaultBaseFilename}, bases...)
6464
}
6565
}
66-
for _, baseLocator := range basedOn {
66+
for _, baseLocator := range bases {
6767
logrus.Debugf("Merging base template %q", baseLocator)
6868
base, err := Read(ctx, "", baseLocator)
6969
if err != nil {
@@ -154,7 +154,7 @@ func (tmpl *Template) mergeBase(base *Template) error {
154154
// * dns lists are not merged and only copied when the template doesn't have any dns entries at all.
155155
// * probes and provision scripts are appended in reverse order.
156156
// * mountTypesUnsupported have duplicate values removed.
157-
// * basedOn is removed from the template.
157+
// * base is removed from the template.
158158
const mergeDocuments = `
159159
select(document_index == 0) as $a
160160
| select(document_index == 1) as $b
@@ -195,7 +195,7 @@ const mergeDocuments = `
195195
# Make sure mountTypesUnsupported elements are unique.
196196
| $a | (select(.mountTypesUnsupported) | .mountTypesUnsupported) |= unique
197197
198-
| del($a.basedOn)
198+
| del($a.base)
199199
200200
# Remove the custom tags again so they do not clutter up the YAML output.
201201
| $a | .. tag = ""

pkg/limatmpl/embed_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type embedTestCase struct {
2727
// * If the description starts with "TODO" then the test is expected to fail (until it is fixed).
2828
// * base is split on "---\n" and stored as base0.yaml, base1.yaml, ... in the same dir as the template.
2929
// * If any base template starts with "#!" then the extension will be .sh instead of .yaml.
30-
// * The template is automatically prefixed with "basedOn: base0.yaml" unless base0 is a script.
30+
// * The template is automatically prefixed with "base: base0.yaml" unless base0 is a script.
3131
// * All line comments will be separated by 2 spaces from the value on output.
3232
// * Merge order of additionalDisks, mounts, and networks depends on the logic in the
3333
// combineListEntries() functions and will not follow the order of the base template(s).
@@ -173,7 +173,7 @@ mounts:
173173
arch: aarch64
174174
`,
175175
`
176-
basedOn: base0.yaml
176+
base: base0.yaml
177177
# failure would mean this test loops forever, not that it fails the test
178178
vmType: qemu
179179
`,
@@ -187,10 +187,10 @@ vmType: qemu
187187
"Bases are embedded depth-first",
188188
`#`,
189189
`
190-
basedOn: [base1.yaml, base2.yaml]
190+
base: [base1.yaml, base2.yaml]
191191
additionalDisks: [disk0]
192192
---
193-
basedOn: base3.yaml
193+
base: base3.yaml
194194
additionalDisks: [disk1]
195195
---
196196
additionalDisks: [disk2]
@@ -281,7 +281,7 @@ provision:
281281
`,
282282
},
283283
{
284-
"Script files are embedded even when no basedOn property exists",
284+
"Script files are embedded even when no base property exists",
285285
"provision: [{file: base0.sh}]",
286286
"#! my script",
287287
`provision: [{script: "#! my script"}]`,
@@ -322,10 +322,10 @@ func RunEmbedTest(t *testing.T, tc embedTestCase) {
322322
assert.NilError(t, err, tc.description)
323323
}
324324
tmpl := &limatmpl.Template{
325-
Bytes: []byte(fmt.Sprintf("basedOn: base0.yaml\n%s", tc.template)),
325+
Bytes: []byte(fmt.Sprintf("base: base0.yaml\n%s", tc.template)),
326326
Locator: "tmpl.yaml",
327327
}
328-
// Don't include `basedOn` property if base0 is a script
328+
// Don't include `base` property if base0 is a script
329329
if strings.HasPrefix(tc.base, "#!") {
330330
tmpl.Bytes = []byte(tc.template)
331331
}

pkg/limayaml/limayaml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
type LimaYAML struct {
10-
BasedOn BaseTemplates `yaml:"basedOn,omitempty" json:"basedOn,omitempty" jsonschema:"nullable"`
10+
Base BaseTemplates `yaml:"base,omitempty" json:"base,omitempty" jsonschema:"nullable"`
1111
MinimumLimaVersion *string `yaml:"minimumLimaVersion,omitempty" json:"minimumLimaVersion,omitempty" jsonschema:"nullable"`
1212
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty" jsonschema:"nullable"`
1313
VMOpts VMOpts `yaml:"vmOpts,omitempty" json:"vmOpts,omitempty"`

pkg/limayaml/marshal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func unmarshalDisk(dst *Disk, b []byte) error {
3535
return yaml.Unmarshal(b, dst)
3636
}
3737

38-
// unmarshalBaseTemplates unmarshalls `basedOn` which is either a string or a list of strings.
38+
// unmarshalBaseTemplates unmarshalls `base` which is either a string or a list of strings.
3939
func unmarshalBaseTemplates(dst *BaseTemplates, b []byte) error {
4040
var s string
4141
if err := yaml.Unmarshal(b, &s); err == nil {

pkg/limayaml/validate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ func validateFileObject(f File, fieldName string) error {
4747
}
4848

4949
func Validate(y *LimaYAML, warn bool) error {
50-
if len(y.BasedOn) > 0 {
51-
return errors.New("field `basedOn` must be empty for YAML validation")
50+
if len(y.Base) > 0 {
51+
return errors.New("field `base` must be empty for YAML validation")
5252
}
5353
if y.MinimumLimaVersion != nil {
5454
if _, err := versionutil.Parse(*y.MinimumLimaVersion); err != nil {

templates/default.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ minimumLimaVersion: null
285285
# This setting ca be either a single string, or a list of strings.
286286
# Any relative base template name will be resolved relative to the location of the main template.
287287
# 🟢 Builtin default: no base template
288-
basedOn: null
288+
base: null
289289

290290
# User to be used inside the VM
291291
user:
@@ -570,7 +570,7 @@ nestedVirtualization: null
570570
# the mount of the home directory writable.
571571

572572
# A third mechanism is $LIMA_HOME/_config/base.yaml. It is similar to
573-
# `default.yaml` but will be merged during the `basedOn` template assembly
573+
# `default.yaml` but will be merged during the `base` template embedding
574574
# when the instance is created, and not on every start. It becomes part
575575
# of the lima.yaml file.
576576

0 commit comments

Comments
 (0)