Skip to content

Commit

Permalink
Rename "examples" to "templates"
Browse files Browse the repository at this point in the history
The "examples" directory in the git repo is not renamed, for keeping
existing hyperlinks alive

Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed Jul 23, 2023
1 parent e773db0 commit 2ee1efa
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ task:
env:
# yamllint disable rule:key-duplicates
matrix:
# We only test "Tier 1" yamls. See examples/README.md for the list of the "Tier 1" yamls.
# We only test "Tier 1" yamls. See templates/README.md for the list of the "Tier 1" yamls.
# default.yaml and vmnet.yaml are tested on GHA macOS.
TEMPLATE: alpine.yaml
TEMPLATE: debian.yaml
Expand All @@ -47,10 +47,10 @@ task:
TEMPLATE: opensuse.yaml
TEMPLATE: experimental/net-user-v2.yaml
lima_cache:
fingerprint_script: uname -s ; cat examples/$TEMPLATE
fingerprint_script: uname -s ; cat templates/$TEMPLATE
folder: /home/testuser/.cache/lima
lima_cache_fix_perm_script: chown -R testuser.testuser /home/testuser
test_script: sudo -iu testuser $(pwd)/hack/test-example.sh $(pwd)/examples/$TEMPLATE
test_script: sudo -iu testuser $(pwd)/hack/test-templates.sh $(pwd)/templates/$TEMPLATE

colima_task:
<<: *common_template
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ jobs:
run: make
- name: Install
run: make install
- name: Validate examples
run: find examples -name '*.yaml' | xargs limactl validate
- name: Validate templates
run: find -L templates -name '*.yaml' | xargs limactl validate
- name: Install test dependencies
# QEMU: required by Lima itself
# bash: required by test-example.sh (OS version of bash is too old)
# coreutils: required by test-example.sh for the "timeout" command
# curl: required by test-example.sh to download nerdctl for alpine
# jq: required by test-example.sh to determine download URL for nerdctl
# bash: required by test-templates.sh (OS version of bash is too old)
# coreutils: required by test-templates.sh for the "timeout" command
# curl: required by test-templates.sh to download nerdctl for alpine
# jq: required by test-templates.sh to determine download URL for nerdctl
run: |
set -x
# Github runners seem to have lima installed by brew already; we don't want/need it
Expand All @@ -106,28 +106,28 @@ jobs:
timeout_minutes: 30
retry_on: error
max_attempts: 3
command: ./hack/test-example.sh examples/default.yaml
command: ./hack/test-templates.sh templates/default.yaml
- name: "Test alpine.yaml"
uses: nick-invision/retry@v2
with:
timeout_minutes: 30
retry_on: error
max_attempts: 3
command: ./hack/test-example.sh examples/alpine.yaml
command: ./hack/test-templates.sh templates/alpine.yaml
- name: "Test experimental/9p.yaml"
uses: nick-invision/retry@v2
with:
timeout_minutes: 30
retry_on: error
max_attempts: 3
command: ./hack/test-example.sh examples/experimental/9p.yaml
command: ./hack/test-templates.sh templates/experimental/9p.yaml
- name: "Test test-misc.yaml"
uses: nick-invision/retry@v2
with:
timeout_minutes: 30
retry_on: error
max_attempts: 3
command: ./hack/test-example.sh hack/test-templates/test-misc.yaml
command: ./hack/test-templates.sh hack/test-templates/test-misc.yaml
# GHA macOS is slow and flaky, so we only test a few YAMLS here.
# Other yamls are tested on Linux instances of Cirrus.

Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
timeout_minutes: 30
retry_on: error
max_attempts: 3
command: ./hack/test-example.sh examples/vmnet.yaml
command: ./hack/test-templates.sh templates/vmnet.yaml
- name: Install socket_vmnet
env:
SOCKET_VMNET_VERSION: v1.1.1
Expand All @@ -199,7 +199,7 @@ jobs:
timeout_minutes: 30
retry_on: error
max_attempts: 3
command: ./hack/test-example.sh examples/vmnet.yaml
command: ./hack/test-templates.sh templates/vmnet.yaml

upgrade:
name: "Upgrade test"
Expand Down Expand Up @@ -253,4 +253,4 @@ jobs:
path: ~/Library/Caches/lima/download
key: ${{ runner.os }}-vz
- name: Test
run: ./hack/test-example.sh examples/experimental/vz.yaml
run: ./hack/test-templates.sh templates/experimental/vz.yaml
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ minimal: clean \
_output/bin/limactl$(exe) \
codesign \
_output/share/lima/lima-guestagent.Linux-$(shell uname -m | sed -e s/arm64/aarch64/)
mkdir -p _output/share/lima/examples
cp -aL examples/default.yaml _output/share/lima/examples/
mkdir -p _output/share/lima/templates
cp -aL examples/default.yaml _output/share/lima/templates/

.PHONY: binaries
binaries: clean \
Expand All @@ -59,14 +59,21 @@ binaries: clean \
_output/share/lima/lima-guestagent.Linux-aarch64 \
_output/share/lima/lima-guestagent.Linux-armv7l \
_output/share/lima/lima-guestagent.Linux-riscv64
cp -aL examples _output/share/lima
cp -aL examples _output/share/lima/templates
ifneq ($(GOOS),windows)
ln -sf templates _output/share/lima/examples
else
cp -aL examples _output/share/lima/examples
endif
mkdir -p _output/share/doc/lima
cp -aL *.md LICENSE docs _output/share/doc/lima
echo "Moved to https://github.com/lima-vm/.github/blob/main/SECURITY.md" >_output/share/doc/lima/SECURITY.md
ifneq ($(GOOS),windows)
ln -sf ../../lima/examples _output/share/doc/lima
ln -sf ../../lima/templates _output/share/doc/lima/templates
ln -sf templates _output/share/doc/lima/examples
else
cp -aL examples _output/share/doc/lima
cp -aL examples _output/share/doc/lima/examples
cp -aL examples _output/share/doc/lima/templates
endif
echo $(VERSION) > _output/share/doc/lima/VERSION

Expand Down
6 changes: 3 additions & 3 deletions cmd/limactl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ func main() {
}

func newApp() *cobra.Command {
examplesDir := "$PREFIX/share/doc/lima/examples"
templatesDir := "$PREFIX/share/lima/templates"
if exe, err := os.Executable(); err == nil {
binDir := filepath.Dir(exe)
prefixDir := filepath.Dir(binDir)
examplesDir = filepath.Join(prefixDir, "share/doc/lima/examples")
templatesDir = filepath.Join(prefixDir, "share/lima/templates")
}

var rootCmd = &cobra.Command{
Expand All @@ -51,7 +51,7 @@ func newApp() *cobra.Command {
Stop the default instance:
$ limactl stop
See also example YAMLs: %s`, examplesDir),
See also template YAMLs: %s`, templatesDir),
SilenceUsage: true,
SilenceErrors: true,
DisableAutoGenTag: true,
Expand Down
2 changes: 1 addition & 1 deletion cmd/limactl/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ To see the template list:
$ limactl create --list-templates
To create an instance "default" from a local file:
$ limactl create --name=default /usr/local/share/lima/examples/fedora.yaml
$ limactl create --name=default /usr/local/share/lima/templates/fedora.yaml
To create an instance "default" from a remote URL (use carefully, with a trustable source):
$ limactl create --name=default https://raw.githubusercontent.com/lima-vm/lima/master/examples/alpine.yaml
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Lima examples
# Lima templates

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

Expand Down
6 changes: 3 additions & 3 deletions hack/test-port-forwarding.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# rules (before the instance is started). And once when the instance is
# running to perform the tests:
#
# ./hack/test-port-forwarding.pl examples/default.yaml
# limactl start --tty=false examples/default.yaml
# git restore examples/default.yaml
# ./hack/test-port-forwarding.pl templates/default.yaml
# limactl start --tty=false templates/default.yaml
# git restore templates/default.yaml
# ./hack/test-port-forwarding.pl default
#
# TODO: support for ipv6 host addresses
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions pkg/templatestore/templatestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Read(name string) ([]byte, error) {
if err != nil {
return nil, err
}
yamlPath, err := securejoin.SecureJoin(filepath.Join(dir, "examples"), name+".yaml")
yamlPath, err := securejoin.SecureJoin(filepath.Join(dir, "templates"), name+".yaml")
if err != nil {
return nil, err
}
Expand All @@ -34,7 +34,7 @@ func Templates() ([]Template, error) {
if err != nil {
return nil, err
}
examplesDir := filepath.Join(usrlocalsharelimaDir, "examples")
templatesDir := filepath.Join(usrlocalsharelimaDir, "templates")

var res []Template
walkDirFn := func(p string, d fs.DirEntry, err error) error {
Expand All @@ -47,13 +47,13 @@ func Templates() ([]Template, error) {
}
x := Template{
// Name is like "default", "debian", "deprecated/centos-7", ...
Name: strings.TrimSuffix(strings.TrimPrefix(p, examplesDir+"/"), ".yaml"),
Name: strings.TrimSuffix(strings.TrimPrefix(p, templatesDir+"/"), ".yaml"),
Location: p,
}
res = append(res, x)
return nil
}
if err = filepath.WalkDir(examplesDir, walkDirFn); err != nil {
if err = filepath.WalkDir(templatesDir, walkDirFn); err != nil {
return nil, err
}
return res, nil
Expand Down
1 change: 1 addition & 0 deletions templates

0 comments on commit 2ee1efa

Please sign in to comment.