databricks-cli/libs/jsonschema
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
..
test_types Make bundle JSON schema modular with `$defs` (#1700) 2024-09-10 13:55:18 +00:00
testdata Add support for `anyOf` to `skip_prompt_if` (#1133) 2024-01-25 10:09:42 +00:00
extension.go Add support for conditional prompting in bundle init (#971) 2023-11-30 16:07:45 +00:00
from_type.go Make bundle JSON schema modular with `$defs` (#1700) 2024-09-10 13:55:18 +00:00
from_type_test.go Make bundle JSON schema modular with `$defs` (#1700) 2024-09-10 13:55:18 +00:00
instance.go Add support for `anyOf` to `skip_prompt_if` (#1133) 2024-01-25 10:09:42 +00:00
instance_test.go Add support for `anyOf` to `skip_prompt_if` (#1133) 2024-01-25 10:09:42 +00:00
schema.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
schema_order.go Add support for ordering of input prompts (#662) 2023-09-05 11:08:25 +00:00
schema_order_test.go Add support for ordering of input prompts (#662) 2023-09-05 11:08:25 +00:00
schema_test.go Use `fs.FS` interface to read template (#1910) 2024-11-20 09:28:35 +00:00
utils.go Add support for reprompts if user input does not match template schema (#946) 2023-12-22 15:43:08 +00:00
utils_test.go Add support for reprompts if user input does not match template schema (#946) 2023-12-22 15:43:08 +00:00
validate_type.go Add schema and config validation to jsonschema package (#740) 2023-09-07 14:36:06 +00:00
validate_type_test.go Add schema and config validation to jsonschema package (#740) 2023-09-07 14:36:06 +00:00