databricks-cli/libs/template
Pieter Noordhuis 4fea0219fd
Use `fs.FS` interface to read template (#1910)
## Changes

While working on the v2 of #1744, I found that:
* Template initialization first copies built-in templates to a temporary
directory before initializing them
* Reading a template's contents goes through a `filer.Filer` but is
hardcoded to a local one

This change updates the interface for reading templates to be `fs.FS`.
This is compatible with the `embed.FS` type for the built-in templates,
so they no longer have to be copied to a temporary directory before
being used.

The alternative is to use a `filer.Filer` throughout, but this would
have required even more plumbing, and we don't need to _read_ templates,
including notebooks, from the workspace filesystem (yet?).

As part of making `template.Materialize` take an `fs.FS` argument, the
logic to match a given argument to a particular built-in template in the
`init` command has moved to sit next to its implementation.

## Tests

Existing tests pass.
2024-11-20 09:28:35 +00:00
..
templates Fix pipeline in default-python template not working for certain workspaces (#1854) 2024-10-22 15:52:46 +00:00
testdata Fix ability to import the CLI repository as module (#1671) 2024-08-12 14:20:04 +00:00
builtin.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
builtin_test.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
config.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
config_test.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
file.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
file_test.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
helpers.go Ignore metastore permission error during template generation (#1819) 2024-10-11 12:28:56 +00:00
helpers_test.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
materialize.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
materialize_test.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
renderer.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
renderer_test.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00