Skip to content

Commit e46309e

Browse files
committed
Switch to RFC compliant opaque template:name URLs
The old style template://name URLs are malformed because they do not contain a valid AUTHORITY (host name), but treat the host name as part of the path. They are still fully supported, but will emit a warning. Signed-off-by: Jan Dubois <jan.dubois@suse.com>
1 parent 1958c01 commit e46309e

File tree

19 files changed

+102
-76
lines changed

19 files changed

+102
-76
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ lima nerdctl run --rm hello-world
3939

4040
To run containers with Docker:
4141
```bash
42-
limactl start template://docker
42+
limactl start template:docker
4343
export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
4444
docker run --rm hello-world
4545
```
4646

4747
To run containers with Kubernetes:
4848
```bash
49-
limactl start template://k8s
49+
limactl start template:k8s
5050
export KUBECONFIG=$(limactl list k8s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
5151
kubectl apply -f ...
5252
```

cmd/apptainer.lima

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eu
44
: "${APPTAINER_BINDPATH:=}"
55

66
if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
7-
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template://apptainer\` to create a new instance" >&2
7+
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template:apptainer\` to create a new instance" >&2
88
exit 1
99
elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
1010
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2

cmd/docker.lima

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -eu
88
: "${DOCKER:=docker}"
99

1010
if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
11-
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template://docker\` to create a new instance" >&2
11+
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template:docker\` to create a new instance" >&2
1212
exit 1
1313
elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
1414
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2

cmd/kubectl.lima

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ if [ -z "$LIMA_INSTANCE" ]; then
1414
LIMA_INSTANCE=k8s
1515
else
1616
echo "No k3s or k8s existing instances found. Either create one with" >&2
17-
echo "limactl create --name=k3s template://k3s" >&2
18-
echo "limactl create --name=k8s template://k8s" >&2
17+
echo "limactl create --name=k3s template:k3s" >&2
18+
echo "limactl create --name=k8s template:k8s" >&2
1919
echo "or set LIMA_INSTANCE to the name of your Kubernetes instance" >&2
2020
exit 1
2121
fi

cmd/limactl/completion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func bashCompleteTemplateNames(_ *cobra.Command, toComplete string) ([]string, c
2828
var comp []string
2929
if templates, err := templatestore.Templates(); err == nil {
3030
for _, f := range templates {
31-
name := "template://" + f.Name
31+
name := "template:" + f.Name
3232
if !strings.HasPrefix(name, toComplete) {
3333
continue
3434
}

cmd/limactl/start.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func newCreateCommand() *cobra.Command {
4949
$ limactl create
5050
5151
To create an instance "default" from a template "docker":
52-
$ limactl create --name=default template://docker
52+
$ limactl create --name=default template:docker
5353
5454
To create an instance "default" with modified parameters:
5555
$ limactl create --cpus=2 --memory=2
@@ -87,7 +87,7 @@ func newStartCommand() *cobra.Command {
8787
$ limactl start
8888
8989
To create an instance "default" from a template "docker", and start it:
90-
$ limactl start --name=default template://docker
90+
$ limactl start --name=default template:docker
9191
`,
9292
Short: "Start an instance of Lima",
9393
Args: WrapArgsError(cobra.MaximumNArgs(1)),
@@ -234,19 +234,19 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
234234
if isTemplateURL, templateName := limatmpl.SeemsTemplateURL(arg); isTemplateURL {
235235
switch templateName {
236236
case "experimental/vz":
237-
logrus.Warn("template://experimental/vz was merged into the default template in Lima v1.0. See also <https://lima-vm.io/docs/config/vmtype/>.")
237+
logrus.Warn("template:experimental/vz was merged into the default template in Lima v1.0. See also <https://lima-vm.io/docs/config/vmtype/>.")
238238
case "experimental/riscv64":
239-
logrus.Warn("template://experimental/riscv64 was merged into the default template in Lima v1.0. Use `limactl create --arch=riscv64 template://default` instead.")
239+
logrus.Warn("template:experimental/riscv64 was merged into the default template in Lima v1.0. Use `limactl create --arch=riscv64 template:default` instead.")
240240
case "experimental/armv7l":
241-
logrus.Warn("template://experimental/armv7l was merged into the default template in Lima v1.0. Use `limactl create --arch=armv7l template://default` instead.")
241+
logrus.Warn("template:experimental/armv7l was merged into the default template in Lima v1.0. Use `limactl create --arch=armv7l template:default` instead.")
242242
case "vmnet":
243-
logrus.Warn("template://vmnet was removed in Lima v1.0. Use `limactl create --network=lima:shared template://default` instead. See also <https://lima-vm.io/docs/config/network/>.")
243+
logrus.Warn("template:vmnet was removed in Lima v1.0. Use `limactl create --network=lima:shared template:default` instead. See also <https://lima-vm.io/docs/config/network/>.")
244244
case "experimental/net-user-v2":
245-
logrus.Warn("template://experimental/net-user-v2 was removed in Lima v1.0. Use `limactl create --network=lima:user-v2 template://default` instead. See also <https://lima-vm.io/docs/config/network/>.")
245+
logrus.Warn("template:experimental/net-user-v2 was removed in Lima v1.0. Use `limactl create --network=lima:user-v2 template:default` instead. See also <https://lima-vm.io/docs/config/network/>.")
246246
case "experimental/9p":
247-
logrus.Warn("template://experimental/9p was removed in Lima v1.0. Use `limactl create --vm-type=qemu --mount-type=9p template://default` instead. See also <https://lima-vm.io/docs/config/mount/>.")
247+
logrus.Warn("template:experimental/9p was removed in Lima v1.0. Use `limactl create --vm-type=qemu --mount-type=9p template:default` instead. See also <https://lima-vm.io/docs/config/mount/>.")
248248
case "experimental/virtiofs-linux":
249-
logrus.Warn("template://experimental/virtiofs-linux was removed in Lima v1.0. Use `limactl create --mount-type=virtiofs template://default` instead. See also <https://lima-vm.io/docs/config/mount/>.")
249+
logrus.Warn("template:experimental/virtiofs-linux was removed in Lima v1.0. Use `limactl create --mount-type=virtiofs template:default` instead. See also <https://lima-vm.io/docs/config/mount/>.")
250250
}
251251
}
252252
if arg == "-" {
@@ -298,8 +298,8 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
298298
return nil, err
299299
}
300300
if arg != "" && arg != DefaultInstanceName {
301-
logrus.Infof("Creating an instance %q from template://default (Not from template://%s)", tmpl.Name, tmpl.Name)
302-
logrus.Warnf("This form is deprecated. Use `limactl create --name=%s template://default` instead", tmpl.Name)
301+
logrus.Infof("Creating an instance %q from template:default (Not from template:%s)", tmpl.Name, tmpl.Name)
302+
logrus.Warnf("This form is deprecated. Use `limactl create --name=%s template:default` instead", tmpl.Name)
303303
}
304304
// Read the default template for creating a new instance
305305
tmpl.Bytes, err = templatestore.Read(templatestore.Default)

cmd/limactl/template.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ func newValidateCommand() *cobra.Command {
5252
return validateCommand
5353
}
5454

55-
var templateCopyExample = ` Template locators are local files, file://, https://, or template:// URLs
55+
var templateCopyExample = ` Template locators are local files, file://, https://, or template: URLs
5656
5757
# Copy default template to STDOUT
58-
limactl template copy template://default -
58+
limactl template copy template:default -
5959
6060
# Copy template from web location to local file and embed all external references
61-
# (this does not embed template:// references)
61+
# (this does not embed template: references)
6262
limactl template copy --embed https://example.com/lima.yaml mighty-machine.yaml
6363
`
6464

@@ -177,10 +177,10 @@ External references are embedded and default values are filled in
177177
before the YQ expression is evaluated.
178178
179179
Example:
180-
limactl template yq template://default '.images[].location'
180+
limactl template yq template:default '.images[].location'
181181
182182
The example command is equivalent to using an external yq command like this:
183-
limactl template copy --fill template://default - | yq '.images[].location'
183+
limactl template copy --fill template:default - | yq '.images[].location'
184184
`
185185

186186
func newTemplateYQCommand() *cobra.Command {

cmd/podman.lima

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eu
44
: "${PODMAN:=podman}"
55

66
if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
7-
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template://podman\` to create a new instance" >&2
7+
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template:podman\` to create a new instance" >&2
88
exit 1
99
elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
1010
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2

hack/bats/tests/preserve-env.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ local_setup_file() {
1717
limactl delete --force "$NAME" || :
1818
# Make sure that the host agent doesn't inherit file handles 3 or 4.
1919
# Otherwise bats will not finish until the host agent exits.
20-
limactl start --yes --name "$NAME" template://default 3>&- 4>&-
20+
limactl start --yes --name "$NAME" template:default 3>&- 4>&-
2121
}
2222

2323
local_teardown_file() {

hack/common.inc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _IPERF3=iperf3
3131
: "${IPERF3:=$_IPERF3}"
3232

3333
# Setup LIMA_TEMPLATES_PATH because the templates are not installed, but reference base templates
34-
# via template://_images/* and template://_default/*.
34+
# via template:_images/* and template:_default/*.
3535
templates_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../templates" && pwd)"
3636
: "${LIMA_TEMPLATES_PATH:-$templates_dir}"
3737
export LIMA_TEMPLATES_PATH

0 commit comments

Comments
 (0)