-
Notifications
You must be signed in to change notification settings - Fork 706
feature: "yq" provision mode #3892
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
Conversation
Why not just apt-get yq in a shell script? |
I think this is too specialized to be built into Lima given that you can already do this with a regular provisioning script: provision:
- mode: user
script: |
if ! command -v yq >/dev/null 2>&1; then
apt-get update
apt install -y yq
fi
mkdir -p ...
touch ...
yq ... |
Because |
Ok, that is unfortunate. I was wondering why it was dragging in Python. But |
If the guestagent was already using And we would rather want to bring down the size of the guestagents, so I don't think we should be doing that either. |
Dragging in the Python implementation makes a sense, as it seems more "authentic" version |
Fair enough. Unfortunately on homebrew |
cc10a18
to
6cb8a7e
Compare
If we want to support adding large local files to the cidata volume, then I would suggest the way to do this would be to extend the base: template://docker
provision:
- mode: data
path: /usr/local/bin/yq
file: ~/Downloads/yq_linux_arm
permissions: 755 It didn't work because of the tilde path (I just created a PR to fix that), but also because template embedding would attempt to include the file as a base64 encoded string, which exceeds the (somewhat arbitrary) max size of 4MB we have for I still think that once created a Lima instance should not reference other local files outside the instance directory. We could get rid of the file size limit (not a good idea, imo), or we could have some mechanism that files would be copied into a cache directory inside the instance directory, and the file reference would be rewritten to point to it. I don't think the use case is particularly strong though when you can also just fetch the file from GitHub in a provisioning script. We do this with all manner of other prerequisites as well. But I can see the utility when you want to bundle something that is not available for download. |
This PR adds |
6cb8a7e
to
06b81fd
Compare
provisionTool:
yq:
- location: "~/Downloads/yq_linux_amd64"
arch: "x86_64"
digest: "sha256:..." The example above is from |
@norio-nomura : I think you should add an issue for what you are trying to accomplish here, before diving straight into the implementation and the PR? My gut feeling is that this will meet the same fate as the "ansible" provisioning. |
I know this is just an example, but I just realized that you are editing a JSON file, so you can just use |
base: template://docker
provision:
- mode: user
script: |
set -eux -o pipefail
DAEMON="{{.Home}}/.config/docker/daemon.json"
mkdir -p "$(dirname "$DAEMON")"
[[ ! -e $DAEMON ]] && echo "{}" > "$DAEMON"
chmod 644 "$DAEMON"
EXPR='.features["containerd-snapshotter"] = {{.Param.containerdSnapshotter}}'
jq "$EXPR" "$DAEMON" >"$DAEMON.new"
mv "$DAEMON.new" "$DAEMON"
param:
containerdSnapshotter: true Seems to work fine: ❯ limactl start --yes --name snap ./snap.tmpl
❯ limactl shell snap sh -c "cat ~/.config/docker/daemon.json"
{
"features": {
"containerd-snapshotter": true
}
} |
Unrelated, but I also think we should just always use the Even Docker Desktop has been using it by default for over a year now for all new installations. It is not considered experimental anymore. |
Yup, I also have some I want to make those tasks much simpler like this PR does. |
If I make an issue before I write a PR, I expect to receive an answer like #3892 (comment) It came. Being able to make |
06b81fd
to
bb0337b
Compare
Added - mode: yq
path: /etc/systemd/system/docker.service.d/override.conf
format: ini
expression: .Socket.SocketUser="{{.User}}" |
9a9c7c4
to
420f6ee
Compare
That is OK, but it also runs into the risk of 1) not realizing there is a simpler way to accomplish the same thing and 2) risking that the PR is never merged - or maybe merged and then deprecated and removed again, like Ansible |
I like the I think a better approach would be to bundle I've created #3908 to show how simple this is to implement. What do you think about using that approach @norio-nomura? |
420f6ee
to
03e90a4
Compare
I will separate the |
84e10a3
to
08c6556
Compare
updated:
|
8f59a28
to
71563bd
Compare
Pushed a separate commit that applying reviews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM
Still have some nit-picks, and I think we are missing the documentation for the order the provisioning types are executed.
Pushed a separate commit that applying additional reviews |
74cd09b
to
b785cb8
Compare
force pushed to fix lint error |
Please squash the commits |
```yaml # Create or edit a file in the guest filesystem by using `yq`. # The file specified by `path` will be updated by `expression`. # An empty file of the required `format` will be created if it does not yet exist. # `format` defaults to "auto" and will be detected by file extension of `path`. # If the extension is not recognized by `yq` then `format` must be set to a # value from this list: # "auto", "csv", "ini", "json", "props", "tsv", "toml", "xml", "yaml" # See https://github.com/mikefarah/yq for more info. # Any missing directories will be created as needed. # The file permissions will be set to the specified value. # The file and directory creation will be performed as the specified owner. # If the existing file is not writable by the specified owner, the operation will fail. # `path` and `expression` are required. # `owner` and `permissions` are optional. Defaults to "root:root" and 644. - mode: yq path: "{{.Home}}/.config/docker/daemon.json" expression: ".features.containerd-snapshotter = {{.Param.containerdSnapshotter}}" format: auto owner: "{{.User}}" permissions: 644 ``` Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
b785cb8
to
2f2f47f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Thanks! 🙏🏻 |
8000
based on #3908updated:
based on Addyq
subcommands tolimactl
andlima-guestagent
#3908provisionTool