Skip to content

Commit

Permalink
Allow empty labels (#207)
Browse files Browse the repository at this point in the history
Co-authored-by: Lars Pickelin <lars.pickelin@hetzner-cloud.de>
  • Loading branch information
4ND3R50N and Lars Pickelin committed Jul 29, 2022
1 parent d39392d commit 390daad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hcloud/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

var keyRegexp = regexp.MustCompile(
`^([a-z0-9A-Z]((?:[\-_.]|[a-z0-9A-Z]){0,253}[a-z0-9A-Z])?/)?[a-z0-9A-Z]((?:[\-_.]|[a-z0-9A-Z]|){0,62}[a-z0-9A-Z])?$`)
var valueRegexp = regexp.MustCompile(`^([a-z0-9A-Z](?:[\-_.]|[a-z0-9A-Z]){0,62})?[a-z0-9A-Z]$`)
var valueRegexp = regexp.MustCompile(`^(([a-z0-9A-Z](?:[\-_.]|[a-z0-9A-Z]){0,62})?[a-z0-9A-Z]$|$)`)

func ValidateResourceLabels(labels map[string]interface{}) (bool, error) {
for k, v := range labels {
Expand Down
1 change: 1 addition & 0 deletions hcloud/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func TestCheckLabels(t *testing.T) {
"label2.de/hallo": "1correct2.de",
"label3-test.de/hallo.welt": "233344444443",
"d/d": "d",
"empty/label": "",
}

ok, err := ValidateResourceLabels(labelMap)
Expand Down

0 comments on commit 390daad

Please sign in to comment.