Skip to content

Add environment variables documentation #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 96 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
597c276
cmd/limactl: return error instead of calling os.Exit
alexandear Jun 19, 2024
aa15485
cidata: fix upgrading nerdctl
AkihiroSuda Feb 2, 2024
368f175
Shorten the descriptions to fit in width 100
afbjorklund Jan 22, 2023
3b62090
Merge pull request #2453 from afbjorklund/shorten-descriptions
jandubois Jun 30, 2024
ce3c041
Move GuestAgentBinary to usrlocalsharelima
afbjorklund Nov 22, 2023
3d495ed
Allow compressing lima-guestagent with gzip
afbjorklund Jun 23, 2024
d470f8b
Merge pull request #2447 from AkihiroSuda/fix-upgrade-nerdctl
AkihiroSuda Jun 30, 2024
91cc83d
templates: remove centos-stream-8, deprecated/centos-7
AkihiroSuda Jul 1, 2024
fc41244
Merge pull request #2457 from AkihiroSuda/remove-centos7
AkihiroSuda Jul 1, 2024
1b54ed4
Move open and gzip back to cidata again
afbjorklund Jun 30, 2024
8a03c40
build(deps): bump github.com/sethvargo/go-password from 0.2.0 to 0.3.1
dependabot[bot] Jul 1, 2024
caced74
Merge pull request #2438 from afbjorklund/guest-gzip
jandubois Jul 1, 2024
9f8b406
Merge pull request #2445 from lima-vm/dependabot/go_modules/github.co…
AkihiroSuda Jul 2, 2024
bb9e31b
Merge pull request #2430 from alexandear/refactor/deep-exit
AkihiroSuda Jul 2, 2024
ab6fd8c
boot/04-persistent-data-volume.sh: fix 9p cache options
AkihiroSuda Jul 2, 2024
a59ac75
pkg/store: split pkg/version/versionutil
AkihiroSuda Jul 2, 2024
0c6da72
Merge pull request #2461 from AkihiroSuda/split-versionutil
jandubois Jul 2, 2024
c39d98f
build(deps): bump github.com/containerd/containerd from 1.7.18 to 1.7.19
dependabot[bot] Jul 3, 2024
9cec780
build(deps): bump google.golang.org/grpc from 1.64.0 to 1.65.0
dependabot[bot] Jul 3, 2024
917398d
Merge pull request #2463 from lima-vm/dependabot/go_modules/google.go…
jandubois Jul 3, 2024
9997d6d
Merge pull request #2460 from AkihiroSuda/fix-9p
jandubois Jul 3, 2024
674cc15
Merge pull request #2462 from lima-vm/dependabot/go_modules/github.co…
jandubois Jul 3, 2024
2d2d9a8
docs: remove redundant dot in examples
alexandear Jul 3, 2024
118c249
Merge pull request #2464 from alexandear/docs/examples-redundant-dot
jandubois Jul 3, 2024
22dcd62
Add default value for audio driver
afbjorklund Jun 30, 2024
a232747
Add qemu example for running alsa
afbjorklund Jul 2, 2024
e78fe9c
Add sudo when trying to read fuse.conf
afbjorklund Jul 4, 2024
1716141
build(deps): bump golang.org/x/sys in the golang-x group
dependabot[bot] Jul 5, 2024
c23d4fe
Merge pull request #2467 from lima-vm/dependabot/go_modules/golang-x-…
jandubois Jul 5, 2024
ce73395
Merge pull request #2466 from afbjorklund/fuse-grep
jandubois Jul 5, 2024
af048c4
Allow using default and none in vz
afbjorklund Jul 3, 2024
c322721
Refactor to use switch instead of if-else chain
alexandear Jul 5, 2024
04363c0
Merge pull request #2456 from afbjorklund/audio-default
jandubois Jul 5, 2024
44f4e5d
Merge pull request #2469 from alexandear/refactor/gocritic-if-else-chain
jandubois Jul 5, 2024
cfa6aca
build(deps): bump golang.org/x/net in the golang-x group
dependabot[bot] Jul 8, 2024
463ed82
Merge pull request #2472 from lima-vm/dependabot/go_modules/golang-x-…
jandubois Jul 8, 2024
f28f585
Fix panic in stop when the VM goes away
alexandear Jul 8, 2024
51d800b
website: remove technical info from 404 page
alexandear Jul 9, 2024
497e567
Merge pull request #2475 from alexandear/fix/panic-stop-on-delete
jandubois Jul 9, 2024
0cfd535
Merge pull request #2477 from alexandear/docs/404-remove-technical-info
jandubois Jul 9, 2024
35ccb6a
Unify file and dir names; integrate ls-lint
alexandear Jul 9, 2024
01bf4b5
add fuzz test for store package
AdamKorcz Jul 10, 2024
0f5fef5
build(deps): bump github.com/cyphar/filepath-securejoin
dependabot[bot] Jul 12, 2024
a173705
create file in t.TempDir()
AdamKorcz Jul 12, 2024
5323b68
remove empty variables
AdamKorcz Jul 12, 2024
078779c
add fuzz test for IsISO9660
AdamKorcz Jul 12, 2024
8a38520
add fuzz test for setupEnv
AdamKorcz Jul 12, 2024
fe52a10
add fuzz test for procnettcp parsing
AdamKorcz Jul 15, 2024
cb27d68
Merge pull request #2482 from AdamKorcz/fuzz3
jandubois Jul 16, 2024
dd5d57e
Merge pull request #2478 from AdamKorcz/fuzz1
jandubois Jul 16, 2024
a0d1227
Merge pull request #2481 from lima-vm/dependabot/go_modules/github.co…
jandubois Jul 16, 2024
d947f7e
Merge pull request #2483 from AdamKorcz/fuzz4
jandubois Jul 16, 2024
2be8886
Merge pull request #2484 from AdamKorcz/fuzz5
jandubois Jul 16, 2024
aaf8b9c
Merge pull request #2476 from alexandear/unify-filenames
AkihiroSuda Jul 16, 2024
7b08d5b
Remove the embedded default user in alpine cloud
afbjorklund May 25, 2024
43d66a5
Merge pull request #2364 from afbjorklund/alpine-user-group
jandubois Jul 16, 2024
28ed94b
add fust test for downloader
AdamKorcz Jul 16, 2024
0f21216
Merge pull request #2485 from AdamKorcz/fuzz5
jandubois Jul 16, 2024
2302641
Create `rosetta.conf` for `binfmt.d(5)`
norio-nomura Jul 7, 2024
ba11ab5
Mount the rosetta volume in `user-data`
norio-nomura Jul 7, 2024
50c10f3
Change comment to using template syntax
norio-nomura Jul 10, 2024
7c13a72
Remove mounting vz-rosetta from 05-rosetta-volume.sh
norio-nomura Jul 11, 2024
5ef067b
Unregister rosetta if `.rosetta.binfmt` is not true
norio-nomura Jul 13, 2024
f317289
Bump alpine-image 3.19.1 → 3.20.1
jandubois Jul 17, 2024
f53aa8b
build(deps): bump github.com/goccy/go-yaml from 1.11.3 to 1.12.0
dependabot[bot] Jul 17, 2024
de9c075
Make sure /proc/sys/fs/binfmt_misc has been mounted (on Alpine)
jandubois Jul 17, 2024
598f45f
Merge pull request #2474 from norio-nomura/prioritize-rosetta-over-qemu
jandubois Jul 17, 2024
8ecee92
Merge pull request #2487 from lima-vm/dependabot/go_modules/github.co…
jandubois Jul 17, 2024
b4189e8
Merge pull request #2486 from rancher-sandbox/alpine-image-3.20.1
jandubois Jul 17, 2024
7295d3b
Merge pull request #2488 from rancher-sandbox/mount-proc-sys-fs-binfmt
AkihiroSuda Jul 17, 2024
50de4ad
Add unmarshal unit test for default.yaml
afbjorklund May 10, 2024
a5f790c
Add marshal unit test for default.yaml
afbjorklund May 10, 2024
e20f879
Use builtin default for ssh.localPort
afbjorklund May 10, 2024
1a101d2
Omit empty values for default rosetta
afbjorklund May 10, 2024
5524c02
Store time of Last-Modified in cache dir
afbjorklund May 27, 2024
e8841f6
Store type of Content-Type in cache dir
afbjorklund May 27, 2024
cf20b24
Return contents and not path in result
afbjorklund May 27, 2024
d6bddec
Use time.Time not string for LastModified
afbjorklund Jun 2, 2024
1d1ce3c
Merge pull request #2368 from afbjorklund/cache-time
AkihiroSuda Jul 17, 2024
b84dd65
Update pkg/limayaml/limayaml_test.go
afbjorklund Jul 17, 2024
486b90b
Merge pull request #2334 from afbjorklund/limayaml-test
jandubois Jul 17, 2024
8df844e
vz: configure Rosetta’s ahead of time (AOT) caching options using an …
norio-nomura Jul 17, 2024
4d44ece
add fuzz test for yqutil
AdamKorcz Jul 18, 2024
980869d
Merge pull request #2491 from AdamKorcz/fuzz5
jandubois Jul 18, 2024
6fa9145
Merge pull request #2489 from norio-nomura/set-rosetta-abstract-socke…
jandubois Jul 19, 2024
54bc5b5
limactl stop: extend the timeout for waiting for the hostAgent to stop
norio-nomura Jul 19, 2024
e3eff00
Merge pull request #2493 from norio-nomura/allow-the-host-agent-some-…
jandubois Jul 19, 2024
119883a
executil: change ctx parameter to be non-pointer
alexandear Jul 21, 2024
6b99644
add fuzz test for ConvertToRaw
AdamKorcz Jul 10, 2024
c42e746
add fuzzer for Inspect
AdamKorcz Jul 22, 2024
67d3be3
Merge pull request #2500 from AdamKorcz/fuzz6
jandubois Jul 22, 2024
65ae991
Merge pull request #2479 from AdamKorcz/fuzz2
jandubois Jul 22, 2024
db7f60f
Merge pull request #2497 from alexandear/change/with-context-non-poin…
jandubois Jul 22, 2024
5d3e51e
limactl start: fix the issue where using `--set` would overwrite the …
norio-nomura Jul 22, 2024
495db7a
Merge pull request #2501 from norio-nomura/validate-libyaml-before-ov…
AkihiroSuda Jul 23, 2024
beabc0b
Add environment variables documentation
SmartManoj Aug 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Run file and directory name linter
uses: ls-lint/[email protected]
- name: Run shellcheck
run: find . -name '*.sh' | xargs shellcheck
- name: Install shfmt
Expand Down
32 changes: 31 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,42 @@ linters-settings:
- rangeValCopy
- hugeParam
- importShadow
- ifElseChain
- sprintfQuotedString
- builtinShadow
- filepathJoin
settings:
ifElseChain:
# Min number of if-else blocks that makes the warning trigger.
minThreshold: 3
errorlint:
asserts: false
revive:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: deep-exit
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
- name: increment-decrement
- name: indent-error-flow
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: unreachable-code
- name: unused-parameter
- name: var-declaration
- name: var-naming
issues:
# Maximum issues count per one linter.
max-issues-per-linter: 0
Expand Down
34 changes: 34 additions & 0 deletions .ls-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ls-lint configuration file.
# https://ls-lint.org/2.2/configuration/the-basics.html
ls:
.dir: kebab-case
.go: snake_case
.lima: snake_case
.sh: kebab-case
.TEMPLATE.yaml: kebab-case
.yaml: kebab-case
.yml: kebab-case

.github:
.yaml: snake_case

cmd/limactl:
# valid names are `show-ssh.go` or `show-ssh_test.go`
.go: kebab-case | regex:[a-z0-9-]+_test

docs:
.md: kebab-case

website/content:
.dir: lowercase

ignore:
- .git
- .golangci.yml
- .ls-lint.yml
- '_output'
- '**/*.pb\.go'
- hack/common.inc.sh
- pkg/cidata/cidata.TEMPLATE.d
- pkg/cidata/cidata.TEMPLATE.d/util/compare_version.sh
- website
6 changes: 6 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ config GUESTAGENT_ARCH_RISCV64
help
Build lima-guestagent for "riscv64" Arch
default y

config GUESTAGENT_COMPRESS
bool "guestagent compress"
help
Compress lima-guestagent
default n
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,26 @@ HELPERS = \
_output/bin/podman.lima \
_output/bin/kubectl.lima

ifeq ($(CONFIG_GUESTAGENT_COMPRESS),y)
gz = .gz
endif

ifeq ($(CONFIG_GUESTAGENT_OS_LINUX),y)
ifeq ($(CONFIG_GUESTAGENT_ARCH_X8664),y)
GUESTAGENT += \
_output/share/lima/lima-guestagent.Linux-x86_64
_output/share/lima/lima-guestagent.Linux-x86_64$(gz)
endif
ifeq ($(CONFIG_GUESTAGENT_ARCH_AARCH64),y)
GUESTAGENT += \
_output/share/lima/lima-guestagent.Linux-aarch64
_output/share/lima/lima-guestagent.Linux-aarch64$(gz)
endif
ifeq ($(CONFIG_GUESTAGENT_ARCH_ARMV7L),y)
GUESTAGENT += \
_output/share/lima/lima-guestagent.Linux-armv7l
_output/share/lima/lima-guestagent.Linux-armv7l$(gz)
endif
ifeq ($(CONFIG_GUESTAGENT_ARCH_RISCV64),y)
GUESTAGENT += \
_output/share/lima/lima-guestagent.Linux-riscv64
_output/share/lima/lima-guestagent.Linux-riscv64$(gz)
endif
endif

Expand Down Expand Up @@ -188,6 +192,9 @@ _output/share/lima/lima-guestagent.Linux-riscv64:
GOOS=linux GOARCH=riscv64 CGO_ENABLED=0 $(GO_BUILD) -o $@ ./cmd/lima-guestagent
chmod 644 $@

_output/share/lima/lima-guestagent.%.gz: _output/share/lima/lima-guestagent.%
gzip $<

.PHONY: manpages
manpages: _output/bin/limactl$(exe)
@mkdir -p _output/share/man/man1
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ GUI:
### Code of Conduct
Lima follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).

### Environment Variables
For more information on environment variables, see the [Environment Variables](https://lima-vm.io/docs/config/environment-variables/) page.

- - -
**We are a [Cloud Native Computing Foundation](https://cncf.io/) sandbox project.**

Expand All @@ -82,4 +85,4 @@ Lima follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/
<img src="https://www.cncf.io/wp-content/uploads/2022/07/cncf-color-bg.svg" width=300 />
</picture>

The Linux Foundation® (TLF) has registered trademarks and uses trademarks. For a list of TLF trademarks, see [Trademark Usage](https://www.linuxfoundation.org/trademark-usage/).
The Linux Foundation® (TLF) has registered trademarks and uses trademarks. For a list of TLF trademarks, see [Trademark Usage](https://www.linuxfoundation.org/trademark-usage/].
6 changes: 5 additions & 1 deletion cmd/docker.lima
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/sh
set -eu

# Environment Variables
# LIMA_INSTANCE: Specifies the name of the Lima instance to use. Default is "docker".

: "${LIMA_INSTANCE:=docker}"
: "${DOCKER:=docker}"

if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template://docker\` to create a new instance" >&2
exit 1
elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2
echo "instance \"$LIMA_INSTANCE\"" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2
exit 1
fi
DOCKER=$(command -v "$DOCKER" || true)
Expand Down
4 changes: 4 additions & 0 deletions cmd/kubectl.lima
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh
set -eu

# Environment Variables
# LIMA_INSTANCE: Specifies the name of the Lima instance to use. Default is empty.

: "${LIMA_INSTANCE:=}"
: "${KUBECTL:=kubectl}"

Expand Down
7 changes: 7 additions & 0 deletions cmd/lima
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/sh
set -eu

# Environment Variables
# LIMA_INSTANCE: Specifies the name of the Lima instance to use. Default is "default".
# LIMA_SHELL: Specifies the shell interpreter to use inside the Lima instance. Default is the user's shell configured inside the instance.
# LIMA_WORKDIR: Specifies the initial working directory inside the Lima instance. Default is the current directory from the host.
# LIMACTL: Specifies the path to the limactl binary. Default is "limactl" in $PATH.

: "${LIMA_INSTANCE:=default}"
: "${LIMA_SHELL:=}"
: "${LIMA_WORKDIR:=}"
Expand Down
12 changes: 8 additions & 4 deletions cmd/lima.bat
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
@echo off
IF NOT DEFINED LIMACTL (SET LIMACTL=limactl)
IF NOT DEFINED LIMA_INSTANCE (SET LIMA_INSTANCE=default)
%LIMACTL% shell %LIMA_INSTANCE% %*
@echo off
REM Environment Variables
REM LIMA_INSTANCE: Specifies the name of the Lima instance to use. Default is "default".
REM LIMACTL: Specifies the path to the limactl binary. Default is "limactl" in %PATH%.

IF NOT DEFINED LIMACTL (SET LIMACTL=limactl)
IF NOT DEFINED LIMA_INSTANCE (SET LIMA_INSTANCE=default)
%LIMACTL% shell %LIMA_INSTANCE% %*
17 changes: 15 additions & 2 deletions cmd/limactl/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ func instanceMatches(arg string, instances []string) []string {
return matches
}

// unmatchedInstancesError is created when unmatched instance names found.
type unmatchedInstancesError struct{}

// Error implements error.
func (unmatchedInstancesError) Error() string {
return "unmatched instances"
}

// ExitCode implements ExitCoder.
func (unmatchedInstancesError) ExitCode() int {
return 1
}

func listAction(cmd *cobra.Command, args []string) error {
quiet, err := cmd.Flags().GetBool("quiet")
if err != nil {
Expand Down Expand Up @@ -148,7 +161,7 @@ func listAction(cmd *cobra.Command, args []string) error {
fmt.Fprintln(cmd.OutOrStdout(), instName)
}
if unmatchedInstances {
os.Exit(1)
return unmatchedInstancesError{}
}
return nil
}
Expand Down Expand Up @@ -186,7 +199,7 @@ func listAction(cmd *cobra.Command, args []string) error {

err = store.PrintInstances(out, instances, format, &options)
if err == nil && unmatchedInstances {
os.Exit(1)
return unmatchedInstancesError{}
}
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/limactl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func handleExitCoder(err error) {
}

if exitErr, ok := err.(ExitCoder); ok {
os.Exit(exitErr.ExitCode())
os.Exit(exitErr.ExitCode()) //nolint:revive // it's intentional to call os.Exit in this function
return
}
}
Expand Down
File renamed without changes.
52 changes: 40 additions & 12 deletions cmd/limactl/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*

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

if ok, u := guessarg.SeemsTemplateURL(arg); ok {
isTemplateURL, templateURL := guessarg.SeemsTemplateURL(arg)
switch {
case isTemplateURL:
// No need to use SecureJoin here. https://github.com/lima-vm/lima/pull/805#discussion_r853411702
templateName := filepath.Join(u.Host, u.Path)
templateName := filepath.Join(templateURL.Host, templateURL.Path)
logrus.Debugf("interpreting argument %q as a template name %q", arg, templateName)
if st.instName == "" {
// e.g., templateName = "deprecated/centos-7" , st.instName = "centos-7"
Expand All @@ -140,7 +142,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
if err != nil {
return nil, err
}
} else if guessarg.SeemsHTTPURL(arg) {
case guessarg.SeemsHTTPURL(arg):
if st.instName == "" {
st.instName, err = guessarg.InstNameFromURL(arg)
if err != nil {
Expand All @@ -161,7 +163,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
if err != nil {
return nil, err
}
} else if guessarg.SeemsFileURL(arg) {
case guessarg.SeemsFileURL(arg):
if st.instName == "" {
st.instName, err = guessarg.InstNameFromURL(arg)
if err != nil {
Expand All @@ -178,7 +180,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
if err != nil {
return nil, err
}
} else if guessarg.SeemsYAMLPath(arg) {
case guessarg.SeemsYAMLPath(arg):
if st.instName == "" {
st.instName, err = guessarg.InstNameFromYAMLPath(arg)
if err != nil {
Expand All @@ -195,7 +197,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
if err != nil {
return nil, err
}
} else if arg == "-" {
case arg == "-":
if st.instName == "" {
return nil, errors.New("must pass instance name with --name when reading template from stdin")
}
Expand All @@ -209,7 +211,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
return nil, errors.New("cannot use --tty=true and read template from stdin together")
}
tty = false
} else {
default:
if arg == "" {
if st.instName == "" {
st.instName = DefaultInstanceName
Expand Down Expand Up @@ -292,6 +294,18 @@ func applyYQExpressionToExistingInstance(inst *store.Instance, yq string) (*stor
if err != nil {
return nil, err
}
y, err := limayaml.Load(yBytes, filePath)
if err != nil {
return nil, err
}
if err := limayaml.Validate(y, true); err != nil {
rejectedYAML := "lima.REJECTED.yaml"
if writeErr := os.WriteFile(rejectedYAML, yBytes, 0o644); writeErr != nil {
return nil, fmt.Errorf("the YAML is invalid, attempted to save the buffer as %q but failed: %w: %w", rejectedYAML, writeErr, err)
}
// TODO: may need to support editing the rejected YAML
return nil, fmt.Errorf("the YAML is invalid, saved the buffer as %q: %w", rejectedYAML, err)
}
if err := os.WriteFile(filePath, yBytes, 0o644); err != nil {
return nil, err
}
Expand Down Expand Up @@ -373,6 +387,21 @@ func modifyInPlace(st *creatorState, yq string) error {
return nil
}

// exitSuccessError is an error that indicates a successful exit.
type exitSuccessError struct {
Msg string
}

// Error implements error.
func (e exitSuccessError) Error() string {
return e.Msg
}

// ExitCode implements ExitCoder.
func (exitSuccessError) ExitCode() int {
return 0
}

func chooseNextCreatorState(st *creatorState, yq string) (*creatorState, error) {
for {
if err := modifyInPlace(st, yq); err != nil {
Expand Down Expand Up @@ -411,9 +440,9 @@ func chooseNextCreatorState(st *creatorState, yq string) (*creatorState, error)
return st, err
}
if len(st.yBytes) == 0 {
logrus.Info("Aborting, as requested by saving the file with empty content")
os.Exit(0)
return st, errors.New("should not reach here")
const msg = "Aborting, as requested by saving the file with empty content"
logrus.Info(msg)
return nil, exitSuccessError{Msg: msg}
}
return st, nil
case 2: // "Choose another template..."
Expand Down Expand Up @@ -446,8 +475,7 @@ func chooseNextCreatorState(st *creatorState, yq string) (*creatorState, error)
}
continue
case 3: // "Exit"
os.Exit(0)
return st, errors.New("should not reach here")
return nil, exitSuccessError{Msg: "Choosing to exit"}
default:
return st, fmt.Errorf("unexpected answer %q", ans)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/limactl/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func stopInstanceGracefully(inst *store.Instance) error {
}

func waitForHostAgentTermination(ctx context.Context, inst *store.Instance, begin time.Time) error {
ctx2, cancel := context.WithTimeout(ctx, 3*time.Minute)
ctx2, cancel := context.WithTimeout(ctx, 3*time.Minute+10*time.Second)
defer cancel()

var receivedExitingEvent bool
Expand Down
3 changes: 3 additions & 0 deletions cmd/limactl/usernet.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func usernetAction(cmd *cobra.Command, _ []string) error {
os.RemoveAll(qemuSocket)
os.RemoveAll(fdSocket)

// Environment Variables
// LIMA_USERNET_RESOLVE_IP_ADDRESS_TIMEOUT: Specifies the timeout duration for resolving IP addresses in minutes. Default is 2 minutes.

return usernet.StartGVisorNetstack(cmd.Context(), &usernet.GVisorNetstackOpts{
MTU: mtu,
Endpoint: endpoint,
Expand Down
Loading