Skip to content

Commit f58a57c

Browse files
authored
Don't prepend TrafficSegment on empty string. (#607)
Signed-off-by: Rodrigo Reis <[email protected]>
1 parent bc0f9ec commit f58a57c

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

docs/stack_crd.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7045,6 +7045,20 @@ spec:
70457045
description: key is the key to project.
70467046
type: string
70477047
mode:
7048+
description: 'mode is Optional:
7049+
mode bits used to set permissions
7050+
on this file. Must be an octal
7051+
value between 0000 and 0777 or
7052+
a decimal value between 0 and
7053+
511. YAML accepts both octal and
7054+
decimal values, JSON requires
7055+
decimal values for mode bits.
7056+
If not specified, the volume defaultMode
7057+
will be used. This might be in
7058+
conflict with other options that
7059+
affect the file mode, like fsGroup,
7060+
and the result can be other mode
7061+
bits set.'
70487062
format: int32
70497063
type: integer
70507064
path:
@@ -7177,20 +7191,6 @@ spec:
71777191
description: key is the key to project.
71787192
type: string
71797193
mode:
7180-
description: 'mode is Optional:
7181-
mode bits used to set permissions
7182-
on this file. Must be an octal
7183-
value between 0000 and 0777 or
7184-
a decimal value between 0 and
7185-
511. YAML accepts both octal and
7186-
decimal values, JSON requires
7187-
decimal values for mode bits.
7188-
If not specified, the volume defaultMode
7189-
will be used. This might be in
7190-
conflict with other options that
7191-
affect the file mode, like fsGroup,
7192-
and the result can be other mode
7193-
bits set.'
71947194
format: int32
71957195
type: integer
71967196
path:

pkg/core/stack_resources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func (sc *StackContainer) GenerateIngressSegment() (
378378
sc.ingressAnnotationsToSync,
379379
)
380380

381-
if predVal, ok := res.Annotations[IngressPredicateKey]; !ok {
381+
if predVal, ok := res.Annotations[IngressPredicateKey]; !ok || predVal == "" {
382382
res.Annotations = mergeLabels(
383383
res.Annotations,
384384
map[string]string{IngressPredicateKey: sc.trafficSegment()},

pkg/core/stack_resources_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,22 @@ func TestStackGenerateIngressSegment(t *testing.T) {
434434
expectedPredicate: "TrafficSegment(0.10, 0.30) && Method(\"GET\")",
435435
expectedHosts: []string{"example.teapot.zalan.do"},
436436
},
437+
{
438+
ingressSpec: &zv1.StackSetIngressSpec{
439+
EmbeddedObjectMetaWithAnnotations: zv1.EmbeddedObjectMetaWithAnnotations{
440+
Annotations: map[string]string{
441+
IngressPredicateKey: "",
442+
},
443+
},
444+
Hosts: []string{"example.teapot.zalan.do"},
445+
},
446+
lowerLimit: 0.1,
447+
upperLimit: 0.3,
448+
expectNil: false,
449+
expectError: false,
450+
expectedPredicate: "TrafficSegment(0.10, 0.30)",
451+
expectedHosts: []string{"example.teapot.zalan.do"},
452+
},
437453
} {
438454
backendPort := intstr.FromInt(int(80))
439455
c := &StackContainer{

0 commit comments

Comments
 (0)