Skip to content

Commit b785cb8

Browse files
committed
Apply additional reviews
- `boot.sh`: - Remove TODO - Reword WARNING - `default.yaml`: - Reword comments - Add provision processing order information - `validateParamIsUsed`: Remove some comments Signed-off-by: Norio Nomura <[email protected]>
1 parent 0db85fb commit b785cb8

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

pkg/cidata/cidata.TEMPLATE.d/boot.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ if [ -d "${LIMA_CIDATA_MNT}"/provision.data ]; then
6969
INFO "Not overwriting $path"
7070
else
7171
INFO "Copying $f to $path"
72-
# TODO: Create intermediate directories with the specified group ownership.
7372
if ! sudo -iu "${user}" mkdir -p "$(dirname "$path")"; then
7473
WARNING "Failed to create directory for ${path} (as user ${user})"
7574
WARNING "Falling back to creating directory as root to maintain compatibility"
@@ -106,7 +105,7 @@ if [ -d "${LIMA_CIDATA_MNT}"/provision.yq ]; then
106105
# If the user does not have write permission, it should fail.
107106
# This avoids changes being made by the wrong user.
108107
if ! sudo -iu "${user}" test -w "${path}"; then
109-
WARNING "Failed to update ${path} (as user ${user})"
108+
WARNING "File ${path} is not writable by user ${user}"
110109
CODE=1
111110
continue
112111
fi

pkg/limayaml/validate.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,7 @@ func validateParamIsUsed(y *limatype.LimaYAML) error {
496496
}
497497
keyIsUsed := false
498498
for _, p := range y.Provision {
499-
for _, ptr := range []*string{
500-
&p.Script,
501-
// mode: data
502-
p.Content, p.Owner, p.Path,
503-
// mode: yq
504-
p.Expression, p.Permissions,
505-
} {
499+
for _, ptr := range []*string{&p.Script, p.Content, p.Expression, p.Owner, p.Path, p.Permissions} {
506500
if ptr != nil && re.MatchString(*ptr) {
507501
keyIsUsed = true
508502
break

templates/default.yaml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,11 @@ containerd:
247247
# permissions: 644
248248
# overwrite: false
249249
# # Create or edit a file in the guest filesystem by using `yq`.
250-
# # The file specified by `path` will be updated with the specified `expression` using `yq --inplace`.
251-
# # If the file does not exist, it will be created using `yq --null-input`.
252-
# # `format` is optional and defaults to "auto".
253-
# # One of the following is expected to work:
250+
# # The file specified by `path` will be updated by `expression`.
251+
# # An empty file of the required `format` will be created if it does not yet exist.
252+
# # `format` defaults to "auto" and will be detected by file extension of `path`.
253+
# # If the extension is not recognized by `yq` then `format` must be set to a
254+
# # value from this list:
254255
# # "auto", "csv", "ini", "json", "props", "tsv", "toml", "xml", "yaml"
255256
# # See https://github.com/mikefarah/yq for more info.
256257
# # Any missing directories will be created as needed.
@@ -265,6 +266,29 @@ containerd:
265266
# format: auto
266267
# owner: "{{.User}}"
267268
# permissions: 644
269+
#
270+
# Q. In what order are provision scripts executed?
271+
# A. All provisions are processed per boot by each module in stages of cloud-init as follows:
272+
# 1. cloud-init 'init' stage
273+
# bootcmd:
274+
# - `mode: boot` scripts are executed
275+
#
276+
# 2. cloud-init 'config' stage
277+
# write_files:
278+
# - `00-lima.boot.sh` is created, but not executed
279+
#
280+
# 3. cloud-init 'final' stage
281+
# scripts_per_boot:
282+
# - `00-lima.boot.sh` is executed; remaining provisions are processed in the following order:
283+
# - LIMA pre-defined boot scripts:
284+
# - `boot/{00-..., ..., 25-...}`
285+
# - `boot/30-install-packages.sh`
286+
# - `mode: dependency` scripts are executed
287+
# - `boot/{35-..., ...}`
288+
# - `mode: data` files are copied
289+
# - `mode: yq` files are processed
290+
# - `mode: system` scripts are executed
291+
# - `mode: user` scripts are executed
268292

269293
# Probe scripts to check readiness.
270294
# The scripts run in user mode. They must start with a '#!' line.

0 commit comments

Comments
 (0)