Update consumer examples for document-root controls
This commit is contained in:
@@ -265,6 +265,8 @@ application `config` data.
|
|||||||
|
|
||||||
## Stage 8 — Migrate maintained consumer fixtures and show the boundary
|
## Stage 8 — Migrate maintained consumer fixtures and show the boundary
|
||||||
|
|
||||||
|
**Status:** Complete. The consumer examples and executable tests pass.
|
||||||
|
|
||||||
**Scope:** `examples/consumers`, its YAML fixtures, and their executable tests.
|
**Scope:** `examples/consumers`, its YAML fixtures, and their executable tests.
|
||||||
|
|
||||||
1. Migrate genuine root controls in consumer fixtures and inline generated
|
1. Migrate genuine root controls in consumer fixtures and inline generated
|
||||||
|
|||||||
26
examples/consumers/config_controls_test.go
Normal file
26
examples/consumers/config_controls_test.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package consumers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing/fstest"
|
||||||
|
|
||||||
|
configkit "go.maximumdirect.net/configkit"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Example_documentRootConfig() {
|
||||||
|
type app struct {
|
||||||
|
Config struct {
|
||||||
|
Timeout string `yaml:"timeout"`
|
||||||
|
} `yaml:"config"`
|
||||||
|
}
|
||||||
|
files := configkit.NewFilesystem("bundle", fstest.MapFS{
|
||||||
|
"main.yml": {Data: []byte("config: {imports: [{path: settings.yml, destination: [config]}]}\n")},
|
||||||
|
"settings.yml": {Data: []byte("timeout: 10s\n")},
|
||||||
|
})
|
||||||
|
result, err := configkit.Load[app](files.File("main.yml"), configkit.Options[app]{Imports: true})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println(result.Config.Config.Timeout)
|
||||||
|
// Output: 10s
|
||||||
|
}
|
||||||
@@ -171,7 +171,7 @@ collections:
|
|||||||
|
|
||||||
func Example_yamlDeclaredIdentityOnly() {
|
func Example_yamlDeclaredIdentityOnly() {
|
||||||
result, err := configkit.Load(configkit.Bytes("YAML identity only", []byte(`
|
result, err := configkit.Load(configkit.Bytes("YAML identity only", []byte(`
|
||||||
configkit:
|
config:
|
||||||
sequences:
|
sequences:
|
||||||
- destination: [prompts]
|
- destination: [prompts]
|
||||||
key: id
|
key: id
|
||||||
@@ -193,7 +193,7 @@ prompts:
|
|||||||
|
|
||||||
func TestYAMLDeclaredIdentityDoesNotRegisterFinalTypedConstraint(t *testing.T) {
|
func TestYAMLDeclaredIdentityDoesNotRegisterFinalTypedConstraint(t *testing.T) {
|
||||||
result, err := configkit.Load(configkit.Bytes("YAML identity only", []byte(`
|
result, err := configkit.Load(configkit.Bytes("YAML identity only", []byte(`
|
||||||
configkit:
|
config:
|
||||||
sequences:
|
sequences:
|
||||||
- destination: [prompts]
|
- destination: [prompts]
|
||||||
key: id
|
key: id
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: metadata.yml
|
- path: metadata.yml
|
||||||
destination: []
|
destination: []
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: version.yml
|
- path: version.yml
|
||||||
description: Imported collection metadata.
|
description: Imported collection metadata.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: compact.yml
|
- path: compact.yml
|
||||||
- path: weather.yml
|
- path: weather.yml
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: brief.yml
|
- path: brief.yml
|
||||||
- path: custom.yml
|
- path: custom.yml
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: ../shared.yml
|
- path: ../shared.yml
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: artifacts.yml
|
- path: artifacts.yml
|
||||||
poll_interval: 1m
|
poll_interval: 1m
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: declarations/path.yml
|
- path: declarations/path.yml
|
||||||
sensitive: PATH_REFERENCE_SECRET_CANARY
|
sensitive: PATH_REFERENCE_SECRET_CANARY
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: metadata.yml
|
- path: metadata.yml
|
||||||
- path: prompts/brief.yml
|
- path: prompts/brief.yml
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
sequences:
|
sequences:
|
||||||
- destination: [prompts]
|
- destination: [prompts]
|
||||||
key: id
|
key: id
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
sequences:
|
sequences:
|
||||||
- destination: [prompts]
|
- destination: [prompts]
|
||||||
key: id
|
key: id
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: helpers/curated-id.yml
|
- path: helpers/curated-id.yml
|
||||||
name: Curated summary
|
name: Curated summary
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- path: prompts/required.yml
|
- path: prompts/required.yml
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
run_label: source-default
|
run_label: source-default
|
||||||
configkit:
|
config:
|
||||||
imports:
|
imports:
|
||||||
- dir: fragments
|
- dir: fragments
|
||||||
pattern: '*.yml'
|
pattern: '*.yml'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
sequences:
|
sequences:
|
||||||
- destination: [prompts]
|
- destination: [prompts]
|
||||||
key: id
|
key: id
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
sequences:
|
sequences:
|
||||||
- destination: [prompts]
|
- destination: [prompts]
|
||||||
key: id
|
key: id
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
sequences:
|
sequences:
|
||||||
- destination: [prompts]
|
- destination: [prompts]
|
||||||
key: id
|
key: id
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
configkit:
|
config:
|
||||||
sequences:
|
sequences:
|
||||||
- destination: [prompts]
|
- destination: [prompts]
|
||||||
key: id
|
key: id
|
||||||
|
|||||||
Reference in New Issue
Block a user