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
**Status:** Complete. The consumer examples and executable tests pass.
**Scope:** `examples/consumers`, its YAML fixtures, and their executable tests.
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() {
result, err := configkit.Load(configkit.Bytes("YAML identity only", []byte(`
configkit:
config:
sequences:
- destination: [prompts]
key: id
@@ -193,7 +193,7 @@ prompts:
func TestYAMLDeclaredIdentityDoesNotRegisterFinalTypedConstraint(t *testing.T) {
result, err := configkit.Load(configkit.Bytes("YAML identity only", []byte(`
configkit:
config:
sequences:
- destination: [prompts]
key: id

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
configkit:
config:
imports:
- path: declarations/path.yml
sensitive: PATH_REFERENCE_SECRET_CANARY

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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