Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/appbean/AppDetail.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type AppMetadata struct {

type AppLabel struct {
Key string `json:"key,notnull" validate:"required"`
Value string `json:"value,notnull" validate:"required"`
Value string `json:"value,notnull"` // intentionally not added required tag as tag can be added without value
Propagate bool `json:"propagate"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/bean/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ type AppLabelDto struct {

type Label struct {
Key string `json:"key" validate:"required"`
Value string `json:"value" validate:"required"`
Value string `json:"value"` // intentionally not added required tag as tag can be added without value
Propagate bool `json:"propagate"`
}

Expand Down
1 change: 1 addition & 0 deletions scripts/sql/125_global_tags_fix.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "public"."global_tag" ALTER COLUMN "key" SET DATA TYPE varchar(100);
1 change: 1 addition & 0 deletions scripts/sql/125_global_tags_fix.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "public"."global_tag" ALTER COLUMN "key" SET DATA TYPE varchar(317);
8 changes: 6 additions & 2 deletions util/K8sUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ import (
"errors"
"fmt"
"k8s.io/apimachinery/pkg/util/validation"
"strings"
)

func CheckIfValidLabel(labelKey string, labelValue string) error {
labelKey = strings.TrimSpace(labelKey)
labelValue = strings.TrimSpace(labelValue)

errs := validation.IsQualifiedName(labelKey)
if len(errs) > 0 {
if len(labelKey) == 0 || len(errs) > 0 {
return errors.New(fmt.Sprintf("Validation error - label key - %s is not satisfying the label key criteria", labelKey))
}

errs = validation.IsValidLabelValue(labelValue)
if len(errs) > 0 {
if len(labelValue) == 0 || len(errs) > 0 {
return errors.New(fmt.Sprintf("Validation error - label value - %s is not satisfying the label value criteria for label key - %s", labelValue, labelKey))
}
return nil
Expand Down