Skip to content

Commit 327de93

Browse files
authored
refactor: string functions (#5962)
1 parent e37cc41 commit 327de93

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

engine/api/workflow_application.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (api *API) releaseApplicationWorkflowHandler() service.Handler {
9898
for _, a := range workflowArtifacts {
9999
for _, aToUp := range req.Artifacts {
100100
if len(aToUp) > 0 {
101-
ok, errRX := regexp.Match(aToUp, []byte(a.Name))
101+
ok, errRX := regexp.MatchString(aToUp, a.Name)
102102
if errRX != nil {
103103
return sdk.WrapError(errRX, "releaseApplicationWorkflowHandler> %s is not a valid regular expression", aToUp)
104104
}
@@ -148,7 +148,7 @@ func (api *API) releaseApplicationWorkflowHandler() service.Handler {
148148
}
149149
for _, aToUp := range req.Artifacts {
150150
if len(aToUp) > 0 {
151-
ok, err := regexp.Match(aToUp, []byte(artiData.Name))
151+
ok, err := regexp.MatchString(aToUp, artiData.Name)
152152
if err != nil {
153153
return sdk.WrapError(err, "releaseApplicationWorkflowHandler> %s is not a valid regular expression", aToUp)
154154
}

engine/hooks/outgoing_hooks.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ func (s *Service) doOutgoingWebHookExecution(ctx context.Context, t *sdk.TaskExe
326326
return sdk.WrapError(handleError(ctx, err), "Unable to interpolate body")
327327
}
328328

329-
req, err := http.NewRequest(method, urls, bytes.NewBuffer([]byte(body)))
329+
req, err := http.NewRequest(method, urls, bytes.NewBufferString(body))
330330
if err != nil {
331331
return sdk.WrapError(handleError(ctx, err), "Unable to create request")
332332
}

sdk/workflow.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ func (label *Label) IsValid() error {
452452
}
453453
label.Color = "#" + hex.EncodeToString(bytes)
454454
} else {
455-
if !ColorRegexp.Match([]byte(label.Color)) {
455+
if !ColorRegexp.MatchString(label.Color) {
456456
return WithStack(ErrIconBadFormat)
457457
}
458458
}

tools/os-ansible-inventory/types.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ type Filter struct {
3737
func (f Filter) Match(k, v string) (bool, error) {
3838
switch f.Operator {
3939
case "=":
40-
if strings.ToUpper(k) == strings.ToUpper(f.Key) && strings.ToUpper(v) == strings.ToUpper(f.Value) {
40+
if strings.EqualFold(k, f.Key) && strings.EqualFold(v, f.Value) {
4141
return true, nil
4242
}
4343
case "~":
44-
if strings.ToUpper(k) == strings.ToUpper(f.Key) {
44+
if strings.EqualFold(k, f.Key) {
4545
r, err := regexp.Compile(f.Value)
4646
if err != nil {
4747
return false, err
4848
}
49-
return r.Match([]byte(v)), nil
49+
return r.MatchString(v), nil
5050
}
5151
default:
5252
return false, fmt.Errorf("unsupported operator %s", f.Operator)

0 commit comments

Comments
 (0)