Skip to content

Commit 82747df

Browse files
committed
fix: fixed includeLabelInRouter logic
Signed-off-by: Peter Gvizd <[email protected]>
1 parent b440e7e commit 82747df

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

pkg/sdk/logging/model/types/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (s *SystemBuilder) RegisterFlow(f *Flow) error {
4242
}
4343
}
4444
s.flows = append(s.flows, f)
45-
if f.FlowLabel == "" || (f.IncludeLabelInRouter != nil && *f.IncludeLabelInRouter) {
45+
if f.IncludeLabelInRouter {
4646
s.router.AddRoute(f)
4747
}
4848
return nil

pkg/sdk/logging/model/types/flow.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type Flow struct {
6969
FlowLabel string `json:"-"`
7070

7171
// Flag whether to include flow in label_router
72-
IncludeLabelInRouter *bool
72+
IncludeLabelInRouter bool
7373
}
7474

7575
func (f *Flow) GetPluginMeta() *PluginMeta {
@@ -108,12 +108,20 @@ func (f *Flow) WithOutputs(output ...Output) *Flow {
108108
}
109109

110110
func NewFlow(matches []FlowMatch, id, name, namespace, flowLabel string, includeLabelInRouter *bool) (*Flow, error) {
111+
var tmpIncludeLabelInRouter bool = true
111112
if flowLabel == "" {
112113
var err error
113114
flowLabel, err = calculateFlowLabel(matches, name, namespace)
114115
if err != nil {
115116
return nil, err
116117
}
118+
if includeLabelInRouter != nil && !*includeLabelInRouter {
119+
tmpIncludeLabelInRouter = false
120+
}
121+
} else {
122+
if includeLabelInRouter == nil || !*includeLabelInRouter {
123+
tmpIncludeLabelInRouter = false
124+
}
117125
}
118126
return &Flow{
119127
PluginMeta: PluginMeta{
@@ -123,7 +131,7 @@ func NewFlow(matches []FlowMatch, id, name, namespace, flowLabel string, include
123131
FlowID: id,
124132
FlowLabel: flowLabel,
125133
Matches: matches,
126-
IncludeLabelInRouter: includeLabelInRouter,
134+
IncludeLabelInRouter: tmpIncludeLabelInRouter,
127135
}, nil
128136
}
129137

0 commit comments

Comments
 (0)