Path: blob/master/website/content/en/docs/templates/github.md
2621 views
------| ⚡ Requirement | Lima >= 2.0 |
|---|
Lima provides a special github: URL scheme to reference templates from a GitHub repo, as an alternative to using the https: scheme with a "raw" URL.
For example the templates/fedora.yaml template in the lima-vm/lima repo could be referenced as
Using the github: scheme this becomes:
⚠️ Note: github: URLs are experimental and the exact semantics may change in future releases.
General rules
File extension:
A github: URL without file extension will automatically get a .yaml suffix. So the Fedora URL above is the same as
File name:
The default filename for github: URLs is .lima.yaml. These URLs all reference the same file:
Branch/tag/commit:
You can append @TAG to a github: URL to specify a branch, a tag, or a commit id. For example:
Lima looks up the default branch of the repo when no @TAG is specified. This uses a GitHub API call.
Note: Frequent use of github: URLs may require setting GITHUB_TOKEN or GH_TOKEN to a personal access token to avoid GitHub rate limits.
Testing URL resolution
You can use the limactl template url command to see which https: URL is generated from a github: URL. For example:
You'll get an error if the template does not exist:
Symbolic links
Lima will check if the template file referenced by the github: URL is a symlink (or a text file whose content has no spaces, newlines, or colons). In that case it will treat the content as a relative path and return the address of that target file.
For example the fedora template is a symlink to fedora-43.yaml:
Org repositories
An "org repo" has identical org and repo names (e.g. lima-vm/lima-vm). For these repos, the repo name can be omitted:
Org repos support two additional features that enable shorter URLs, even when the main project lives in a different repo (like lima-vm/lima instead of lima-vm/lima-vm).
Redirects:
In an org repo a template file can not only be a symlink, but also a text file containing a github: URL. The URL must point to the same GitHub org and must NOT include a @TAG. It will be used to replace the original URL.
For example assume the lima-vm projects wants to support this URL:
Then it would have to create a lima-vm/lima-vm repo with a fedora.yaml file (in the default branch) that contains:
Tag propagation:
Org repo redirects work with tags. For example:
Lima resolves this through the following steps:
Tries to load
fedora.yamlfrom tagv1.2.1in thelima-vm/lima-vmrepoTag doesn't exist, so falls back to the default branch (
master)Loads
fedora.yaml@master, which contains the redirect:github:lima-vm/lima/templates/fedoraApplies the original tag to the redirect URL
Final resolved URL:
Lima will error if the fallback file doesn't exist or isn't a valid github: redirect.