Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,16 @@ bats: native limactl-plugins

.PHONY: lint
lint: check-generated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not executed in CI

# Check for trailing whitespace. -I skips binary files (images, etc.)
! git grep -rn -I '[[:space:]]$$' -- . || \
(echo "Please remove trailing whitespace from the lines listed above" && false)
# Check that all text files end with a newline. -I skips most binary
# files, but not .pb.desc (protobuf descriptors), which contain enough
# text-like content to appear as text to git.
@result=$$(git grep -rIl '' -- . ':!*.pb.desc' | while IFS= read -r f; do \
test "$$(tail -c 1 "$$f")" && echo "$$f: missing newline at end of file"; \
done); \
if [ -n "$$result" ]; then echo "$$result"; echo "Please ensure all text files end with a newline"; false; fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can rather use https://github.com/editorconfig-checker/editorconfig-checker or something else existing

golangci-lint run ./...
yamllint .
ls-lint
Expand Down
2 changes: 1 addition & 1 deletion hack/bats/extras/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
The extra tests located in this directory are not automatically executed via `make bats`.

Some tests are executed on the CI, some ones are not.
Refer to the configuration of the GitHub Actions to see what tests are executed.
Refer to the configuration of the GitHub Actions to see what tests are executed.
2 changes: 1 addition & 1 deletion hack/bats/tests/mcp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ tools_call() {
}

@test 'glob returns an empty list when the pattern does not match' {

tools_call glob '{"pattern":"nothing.to.see"}'

run_yq '.structuredContent.matches[]' <<<"$output"
Expand Down
12 changes: 6 additions & 6 deletions hack/bats/tests/preserve-env.bats
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ local_setup() {
export BARBAZ=barbaz
export LD_UID=randomuid
run -0 limactl shell --preserve-env "$NAME" printenv

assert_line SSH_FOO=ssh_foo
assert_line BAR=bar
assert_line BARBAZ=barbaz
assert_line LD_UID=randomuid

refute_line --regexp '^SSH_BAR='
refute_line --regexp '^SSH_BLOCK='
}
Expand All @@ -145,11 +145,11 @@ local_setup() {
export NORMAL_VAR=normal_var
export UNRELATED=unrelated
run -0 limactl shell --preserve-env "$NAME" printenv

refute_line --regexp '^FOOBAR='
refute_line --regexp '^FOOXYZBAR='
refute_line --regexp '^FOOXYZBAR='
refute_line --regexp '^XFOOYBARZDOTCOM='

assert_line FOOBAZ=foobaz
assert_line NORMAL_VAR=normal_var
assert_line UNRELATED=unrelated
Expand All @@ -167,7 +167,7 @@ local_setup() {
export MY_TOKEN=my_token
export UNRELATED=unrelated
run -0 limactl shell --preserve-env "$NAME" printenv

assert_line SSH_AUTH_SOCK=ssh_auth_sock
assert_line SSH_CONNECTION=ssh_connection
assert_line CUSTOM_VAR=custom_var
Expand Down
42 changes: 21 additions & 21 deletions hack/bats/tests/shell-sync.bats
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ setup() {
mkdir -p "$TEST_SYNC_DIR"
touch "$TEST_SYNC_DIR/foo.txt"
touch "$TEST_SYNC_DIR/bar.txt"

# Create a simple script that makes changes to these files
cat > "$TEST_SYNC_DIR/modify.sh" << 'EOF'
#!/bin/sh
Expand All @@ -60,13 +60,13 @@ teardown() {

@test 'shell --sync preserves working directory path from host to guest' {
cd "$TEST_SYNC_DIR"

# Get path of the TEST_SYNC_DIR for verification
local path_test_dir
path_test_dir="$PWD"

run -0 bash -c "limactl shell --sync . --yes '$NAME' pwd && ./modify.sh"

# Verify the guest working directory matches the host path structure
assert_output --regexp ".*${path_test_dir#/}"

Expand All @@ -83,13 +83,13 @@ teardown() {
mkdir -p "$special_dir"
mv "$TEST_SYNC_DIR" "$special_dir"
cd "$special_dir/sync-test"

# Count files before sync
local files_before
files_before=$(find . -type f | wc -l)

run -0 bash -c "limactl shell --sync . --yes '$NAME' ./modify.sh"

# Verify files were modified
run cat "$special_dir/sync-test/foo.txt"
assert_output "modified foo"
Expand All @@ -100,22 +100,22 @@ teardown() {
local files_after
files_after=$(find "$special_dir/sync-test" -type f | wc -l)
[[ $files_after -eq $files_before ]]

# Cleanup
rm -rf "$special_dir"
}

@test 'shell --sync reflects file deletion from guest to host' {
cd "$TEST_SYNC_DIR"

run -0 bash -c "limactl shell --sync . --yes '$NAME' rm -f foo.txt"
assert_file_not_exists "$TEST_SYNC_DIR/foo.txt"

assert_file_not_exists "$TEST_SYNC_DIR/foo.txt"
}

@test 'shell --sync reflects new directory and file creation from guest to host' {
cd "$TEST_SYNC_DIR"

# Create a script that creates a new directory with a file
cat > "$TEST_SYNC_DIR/create_new.sh" << 'EOF'
#!/bin/sh
Expand All @@ -124,13 +124,13 @@ mkdir -p new_directory
echo "foo bar baz" > new_directory/new_file.txt
EOF
chmod +x "$TEST_SYNC_DIR/create_new.sh"

run -0 bash -c "limactl shell --sync . --yes '$NAME' ./create_new.sh && ./modify.sh"

# Verify new directory was created on host
assert_dir_exists "$TEST_SYNC_DIR/new_directory"
assert_file_exists "$TEST_SYNC_DIR/new_directory/new_file.txt"

# Verify file content
run cat "$TEST_SYNC_DIR/new_directory/new_file.txt"
assert_output "foo bar baz"
Expand All @@ -142,14 +142,14 @@ EOF

@test 'shell --sync preserves file permissions' {
cd "$TEST_SYNC_DIR"

# Create a file with specific permissions
touch "$TEST_SYNC_DIR/executable.sh"
chmod 755 "$TEST_SYNC_DIR/executable.sh"

# Modify the file in guest
run -0 bash -c "limactl shell --sync . --yes '$NAME' ./modify.sh"

# Verify file is still executable on host
if [[ "$OSTYPE" == darwin* ]]; then
run stat -f '%A' "$TEST_SYNC_DIR/executable.sh"
Expand All @@ -167,18 +167,18 @@ EOF

@test 'shell --sync works without existing ControlMaster socket' {
cd "$TEST_SYNC_DIR"

# Remove the ControlMaster socket
local sock_path="$LIMA_HOME/$NAME/ssh.sock"
if [[ -S "$sock_path" ]]; then
rm "$sock_path"
fi

run -0 bash -c "limactl shell --sync . --yes '$NAME' ./modify.sh"

# Verify files were modified
run cat "$TEST_SYNC_DIR/foo.txt"
assert_output "modified foo"
run cat "$TEST_SYNC_DIR/bar.txt"
assert_output "modified bar"
}
}
4 changes: 2 additions & 2 deletions hack/test-port-forwarding.pl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
/^(forward|ignore):\s+([0-9.:]+)\s+(\d+)(?:\s+→)?(?:\s+(?:([0-9.:]+)(?:\s+(\d+))|(\S+))?)?/;
die "Cannot parse test '$_'" unless $1;
my %test; @test{qw(mode guest_ip guest_port host_ip host_port host_socket)} = ($1, $2, $3, $4, $5, $6);

$test{host_ip} ||= "127.0.0.1";
$test{host_port} ||= $test{guest_port};
$test{host_socket} ||= "";
Expand Down Expand Up @@ -300,7 +300,7 @@
foreach (keys %failed_to_listen_tcp) {
print "⚠️ $failed_to_listen_tcp{$_}\n";
}
my @tcp_list = keys %failed_to_listen_tcp;
my @tcp_list = keys %failed_to_listen_tcp;
if ($Config{osname} eq "darwin") {
my @lsof_args = map { "-iTCP\@$_" } @tcp_list;
print `lsof -P @lsof_args`;
Expand Down
2 changes: 1 addition & 1 deletion hack/update-template-almalinux-kitten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Description:

https://kitten.repo.almalinux.org/<major version>-kitten/cloud/<arch>/images/

To parsing html, this script requires 'htmlq' or 'pup' command.
To parsing html, this script requires 'htmlq' or 'pup' command.
The downloaded files will be cached in the Lima cache directory.

Examples:
Expand Down
2 changes: 1 addition & 1 deletion hack/update-template-almalinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Description:

https://repo.almalinux.org/almalinux/<major version>/cloud/<arch>/images/

To parsing html, this script requires 'htmlq' or 'pup' command.
To parsing html, this script requires 'htmlq' or 'pup' command.
The downloaded files will be cached in the Lima cache directory.

Examples:
Expand Down
2 changes: 1 addition & 1 deletion hack/update-template-alpine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Description:
latest-stable: https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/cloud
<major>.<minor>: https://dl-cdn.alpinelinux.org/alpine/v<major>.<minor>/releases/cloud

To parsing html, this script requires 'htmlq' or 'pup' command.
To parsing html, this script requires 'htmlq' or 'pup' command.
The downloaded files will be cached in the Lima cache directory.

Examples:
Expand Down
4 changes: 2 additions & 2 deletions hack/update-template-archlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Description:
x86_64:
listing: https://gitlab.archlinux.org/api/v4/projects/archlinux%2Farch-boxes/packages
details: https://gitlab.archlinux.org/api/v4/projects/archlinux%2Farch-boxes/packages/:package_id/package_files

aarch64:
https://github.com/mcginty/arch-boxes-arm/releases/

Using 'gh' CLI tool for fetching the latest release from GitHub.

Examples:
Expand Down
4 changes: 2 additions & 2 deletions hack/update-template-centos-stream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Description:

https://cloud.centos.org/centos/<major version>-stream/<arch>/images/

To parsing html, this script requires 'htmlq' or 'pup' command.
To parsing html, this script requires 'htmlq' or 'pup' command.
The downloaded files will be cached in the Lima cache directory.

Examples:
Expand Down Expand Up @@ -104,7 +104,7 @@ function centos_latest_image_entry_for_url_spec() {
fi
latest_info=$(jq -e -Rrs --argjson spec "${url_spec}" '
[
split("\n").[] |
split("\n").[] |
capture(
"^CentOS-Stream-\($spec.target_vendor)-\($spec.version)-(?<date_and_ci_job_id>\\d{8}\\.\\d+)\\.\($spec.arch)\\.\($spec.file_extension)$"
;"x"
Expand Down
6 changes: 3 additions & 3 deletions hack/update-template-opensuse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Description:
<major>.<minor>: https://download.opensuse.org/distribution/leap/<major>.<minor>/appliances/?jsontable
current: https://download.opensuse.org/distribution/openSUSE-current/appliances/?jsontable
stable: https://download.opensuse.org/distribution/openSUSE-stable/appliances/?jsontable

Tumbleweed:
x86_64: https://download.opensuse.org/tumbleweed/appliances/?jsontable
not x86_64: https://download.opensuse.org/ports/<arch>/tumbleweed/appliances/?jsontable
Expand All @@ -51,7 +51,7 @@ Examples:
$ limactl factory-reset opensuse

Flags:
--version-major-minor (<major>.<minor>|current|stable|tumbleweed) Use the specified <major>.<minor> version or
--version-major-minor (<major>.<minor>|current|stable|tumbleweed) Use the specified <major>.<minor> version or
aliases "current", "stable", or "tumbleweed".
The <major>.<minor> version must be 15.0 or later.
--version-major <major> --version-minor <minor> Use the specified <major> and <minor> version.
Expand All @@ -72,7 +72,7 @@ function opensuse_url_spec_from_location() {
)/appliances/
openSUSE-(?<version>Leap-\\d+\\.\\d+|Tumbleweed)-Minimal-VM
\\.(?<arch>[^-]+)(?<major_minor_patch>-\\d+\\.\\d+\\.\\d+)?-(?<target_vendor>.*)(?<build_info>-Build\\d+\\.\\d+)?\\.(?<file_extension>.*)$
";"x") |
";"x") |
.path_version = (.path_version_leap // .path_version_leap_alias // .path_version_tumbleweed)
'
url_spec=$(jq -e -r "${jq_filter}" <<<"\"${location}\"")
Expand Down
2 changes: 1 addition & 1 deletion hack/update-template-oraclelinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Description:
OL8:
x86_64: https://yum.oracle.com/templates/OracleLinux/ol8-template.json
aarch64: https://yum.oracle.com/templates/OracleLinux/ol8_aarch64-cloud-template.json

OL9:
x86_64: https://yum.oracle.com/templates/OracleLinux/ol9-template.json
aarch64: https://yum.oracle.com/templates/OracleLinux/ol9_aarch64-cloud-template.json
Expand Down
2 changes: 1 addition & 1 deletion hack/update-template-rocky.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Description:

https://dl.rockylinux.org/pub/rocky/<major version>/images/<arch>/

To parsing html, this script requires 'htmlq' or 'pup' command.
To parsing html, this script requires 'htmlq' or 'pup' command.
The downloaded files will be cached in the Lima cache directory.

Examples:
Expand Down
2 changes: 1 addition & 1 deletion hack/update-template-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function ubuntu_image_url_release() {
jq_filter="
[
.products | to_entries[] as \$product_entry |
\$product_entry.value| select(.version == \"${version}\") |
\$product_entry.value| select(.version == \"${version}\") |
.release
] | first
"
Expand Down
6 changes: 4 additions & 2 deletions pkg/autostart/autostart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func TestRenderTemplate(t *testing.T) {
<key>ProcessType</key>
<string>Background</string>
</dict>
</plist>`,
</plist>
`,
GetExecutable: func() (string, error) {
return "/limactl", nil
},
Expand All @@ -94,7 +95,8 @@ TimeoutSec=10
Restart=on-failure

[Install]
WantedBy=default.target`,
WantedBy=default.target
`,
GetExecutable: func() (string, error) {
return "/limactl", nil
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/autostart/launchd/io.lima-vm.autostart.INSTANCE.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
<key>ProcessType</key>
<string>Background</string>
</dict>
</plist>
</plist>
2 changes: 1 addition & 1 deletion pkg/autostart/systemd/lima-vm@INSTANCE.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ TimeoutSec=10
Restart=on-failure

[Install]
WantedBy=default.target
WantedBy=default.target
6 changes: 3 additions & 3 deletions pkg/cidata/cidata.TEMPLATE.d/boot/08-shell-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ "${LIMA_CIDATA_NAME}" = "default" ] && command -v patch >/dev/null 2>&1 &&

patch --forward -r - "${LIMA_CIDATA_HOME}/.bashrc" <<'EOF'
@@ -37,7 +37,11 @@

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
- xterm-color|*-256color) color_prompt=yes;;
Expand All @@ -25,12 +25,12 @@ if [ "${LIMA_CIDATA_NAME}" = "default" ] && command -v patch >/dev/null 2>&1 &&
+case "$COLORTERM" in
+ truecolor) color_prompt=true;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
@@ -56,7 +60,12 @@
fi
fi

-if [ "$color_prompt" = yes ]; then
+# Lima PS1: set color to lime green
+if [ "$color_prompt" = true ]; then
Expand Down
Loading
Loading