Skip to content

Commit

Permalink
don't create slices in enrich
Browse files Browse the repository at this point in the history
  • Loading branch information
lovromazgon committed Apr 3, 2023
1 parent 1637cba commit 99148d8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions pkg/provisioning/config/enrich.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func enrichDLQ(dlq DLQ) DLQ {

// enrichConnectors sets default values for connectors config fields
func enrichConnectors(mp []Connector, pipelineID string) []Connector {
if mp == nil {
return nil
}
out := make([]Connector, len(mp))
for i, cfg := range mp {
if cfg.Name == "" {
Expand All @@ -69,6 +72,9 @@ func enrichConnectors(mp []Connector, pipelineID string) []Connector {

// enrichProcessorsConfig sets default values for processors config fields
func enrichProcessors(mp []Processor, parentID string) []Processor {
if mp == nil {
return nil
}
out := make([]Processor, len(mp))
for i, cfg := range mp {
if cfg.Workers == 0 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/provisioning/config/enrich_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func TestEnrich_DefaultValues(t *testing.T) {
WindowSize: &pipeline.DefaultDLQ.WindowSize,
WindowNackThreshold: &pipeline.DefaultDLQ.WindowNackThreshold,
},
Connectors: []Connector{},
Processors: []Processor{},
Connectors: nil,
Processors: nil,
},
}}

Expand Down
2 changes: 1 addition & 1 deletion pkg/provisioning/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var (
Plugin: "builtin:file",
PipelineID: oldPipelineInstance.ID,
Config: connector.Config{
Name: "source",
Name: "source-new",
Settings: map[string]string{"path": "my/path/file1.txt"},
},
}
Expand Down

0 comments on commit 99148d8

Please sign in to comment.