From 942ffa7e02ccf8e66751810890899662292e8ca2 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 20 Nov 2020 15:23:58 -0500 Subject: [PATCH] config: use LiteralConfig for flag values --- agent/config/builder.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/agent/config/builder.go b/agent/config/builder.go index eb7e7a61a..e4faa4d2d 100644 --- a/agent/config/builder.go +++ b/agent/config/builder.go @@ -126,14 +126,6 @@ func NewBuilder(opts BuilderOpts) (*Builder, error) { return nil, fmt.Errorf("config: -config-format must be either 'hcl' or 'json'") } - newSource := func(name string, v interface{}) Source { - b, err := json.MarshalIndent(v, "", " ") - if err != nil { - panic(err) - } - return FileSource{Name: name, Format: "json", Data: string(b)} - } - b := &Builder{ devMode: opts.DevMode, Head: []Source{DefaultSource(), DefaultEnterpriseSource()}, @@ -149,7 +141,7 @@ func NewBuilder(opts BuilderOpts) (*Builder, error) { // merge the config files since the flag values for slices are // otherwise appended instead of prepended. slices, values := splitSlicesAndValues(opts.Config) - b.Head = append(b.Head, newSource("flags.slices", slices)) + b.Head = append(b.Head, LiteralSource{Name: "flags.slices", Config: slices}) for _, path := range opts.ConfigFiles { sources, err := b.sourcesFromPath(path, opts.ConfigFormat) if err != nil { @@ -157,7 +149,7 @@ func NewBuilder(opts BuilderOpts) (*Builder, error) { } b.Sources = append(b.Sources, sources...) } - b.Tail = append(b.Tail, newSource("flags.values", values)) + b.Tail = append(b.Tail, LiteralSource{Name: "flags.values", Config: values}) for i, s := range opts.HCL { b.Tail = append(b.Tail, FileSource{ Name: fmt.Sprintf("flags-%d.hcl", i),