Update consumer examples for document-root controls

This commit is contained in:
2026-11-02 00:44:33 +00:00
parent cf9e2fd677
commit e5475ea7f8
20 changed files with 47 additions and 19 deletions

View File

@@ -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

View 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
}

View File

@@ -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

View File

@@ -1,4 +1,4 @@
configkit: config:
imports: imports:
- path: metadata.yml - path: metadata.yml
destination: [] destination: []

View File

@@ -1,4 +1,4 @@
configkit: config:
imports: imports:
- path: version.yml - path: version.yml
description: Imported collection metadata. description: Imported collection metadata.

View File

@@ -1,4 +1,4 @@
configkit: config:
imports: imports:
- path: compact.yml - path: compact.yml
- path: weather.yml - path: weather.yml

View File

@@ -1,4 +1,4 @@
configkit: config:
imports: imports:
- path: brief.yml - path: brief.yml
- path: custom.yml - path: custom.yml

View File

@@ -1,4 +1,4 @@
configkit: config:
imports: imports:
- path: ../shared.yml - path: ../shared.yml
enabled: true enabled: true

View File

@@ -1,4 +1,4 @@
configkit: config:
imports: imports:
- path: artifacts.yml - path: artifacts.yml
poll_interval: 1m poll_interval: 1m

View File

@@ -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

View File

@@ -1,4 +1,4 @@
configkit: config:
imports: imports:
- path: metadata.yml - path: metadata.yml
- path: prompts/brief.yml - path: prompts/brief.yml

View File

@@ -1,4 +1,4 @@
configkit: config:
sequences: sequences:
- destination: [prompts] - destination: [prompts]
key: id key: id

View File

@@ -1,4 +1,4 @@
configkit: config:
sequences: sequences:
- destination: [prompts] - destination: [prompts]
key: id key: id

View File

@@ -1,4 +1,4 @@
configkit: config:
imports: imports:
- path: helpers/curated-id.yml - path: helpers/curated-id.yml
name: Curated summary name: Curated summary

View File

@@ -1,4 +1,4 @@
configkit: config:
imports: imports:
- path: prompts/required.yml - path: prompts/required.yml
required: true required: true

View File

@@ -1,5 +1,5 @@
run_label: source-default run_label: source-default
configkit: config:
imports: imports:
- dir: fragments - dir: fragments
pattern: '*.yml' pattern: '*.yml'

View File

@@ -1,4 +1,4 @@
configkit: config:
sequences: sequences:
- destination: [prompts] - destination: [prompts]
key: id key: id

View File

@@ -1,4 +1,4 @@
configkit: config:
sequences: sequences:
- destination: [prompts] - destination: [prompts]
key: id key: id

View File

@@ -1,4 +1,4 @@
configkit: config:
sequences: sequences:
- destination: [prompts] - destination: [prompts]
key: id key: id

View File

@@ -1,4 +1,4 @@
configkit: config:
sequences: sequences:
- destination: [prompts] - destination: [prompts]
key: id key: id