Skip to content
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

Allow providing scripts as separate files #2442

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

afbjorklund
Copy link
Contributor

@afbjorklund afbjorklund commented Jun 24, 2024

The "path" provided will be read, and used instead of the "script".

provision:
- mode: user
  path: foo.sh

probes:
- mode: readiness
  path: bar.sh

There are some unsolved issues with this, regarding relative paths.

Currently it requires that limactl is always run from the top directory.

The paths PWD should probably be recorded in the instance directory?

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Jun 24, 2024

There are some issues with relative paths for the scripts, as has been discussed before...

Note: all the files/paths used here are on the host, and nothing is copied to the instance

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Jun 24, 2024

The provision scripts are recorded in the cidata.iso, so they should be OK with changing directory.

But the probes are run from the hostagent, so they don't really record the "working directory" now.

EDIT: duh, the lima-hostagent does have a PWD environment variable, so this is a validation problem

If validate should look if the script files exist, then it must also know the current working directory...

@afbjorklund afbjorklund marked this pull request as draft June 24, 2024 10:59
@afbjorklund
Copy link
Contributor Author

afbjorklund commented Jun 24, 2024

As noted in the older issue, this becomes extra interesting if lima.yaml is loaded from an URL.

limactl start https://raw.githubusercontent.com/lima-vm/lima/master/examples/default.yaml

@afbjorklund afbjorklund marked this pull request as ready for review June 24, 2024 15:38
@@ -206,6 +207,7 @@ type Probe struct {
Mode ProbeMode // default: "readiness"
Description string
Script string
Path string `yaml:",omitempty" json:",omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we consistently use the File object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The file objects also adds arch and digest, neither of which is applicable here...

We could rename Path to Location, to allow for running scripts from URLs?

Copy link
Member

Choose a reason for hiding this comment

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

at least digest seems to be applicable here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, probably needs more design then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i.e. the wish was to "include" common scripts

If the digest changes every time you edit the script, you still need to copy/paste the sha256?

@@ -33,6 +33,7 @@ An instance directory contains the following files:

Metadata:
- `lima-version`: the Lima version used to create this instance
- `lima-workdir`: the Lima workdir used to create this instance
Copy link
Member

Choose a reason for hiding this comment

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

What is workdir? Why does it need to be a dir?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The workdir is the $PWD from when the limactl start was first run.

It is used to find relative paths, for the scripts and the playbooks...

Otherwise, you need to cd to the directory before any limactl.

Or make all paths absolute, making them static and unportable?

if err != nil {
return nil, err
}
if err := os.WriteFile(filepath.Join(instDir, filenames.LimaWorkDir), []byte(wd), 0o644); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This could be a symlink ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not on Windows, I suppose.

But yes, it could be a symlink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants