Skip to content

Commit 4e1cfac

Browse files
authored
Merge pull request #2123 from rancher-sandbox/example-templates
Use template variables instead of LIMA_CIDATA_* bash variables
2 parents b578b3f + 764d5df commit 4e1cfac

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

examples/docker-rootful.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# $ export DOCKER_HOST=$(limactl list docker-rootful --format 'unix://{{.Dir}}/sock/docker.sock')
77
# $ docker ...
88

9-
# This template requires Lima v0.8.0 or later
9+
# This template requires Lima v0.20.0 or later
1010
images:
1111
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
1212
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20231211/ubuntu-22.04-server-cloudimg-amd64.img"
@@ -49,7 +49,7 @@ provision:
4949
# Alternatively we could just add the user to the "docker" group, but that requires restarting the user session
5050
cat <<-EOF >/etc/systemd/system/docker.socket.d/override.conf
5151
[Socket]
52-
SocketUser=${LIMA_CIDATA_USER}
52+
SocketUser={{.User}}
5353
EOF
5454
fi
5555
export DEBIAN_FRONTEND=noninteractive

examples/experimental/vnc.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A template to run ubuntu using display: vnc
2-
# This template requires Lima v0.15.0 or later.
2+
# This template requires Lima v0.20.0 or later.
33
images:
44
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
55
- location: "https://cloud-images.ubuntu.com/releases/23.10/release-20231220/ubuntu-23.10-server-cloudimg-amd64.img"
@@ -33,7 +33,7 @@ provision:
3333
export DEBIAN_FRONTEND=noninteractive
3434
# x-terminal-emulator x-session-manager x-window-manager
3535
apt-get install -y xorg xterm openbox hsetroot tint2 slim
36-
printf "auto_login yes\ndefault_user ${LIMA_CIDATA_USER}\n" >>/etc/slim.conf
36+
printf "auto_login yes\ndefault_user {{.User}}\n" >>/etc/slim.conf
3737
# configure some nice lima green, set up panel and apps
3838
printf "hsetroot -solid \"#32CD32\" &\ntint2 &\n" >>/etc/xdg/openbox/autostart
3939
sed -i 's/Clearlooks/Clearlooks-Olive/' /etc/xdg/openbox/rc.xml # go for green

examples/k8s.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# NAME STATUS ROLES AGE VERSION
1111
# lima-k8s Ready control-plane,master 44s v1.22.3
1212

13-
# This template requires Lima v0.7.0 or later.
13+
# This template requires Lima v0.20.0 or later.
1414
images:
1515
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
1616
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20231211/ubuntu-22.04-server-cloudimg-amd64.img"
@@ -131,9 +131,9 @@ provision:
131131
#!/bin/bash
132132
set -eux -o pipefail
133133
export KUBECONFIG=/etc/kubernetes/admin.conf
134-
mkdir -p ${LIMA_CIDATA_HOME}/.kube
135-
cp -f $KUBECONFIG ${LIMA_CIDATA_HOME}/.kube/config
136-
chown -R ${LIMA_CIDATA_USER} ${LIMA_CIDATA_HOME}/.kube
134+
mkdir -p {{.Home}}/.kube
135+
cp -f $KUBECONFIG {{.Home}}/.kube/config
136+
chown -R {{.User}} {{.Home}}/.kube
137137
probes:
138138
- description: "kubeadm to be installed"
139139
script: |

examples/podman-rootful.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# $ export DOCKER_HOST=$(limactl list podman-rootful --format 'unix://{{.Dir}}/sock/podman.sock')
1111
# $ docker ...
1212

13-
# This template requires Lima v0.8.0 or later
13+
# This template requires Lima v0.20.0 or later
1414
images:
1515
- location: "https://download.fedoraproject.org/pub/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-39-1.5.x86_64.qcow2"
1616
arch: "x86_64"
@@ -36,12 +36,12 @@ provision:
3636
mkdir -p /etc/systemd/system/podman.socket.d
3737
cat <<-EOF >/etc/systemd/system/podman.socket.d/override.conf
3838
[Socket]
39-
SocketUser=${LIMA_CIDATA_USER}
39+
SocketUser={{.User}}
4040
EOF
4141
fi
4242
if [ ! -e /etc/tmpfiles.d/podman.conf ]; then
4343
mkdir -p /etc/tmpfiles.d
44-
echo "d /run/podman 0700 ${LIMA_CIDATA_USER} -" > /etc/tmpfiles.d/podman.conf
44+
echo "d /run/podman 0700 {{.User}} -" > /etc/tmpfiles.d/podman.conf
4545
fi
4646
dnf -y install podman
4747
- mode: system

pkg/limayaml/validate.go

+3
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ func Validate(y LimaYAML, warn bool) error {
187187
return fmt.Errorf("field `provision[%d].mode` must one of %q, %q, %q, or %q",
188188
i, ProvisionModeSystem, ProvisionModeUser, ProvisionModeBoot, ProvisionModeDependency)
189189
}
190+
if strings.Contains(p.Script, "LIMA_CIDATA") {
191+
logrus.Warn("provisioning scripts should not reference the LIMA_CIDATA variables")
192+
}
190193
}
191194
needsContainerdArchives := (y.Containerd.User != nil && *y.Containerd.User) || (y.Containerd.System != nil && *y.Containerd.System)
192195
if needsContainerdArchives && len(y.Containerd.Archives) == 0 {

0 commit comments

Comments
 (0)