Skip to content

Commit

Permalink
fix: failed to update opsrequest (#4951)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt committed Sep 1, 2023
1 parent b7ac16d commit c6880ef
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion controllers/apps/operations/reconfigure_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"context"
"encoding/json"
"fmt"
"regexp"

"github.com/spf13/cast"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -155,6 +156,14 @@ func syncConfigmap(

func updateOpsLabelWithReconfigure(obj *appsv1alpha1.OpsRequest, params []core.ParamPairs, orinalData map[string]string, formatter *appsv1alpha1.FormatterConfig) {
var maxLabelCount = 16
extractValue := func(v interface{}) string {
str := cast.ToString(v)
regxPattern, _ := regexp.Compile(`^[a-z0-9]([a-z0-9\.\-\_]*[a-z0-9])?$`)
if regxPattern.MatchString(str) {
return str
}
return ""
}
updateLabel := func(param map[string]interface{}) {
if obj.Labels == nil {
obj.Labels = make(map[string]string)
Expand All @@ -164,7 +173,7 @@ func updateOpsLabelWithReconfigure(obj *appsv1alpha1.OpsRequest, params []core.P
return
}
maxLabelCount--
obj.Labels[key] = cast.ToString(val)
obj.Labels[key] = extractValue(val)
}
}
updateAnnotation := func(keyFile string, param map[string]interface{}) {
Expand Down

0 comments on commit c6880ef

Please sign in to comment.