File tree Expand file tree Collapse file tree 4 files changed +33
-6
lines changed
Expand file tree Collapse file tree 4 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,39 @@ type kubeDefaults struct {
3232 Namespace string `yaml:"namespace,omitempty"`
3333}
3434
35- // Defaults is the known HTTP plugin defaults collection
35+ // Defaults is the known kube plugin defaults collection
3636type Defaults struct {
3737 kubeDefaults
3838}
3939
40+ // Merge merges the supplies map of key/value combinations with the set of
41+ // handled defaults for the plugin. The supplied key/value map will NOT be
42+ // unpacked from its top-most plugin named element. So, for example, the
43+ // kube plugin should expect to get a map that looks like
44+ // "kube:namespace:<namespace>" and not "namespace:<namespace>".
45+ func (d * Defaults ) Merge (vals map [string ]any ) {
46+ kubeValsAny , ok := vals [pluginName ]
47+ if ! ok {
48+ return
49+ }
50+ kubeVals , ok := kubeValsAny .(map [string ]string )
51+ if ! ok {
52+ return
53+ }
54+ cfg , ok := kubeVals ["config" ]
55+ if ok {
56+ d .Config = cfg
57+ }
58+ ctx , ok := kubeVals ["context" ]
59+ if ok {
60+ d .Context = ctx
61+ }
62+ ns , ok := kubeVals ["namespace" ]
63+ if ok {
64+ d .Namespace = ns
65+ }
66+ }
67+
4068func (d * Defaults ) UnmarshalYAML (node * yaml.Node ) error {
4169 if node .Kind != yaml .MappingNode {
4270 return parse .ExpectedMapAt (node )
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ go 1.24.3
44
55require (
66 github.com/cenkalti/backoff v2.2.1+incompatible
7- github.com/gdt-dev/core v1.10.5
7+ github.com/gdt-dev/core v1.11.0
88 github.com/samber/lo v1.51.0
99 github.com/stretchr/testify v1.11.1
1010 github.com/theory/jsonpath v0.10.1
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjT
1919github.com/evanphx/json-patch/v5 v5.9.11 /go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM =
2020github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM =
2121github.com/fxamacker/cbor/v2 v2.9.0 /go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ =
22- github.com/gdt-dev/core v1.10.5 h1:plVO6WegOEuJTopnmTRQTIwyvHY2iG4xXDax2OP4fO8 =
23- github.com/gdt-dev/core v1.10.5 /go.mod h1:Bw8J6kUW0b7MUL8qW5e7qSbxb4SI9EAWQ0a4cAoPVpo =
22+ github.com/gdt-dev/core v1.11.0 h1:jEKDMZ8eoQIQMlTB2C6Ai6q7CfgHJ3y9MVFSzdgc208 =
23+ github.com/gdt-dev/core v1.11.0 /go.mod h1:Bw8J6kUW0b7MUL8qW5e7qSbxb4SI9EAWQ0a4cAoPVpo =
2424github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY =
2525github.com/go-logr/logr v1.4.2 /go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY =
2626github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ =
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ package kube
77import (
88 "github.com/gdt-dev/core/api"
99 gdtplugin "github.com/gdt-dev/core/plugin"
10- "gopkg.in/yaml.v3"
1110)
1211
1312var (
@@ -39,7 +38,7 @@ func (p *plugin) Info() api.PluginInfo {
3938 }
4039}
4140
42- func (p * plugin ) Defaults () yaml. Unmarshaler {
41+ func (p * plugin ) Defaults () api. DefaultsHandler {
4342 return & Defaults {}
4443}
4544
You can’t perform that action at this time.
0 commit comments