Skip to content

Commit 2fbfac3

Browse files
Merge branch 'main' into issue-17886-expose-certs
2 parents 84b6f80 + 0b1299c commit 2fbfac3

File tree

2 files changed

+1
-67
lines changed

2 files changed

+1
-67
lines changed

agent/structs/config_entry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ func (e *ProxyConfigEntry) UnmarshalBinary(data []byte) error {
574574
// into a concrete type.
575575
//
576576
// There is an 'api' variation of this in
577-
// command/config/write/config_write.go:newDecodeConfigEntry
577+
// command/helpers/helpers.go:newDecodeConfigEntry
578578
func DecodeConfigEntry(raw map[string]interface{}) (ConfigEntry, error) {
579579
var entry ConfigEntry
580580

command/config/write/config_write.go

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@ import (
77
"flag"
88
"fmt"
99
"io"
10-
"time"
1110

12-
"github.com/hashicorp/go-multierror"
1311
"github.com/mitchellh/cli"
14-
"github.com/mitchellh/mapstructure"
1512

16-
"github.com/hashicorp/consul/api"
1713
"github.com/hashicorp/consul/command/config"
1814
"github.com/hashicorp/consul/command/flags"
1915
"github.com/hashicorp/consul/command/helpers"
20-
"github.com/hashicorp/consul/lib/decode"
2116
)
2217

2318
func New(ui cli.Ui) *cmd {
@@ -109,67 +104,6 @@ func (c *cmd) Run(args []string) int {
109104
return 0
110105
}
111106

112-
// There is a 'structs' variation of this in
113-
// agent/structs/config_entry.go:DecodeConfigEntry
114-
func newDecodeConfigEntry(raw map[string]interface{}) (api.ConfigEntry, error) {
115-
var entry api.ConfigEntry
116-
117-
kindVal, ok := raw["Kind"]
118-
if !ok {
119-
kindVal, ok = raw["kind"]
120-
}
121-
if !ok {
122-
return nil, fmt.Errorf("Payload does not contain a kind/Kind key at the top level")
123-
}
124-
125-
if kindStr, ok := kindVal.(string); ok {
126-
newEntry, err := api.MakeConfigEntry(kindStr, "")
127-
if err != nil {
128-
return nil, err
129-
}
130-
entry = newEntry
131-
} else {
132-
return nil, fmt.Errorf("Kind value in payload is not a string")
133-
}
134-
135-
var md mapstructure.Metadata
136-
decodeConf := &mapstructure.DecoderConfig{
137-
DecodeHook: mapstructure.ComposeDecodeHookFunc(
138-
decode.HookWeakDecodeFromSlice,
139-
decode.HookTranslateKeys,
140-
mapstructure.StringToTimeDurationHookFunc(),
141-
mapstructure.StringToTimeHookFunc(time.RFC3339),
142-
),
143-
Metadata: &md,
144-
Result: &entry,
145-
WeaklyTypedInput: true,
146-
}
147-
148-
decoder, err := mapstructure.NewDecoder(decodeConf)
149-
if err != nil {
150-
return nil, err
151-
}
152-
153-
if err := decoder.Decode(raw); err != nil {
154-
return nil, err
155-
}
156-
157-
for _, k := range md.Unused {
158-
switch k {
159-
case "kind", "Kind":
160-
// The kind field is used to determine the target, but doesn't need
161-
// to exist on the target.
162-
continue
163-
}
164-
err = multierror.Append(err, fmt.Errorf("invalid config key %q", k))
165-
}
166-
if err != nil {
167-
return nil, err
168-
}
169-
170-
return entry, nil
171-
}
172-
173107
func (c *cmd) Synopsis() string {
174108
return synopsis
175109
}

0 commit comments

Comments
 (0)