diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2022-05-28 19:24:48 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2022-05-28 19:49:42 -0400 |
| commit | cec23e66f9bd5022845162ae4dd3f2633b5236fa (patch) | |
| tree | f5caf83d0c92ce80942b2e7ed5e184ffb69e3c2d /internal | |
| parent | e00015a86393e947757dea88cb82b328b35ad8b4 (diff) | |
General refactoring & cleanup
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/cmd/config.go | 7 | ||||
| -rw-r--r-- | internal/cmd/config_test.go | 29 |
2 files changed, 7 insertions, 29 deletions
diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 201b867a..6f0c3673 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -52,13 +52,6 @@ func loadConfig(cmd *cobra.Command, args []string) (*config.Config, error) { cfg.Stdout = cmd.OutOrStdout() cfg.Stderr = cmd.ErrOrStderr() - // reset defaults before validation - cfg.ApplyDefaults() - - err = cfg.Validate() - if err != nil { - return nil, fmt.Errorf("failed to validate merged config: %w\n%+v", err, cfg) - } return cfg, nil } diff --git a/internal/cmd/config_test.go b/internal/cmd/config_test.go index aa7ff753..0a5b38f6 100644 --- a/internal/cmd/config_test.go +++ b/internal/cmd/config_test.go @@ -82,15 +82,9 @@ func TestLoadConfig(t *testing.T) { out, err := loadConfig(cmd, cmd.Flags().Args()) expected := &config.Config{ - InputFiles: []string{"-"}, - OutputFiles: []string{"-"}, - LDelim: "{{", - RDelim: "}}", - PostExecInput: stdin, - PluginTimeout: 5 * time.Second, - Stdin: stdin, - Stdout: stdout, - Stderr: stderr, + Stdin: stdin, + Stdout: stdout, + Stderr: stderr, } assert.NoError(t, err) assert.EqualValues(t, expected, out) @@ -98,15 +92,10 @@ func TestLoadConfig(t *testing.T) { cmd.ParseFlags([]string{"--in", "foo"}) out, err = loadConfig(cmd, cmd.Flags().Args()) expected = &config.Config{ - Input: "foo", - OutputFiles: []string{"-"}, - LDelim: "{{", - RDelim: "}}", - PostExecInput: stdin, - PluginTimeout: 5 * time.Second, - Stdin: stdin, - Stdout: out.Stdout, - Stderr: stderr, + Input: "foo", + Stdin: stdin, + Stdout: out.Stdout, + Stderr: stderr, } assert.NoError(t, err) assert.EqualValues(t, expected, out) @@ -115,13 +104,9 @@ func TestLoadConfig(t *testing.T) { out, err = loadConfig(cmd, cmd.Flags().Args()) expected = &config.Config{ Input: "foo", - LDelim: "{{", - RDelim: "}}", ExecPipe: true, PostExec: []string{"tr", "[a-z]", "[A-Z]"}, PostExecInput: out.PostExecInput, - OutputFiles: []string{"-"}, - PluginTimeout: 5 * time.Second, Stdin: stdin, Stdout: out.Stdout, Stderr: stderr, |
