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

Add templating support for cloud-init in lima.yaml #2128

Open
jandubois opened this issue Jan 10, 2024 · 2 comments
Open

Add templating support for cloud-init in lima.yaml #2128

jandubois opened this issue Jan 10, 2024 · 2 comments

Comments

@jandubois
Copy link
Member

jandubois commented Jan 10, 2024

To avoid inflating the numbers of the limayaml fields, can we consider to support templating cloud-init yaml in limayaml?

Originally posted by @AkihiroSuda in #2119 (comment)

I think we should consider it, but it may take a bit of an effort. Here is what I think is needed (just brainstorming; please correct if I'm missing something):

  • Import the cloud-init json schema
  • Do whatever is necessary to make sure it is OpenAPI compliant (if it isn't already)
  • Turn it into a Go package using swagger
  • Add cloudInit field to lima.yaml
  • Create additional validations for potential conflicts with settings managed by Lima
  • Modify cidata to merge our settings into the cloud-init data structure; we can no longer use Go templating, but need to encode the structs to YAML.
  • Update lima-init in alpine-lima to deal with potential formatting changes

If this works, then we should decide how we import the JSON schema into the lima repo, how we update it etc. I think it would be best to have a separate repo for this, that maybe uses git submodules to include upstream cloud-init, and then checks in the swagger output as a Go module. That way we don't need to require swagger for building Lima.

@AkihiroSuda
Copy link
Member

Import the cloud-init json schema

Can we just use map[string]interface{} ?

@jandubois
Copy link
Member Author

Can we just use map[string]interface{} ?

We could, although it makes updating fields a bit awkward when we are merging in the fields that Lima needs to control. Maybe we can use something like https://github.com/Jeffail/gabs?

Also, I haven't checked if encoding the data again as YAML will write out the fields with lowercase names. I guess it needs to, if it supports proper round-tripping.

But how do we validate the user-data part if we don't use the schema? Hope that the VM will still somehow boots up, and let people look at /var/log/cloud-init-output.log?

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

No branches or pull requests

2 participants