Skip to content

Commit 1b1aa95

Browse files
authored
Merge pull request #1679 from AkihiroSuda/rename-templates
Rename "examples" to "templates"
2 parents 4975bb8 + 2ee1efa commit 1b1aa95

File tree

10 files changed

+41
-33
lines changed

10 files changed

+41
-33
lines changed

.cirrus.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ task:
3838
env:
3939
# yamllint disable rule:key-duplicates
4040
matrix:
41-
# We only test "Tier 1" yamls. See examples/README.md for the list of the "Tier 1" yamls.
41+
# We only test "Tier 1" yamls. See templates/README.md for the list of the "Tier 1" yamls.
4242
# default.yaml and vmnet.yaml are tested on GHA macOS.
4343
TEMPLATE: alpine.yaml
4444
TEMPLATE: debian.yaml
@@ -47,10 +47,10 @@ task:
4747
TEMPLATE: opensuse.yaml
4848
TEMPLATE: experimental/net-user-v2.yaml
4949
lima_cache:
50-
fingerprint_script: uname -s ; cat examples/$TEMPLATE
50+
fingerprint_script: uname -s ; cat templates/$TEMPLATE
5151
folder: /home/testuser/.cache/lima
5252
lima_cache_fix_perm_script: chown -R testuser.testuser /home/testuser
53-
test_script: sudo -iu testuser $(pwd)/hack/test-example.sh $(pwd)/examples/$TEMPLATE
53+
test_script: sudo -iu testuser $(pwd)/hack/test-templates.sh $(pwd)/templates/$TEMPLATE
5454

5555
colima_task:
5656
<<: *common_template

.github/workflows/test.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ jobs:
8282
run: make
8383
- name: Install
8484
run: make install
85-
- name: Validate examples
86-
run: find examples -name '*.yaml' | xargs limactl validate
85+
- name: Validate templates
86+
run: find -L templates -name '*.yaml' | xargs limactl validate
8787
- name: Install test dependencies
8888
# QEMU: required by Lima itself
89-
# bash: required by test-example.sh (OS version of bash is too old)
90-
# coreutils: required by test-example.sh for the "timeout" command
91-
# curl: required by test-example.sh to download nerdctl for alpine
92-
# jq: required by test-example.sh to determine download URL for nerdctl
89+
# bash: required by test-templates.sh (OS version of bash is too old)
90+
# coreutils: required by test-templates.sh for the "timeout" command
91+
# curl: required by test-templates.sh to download nerdctl for alpine
92+
# jq: required by test-templates.sh to determine download URL for nerdctl
9393
run: |
9494
set -x
9595
# Github runners seem to have lima installed by brew already; we don't want/need it
@@ -106,28 +106,28 @@ jobs:
106106
timeout_minutes: 30
107107
retry_on: error
108108
max_attempts: 3
109-
command: ./hack/test-example.sh examples/default.yaml
109+
command: ./hack/test-templates.sh templates/default.yaml
110110
- name: "Test alpine.yaml"
111111
uses: nick-invision/retry@v2
112112
with:
113113
timeout_minutes: 30
114114
retry_on: error
115115
max_attempts: 3
116-
command: ./hack/test-example.sh examples/alpine.yaml
116+
command: ./hack/test-templates.sh templates/alpine.yaml
117117
- name: "Test experimental/9p.yaml"
118118
uses: nick-invision/retry@v2
119119
with:
120120
timeout_minutes: 30
121121
retry_on: error
122122
max_attempts: 3
123-
command: ./hack/test-example.sh examples/experimental/9p.yaml
123+
command: ./hack/test-templates.sh templates/experimental/9p.yaml
124124
- name: "Test test-misc.yaml"
125125
uses: nick-invision/retry@v2
126126
with:
127127
timeout_minutes: 30
128128
retry_on: error
129129
max_attempts: 3
130-
command: ./hack/test-example.sh hack/test-templates/test-misc.yaml
130+
command: ./hack/test-templates.sh hack/test-templates/test-misc.yaml
131131
# GHA macOS is slow and flaky, so we only test a few YAMLS here.
132132
# Other yamls are tested on Linux instances of Cirrus.
133133

@@ -176,7 +176,7 @@ jobs:
176176
timeout_minutes: 30
177177
retry_on: error
178178
max_attempts: 3
179-
command: ./hack/test-example.sh examples/vmnet.yaml
179+
command: ./hack/test-templates.sh templates/vmnet.yaml
180180
- name: Install socket_vmnet
181181
env:
182182
SOCKET_VMNET_VERSION: v1.1.1
@@ -199,7 +199,7 @@ jobs:
199199
timeout_minutes: 30
200200
retry_on: error
201201
max_attempts: 3
202-
command: ./hack/test-example.sh examples/vmnet.yaml
202+
command: ./hack/test-templates.sh templates/vmnet.yaml
203203

204204
upgrade:
205205
name: "Upgrade test"
@@ -253,4 +253,4 @@ jobs:
253253
path: ~/Library/Caches/lima/download
254254
key: ${{ runner.os }}-vz
255255
- name: Test
256-
run: ./hack/test-example.sh examples/experimental/vz.yaml
256+
run: ./hack/test-templates.sh templates/experimental/vz.yaml

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ minimal: clean \
4141
_output/bin/limactl$(exe) \
4242
codesign \
4343
_output/share/lima/lima-guestagent.Linux-$(shell uname -m | sed -e s/arm64/aarch64/)
44-
mkdir -p _output/share/lima/examples
45-
cp -aL examples/default.yaml _output/share/lima/examples/
44+
mkdir -p _output/share/lima/templates
45+
cp -aL examples/default.yaml _output/share/lima/templates/
4646

4747
.PHONY: binaries
4848
binaries: clean \
@@ -59,14 +59,21 @@ binaries: clean \
5959
_output/share/lima/lima-guestagent.Linux-aarch64 \
6060
_output/share/lima/lima-guestagent.Linux-armv7l \
6161
_output/share/lima/lima-guestagent.Linux-riscv64
62-
cp -aL examples _output/share/lima
62+
cp -aL examples _output/share/lima/templates
63+
ifneq ($(GOOS),windows)
64+
ln -sf templates _output/share/lima/examples
65+
else
66+
cp -aL examples _output/share/lima/examples
67+
endif
6368
mkdir -p _output/share/doc/lima
6469
cp -aL *.md LICENSE docs _output/share/doc/lima
6570
echo "Moved to https://github.com/lima-vm/.github/blob/main/SECURITY.md" >_output/share/doc/lima/SECURITY.md
6671
ifneq ($(GOOS),windows)
67-
ln -sf ../../lima/examples _output/share/doc/lima
72+
ln -sf ../../lima/templates _output/share/doc/lima/templates
73+
ln -sf templates _output/share/doc/lima/examples
6874
else
69-
cp -aL examples _output/share/doc/lima
75+
cp -aL examples _output/share/doc/lima/examples
76+
cp -aL examples _output/share/doc/lima/templates
7077
endif
7178
echo $(VERSION) > _output/share/doc/lima/VERSION
7279

cmd/limactl/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ func main() {
2828
}
2929

3030
func newApp() *cobra.Command {
31-
examplesDir := "$PREFIX/share/doc/lima/examples"
31+
templatesDir := "$PREFIX/share/lima/templates"
3232
if exe, err := os.Executable(); err == nil {
3333
binDir := filepath.Dir(exe)
3434
prefixDir := filepath.Dir(binDir)
35-
examplesDir = filepath.Join(prefixDir, "share/doc/lima/examples")
35+
templatesDir = filepath.Join(prefixDir, "share/lima/templates")
3636
}
3737

3838
var rootCmd = &cobra.Command{
@@ -51,7 +51,7 @@ func newApp() *cobra.Command {
5151
Stop the default instance:
5252
$ limactl stop
5353
54-
See also example YAMLs: %s`, examplesDir),
54+
See also template YAMLs: %s`, templatesDir),
5555
SilenceUsage: true,
5656
SilenceErrors: true,
5757
DisableAutoGenTag: true,

cmd/limactl/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ To see the template list:
5353
$ limactl create --list-templates
5454
5555
To create an instance "default" from a local file:
56-
$ limactl create --name=default /usr/local/share/lima/examples/fedora.yaml
56+
$ limactl create --name=default /usr/local/share/lima/templates/fedora.yaml
5757
5858
To create an instance "default" from a remote URL (use carefully, with a trustable source):
5959
$ limactl create --name=default https://raw.githubusercontent.com/lima-vm/lima/master/examples/alpine.yaml

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Lima examples
1+
# Lima templates
22

33
⭐ = ["Tier 1"](#tier-1)
44

hack/test-port-forwarding.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# rules (before the instance is started). And once when the instance is
66
# running to perform the tests:
77
#
8-
# ./hack/test-port-forwarding.pl examples/default.yaml
9-
# limactl start --tty=false examples/default.yaml
10-
# git restore examples/default.yaml
8+
# ./hack/test-port-forwarding.pl templates/default.yaml
9+
# limactl start --tty=false templates/default.yaml
10+
# git restore templates/default.yaml
1111
# ./hack/test-port-forwarding.pl default
1212
#
1313
# TODO: support for ipv6 host addresses
File renamed without changes.

pkg/templatestore/templatestore.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func Read(name string) ([]byte, error) {
2020
if err != nil {
2121
return nil, err
2222
}
23-
yamlPath, err := securejoin.SecureJoin(filepath.Join(dir, "examples"), name+".yaml")
23+
yamlPath, err := securejoin.SecureJoin(filepath.Join(dir, "templates"), name+".yaml")
2424
if err != nil {
2525
return nil, err
2626
}
@@ -34,7 +34,7 @@ func Templates() ([]Template, error) {
3434
if err != nil {
3535
return nil, err
3636
}
37-
examplesDir := filepath.Join(usrlocalsharelimaDir, "examples")
37+
templatesDir := filepath.Join(usrlocalsharelimaDir, "templates")
3838

3939
var res []Template
4040
walkDirFn := func(p string, d fs.DirEntry, err error) error {
@@ -47,13 +47,13 @@ func Templates() ([]Template, error) {
4747
}
4848
x := Template{
4949
// Name is like "default", "debian", "deprecated/centos-7", ...
50-
Name: strings.TrimSuffix(strings.TrimPrefix(p, examplesDir+"/"), ".yaml"),
50+
Name: strings.TrimSuffix(strings.TrimPrefix(p, templatesDir+"/"), ".yaml"),
5151
Location: p,
5252
}
5353
res = append(res, x)
5454
return nil
5555
}
56-
if err = filepath.WalkDir(examplesDir, walkDirFn); err != nil {
56+
if err = filepath.WalkDir(templatesDir, walkDirFn); err != nil {
5757
return nil, err
5858
}
5959
return res, nil

templates

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
examples

0 commit comments

Comments
 (0)