lima-vm / lima-vm/lima

Implement `limayaml.FillDefault` with `limatmpl.Embed`

Open
#4,602 0 comments 0 reactions 1 assignee Claimed by @jandubois View on GitHub
kind/refactoring
Dominant language
Go
Stars
21.9k
Forks
957
Avg merge
2d 6h
Merged PRs (30d)
53

Description

> That may help simplifying `FillDefault` with reflection in future?

I don't think `FillDefaults()` will be implemented using reflection, but will use template embedding instead:

* we need a way for custom URL schemes to return the data, not just a redirect (#4135)

* define an `internal:` scheme that can return the following:
- `internal:override`: contents of `$LIMA_HOME/_config/override.yaml` or empty string
- `internal:default`: contents of `$LIMA_HOME/_config/default.yaml` or empty string
- `internal:builtin`: builtin defaults as a LimaYAML config
- `internal:user`: the template provided by the user

* `limayaml.FillDefaults()` then just invokes `limatmpl.Embed()` on
```yaml
base:
- internal:override
- internal:user
- internal:default
- internal:builtin
```

* URL scheme need to be registered dynamically because `internal` needs to be a closure in order to implement `internal:user`.

There are some other challenges that I currently no longer remember, but this would re-use the existing code for combining templates instead of having a second implementation.

_Originally posted by @jandubois in https://github.com/lima-vm/lima/issues/4595#issuecomment-3937760908_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.