Skip to content

Commit

Permalink
Insensitive case for allow-empty value.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored and traefiker committed Apr 9, 2019
1 parent 2e20394 commit ee0e014
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/provider/label/internal/nodes_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func addMetadata(rootType reflect.Type, node *Node) error {
return fmt.Errorf("node %s (type %s) must have children", node.Name, fType)
}

node.Disabled = len(node.Value) > 0 && node.Value != "true" && field.Tag.Get(TagLabel) == "allowEmpty"
node.Disabled = len(node.Value) > 0 && !strings.EqualFold(node.Value, "true") && field.Tag.Get(TagLabel) == "allowEmpty"
}

if len(node.Children) == 0 {
Expand Down
27 changes: 27 additions & 0 deletions pkg/provider/label/internal/nodes_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,33 @@ func TestAddMetadata(t *testing.T) {
},
},
},
{
desc: "level 2, struct with allowEmpty, value true with case variation",
tree: &Node{
Name: "traefik",
Children: []*Node{
{Name: "Foo", Value: "TruE"},
},
},
structure: struct {
Foo struct {
Bar string
} `label:"allowEmpty"`
}{
Foo: struct {
Bar string
}{},
},
expected: expected{
node: &Node{
Name: "traefik",
Kind: reflect.Struct,
Children: []*Node{
{Name: "Foo", FieldName: "Foo", Value: "TruE", Kind: reflect.Struct},
},
},
},
},
{
desc: "level 2, struct with allowEmpty, value false",
tree: &Node{
Expand Down

0 comments on commit ee0e014

Please sign in to comment.