Skip to content

Commit 186a840

Browse files
committed
examples: unembed default.yaml
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 65669f4 commit 186a840

File tree

10 files changed

+357
-360
lines changed

10 files changed

+357
-360
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ binaries: \
2323
_output/bin/nerdctl.lima \
2424
_output/share/lima/lima-guestagent.Linux-x86_64 \
2525
_output/share/lima/lima-guestagent.Linux-aarch64
26+
cp -aL examples _output/share/lima
2627
mkdir -p _output/share/doc/lima
27-
cp -aL README.md LICENSE docs examples _output/share/doc/lima
28+
cp -aL README.md LICENSE docs _output/share/doc/lima
29+
ln -sf ../../lima/examples _output/share/doc/lima
2830
echo $(VERSION) > _output/share/doc/lima/VERSION
2931

3032
.PHONY: _output/bin/lima
@@ -56,7 +58,8 @@ _output/share/lima/lima-guestagent.Linux-aarch64:
5658
.PHONY: install
5759
install:
5860
mkdir -p "$(DEST)"
59-
cp -av _output/* "$(DEST)"
61+
# Use tar rather than cp, for better symlink handling
62+
( cd _output && tar c * | tar Cxv "$(DEST)" )
6063
if [ "$(shell uname -s )" != "Linux" -a ! -e "$(DEST)/bin/nerdctl" ]; then ln -sf nerdctl.lima "$(DEST)/bin/nerdctl"; fi
6164

6265
.PHONY: uninstall

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Especially, the following data might be easily lost:
177177

178178
### Configuration
179179

180-
See [`./pkg/limayaml/default.yaml`](./pkg/limayaml/default.yaml).
180+
See [`./examples/default.yaml`](./examples/default.yaml).
181181

182182
The current default spec:
183183
- OS: Ubuntu 21.10 (Impish Indri)

cmd/limactl/info.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ type Info struct {
2828
}
2929

3030
func infoAction(cmd *cobra.Command, args []string) error {
31-
y, err := limayaml.Load(limayaml.DefaultTemplate, "")
31+
b, err := readDefaultTemplate()
32+
if err != nil {
33+
return err
34+
}
35+
y, err := limayaml.Load(b, "")
3236
if err != nil {
3337
return err
3438
}

cmd/limactl/start.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/lima-vm/lima/pkg/store"
2222
"github.com/lima-vm/lima/pkg/store/dirnames"
2323
"github.com/lima-vm/lima/pkg/store/filenames"
24+
"github.com/lima-vm/lima/pkg/usrlocalsharelima"
2425
"github.com/mattn/go-isatty"
2526
"github.com/norouter/norouter/cmd/norouter/editorcmd"
2627
"github.com/sirupsen/logrus"
@@ -39,6 +40,15 @@ func newStartCommand() *cobra.Command {
3940
return startCommand
4041
}
4142

43+
func readDefaultTemplate() ([]byte, error) {
44+
dir, err := usrlocalsharelima.Dir()
45+
if err != nil {
46+
return nil, err
47+
}
48+
defaultYAMLPath := filepath.Join(dir, "examples", "default.yaml")
49+
return os.ReadFile(defaultYAMLPath)
50+
}
51+
4252
func loadOrCreateInstance(cmd *cobra.Command, args []string) (*store.Instance, error) {
4353
var arg string
4454
if len(args) == 0 {
@@ -47,11 +57,12 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string) (*store.Instance, e
4757
arg = args[0]
4858
}
4959

50-
var (
51-
instName string
52-
yBytes = limayaml.DefaultTemplate
53-
err error
54-
)
60+
yBytes, err := readDefaultTemplate()
61+
if err != nil {
62+
return nil, err
63+
}
64+
65+
var instName string
5566

5667
const yBytesLimit = 4 * 1024 * 1024 // 4MiB
5768

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
Default: [`default.yaml`](../pkg/limayaml/default.yaml) (⭐Ubuntu, with containerd/nerdctl)
5+
Default: [`default.yaml`](./default.yaml) (⭐Ubuntu, with containerd/nerdctl)
66

77
Distro:
88
- [`almalinux.yaml`](./almalinux.yaml): AlmaLinux

examples/default.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)