Update consumer examples for document-root controls
This commit is contained in:
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() {
|
||||
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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: metadata.yml
|
||||
destination: []
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: version.yml
|
||||
description: Imported collection metadata.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: compact.yml
|
||||
- path: weather.yml
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: brief.yml
|
||||
- path: custom.yml
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: ../shared.yml
|
||||
enabled: true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: artifacts.yml
|
||||
poll_interval: 1m
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: declarations/path.yml
|
||||
sensitive: PATH_REFERENCE_SECRET_CANARY
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: metadata.yml
|
||||
- path: prompts/brief.yml
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
sequences:
|
||||
- destination: [prompts]
|
||||
key: id
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
sequences:
|
||||
- destination: [prompts]
|
||||
key: id
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: helpers/curated-id.yml
|
||||
name: Curated summary
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: prompts/required.yml
|
||||
required: true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
run_label: source-default
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- dir: fragments
|
||||
pattern: '*.yml'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
sequences:
|
||||
- destination: [prompts]
|
||||
key: id
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
sequences:
|
||||
- destination: [prompts]
|
||||
key: id
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
sequences:
|
||||
- destination: [prompts]
|
||||
key: id
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
configkit:
|
||||
config:
|
||||
sequences:
|
||||
- destination: [prompts]
|
||||
key: id
|
||||
|
||||
Reference in New Issue
Block a user