Skip to content

Commit

Permalink
Fix streams mode main config reader
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffail committed Jan 29, 2024
1 parent 69359e5 commit b16f01a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion internal/cli/common/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ func CreateManager(
sanitConf := docs.NewSanitiseConfig(bundle.GlobalEnvironment)
sanitConf.RemoveTypeField = true
sanitConf.ScrubSecrets = true
err = config.Spec().SanitiseYAML(&sanitNode, sanitConf)
sanitSpec := config.Spec()
if streamsMode {
sanitSpec = config.SpecWithoutStream()
}
err = sanitSpec.SanitiseYAML(&sanitNode, sanitConf)
}
if err != nil {
err = fmt.Errorf("failed to generate sanitised config: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/config/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (r *Reader) readMain(mainPath string) (conf Type, lints []string, err error
if r.streamsMode {
// Spec is limited to just non-stream fields when in streams mode (no
// input, output, etc)
confSpec = r.specStreamOnly
confSpec = r.specObservability
}
if err = applyOverrides(confSpec, rawNode, r.overrides...); err != nil {
return
Expand Down
8 changes: 7 additions & 1 deletion internal/config/stream_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import (
func TestStreamsLints(t *testing.T) {
dir := t.TempDir()

generalConfPath := filepath.Join(dir, "main.yaml")
require.NoError(t, os.WriteFile(generalConfPath, []byte(`
logger:
level: ALL
`), 0o644))

streamOnePath := filepath.Join(dir, "first.yaml")
require.NoError(t, os.WriteFile(streamOnePath, []byte(`
input:
Expand All @@ -42,7 +48,7 @@ cache_resources:
ttl: 13
`), 0o644))

rdr := config.NewReader("", nil, config.OptSetStreamPaths(streamOnePath, streamTwoPath))
rdr := config.NewReader(generalConfPath, nil, config.OptSetStreamPaths(streamOnePath, streamTwoPath))

_, lints, err := rdr.Read()
require.NoError(t, err)
Expand Down

0 comments on commit b16f01a

Please sign in to comment.