From b81ac4285b7f0c2580b8ba8bc8e6f485549438a0 Mon Sep 17 00:00:00 2001 From: xliuqq Date: Tue, 7 May 2024 17:13:43 +0800 Subject: [PATCH] fix sonar lint check Signed-off-by: xliuqq --- pkg/common/label.go | 2 +- pkg/common/label_test.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/common/label.go b/pkg/common/label.go index 99f83a19d78..16ffa7e7bf5 100644 --- a/pkg/common/label.go +++ b/pkg/common/label.go @@ -53,7 +53,7 @@ const ( var ( // LabelAnnotationPodSchedRegex is the fluid cache label for scheduling pod, format: 'fluid.io/dataset.{dataset name}.sched]' // use string literal to meet security check. - LabelAnnotationPodSchedRegex = regexp.MustCompile("^fluid\\.io/dataset\\.([A-Za-z0-9.-]*)\\.sched$") + LabelAnnotationPodSchedRegex = regexp.MustCompile(`^fluid\.io/dataset\.([A-Za-z0-9.-]*)\.sched$`) ) type OperationType string diff --git a/pkg/common/label_test.go b/pkg/common/label_test.go index b8e6c2c2fbf..81ea35e0e8e 100644 --- a/pkg/common/label_test.go +++ b/pkg/common/label_test.go @@ -244,10 +244,14 @@ func TestLabelAnnotationPodSchedRegex(t *testing.T) { match: true, got: "dsA", }, - "wrong": { + "wrong fluid.io": { target: "fluidaio/dataset.dsA.sched", match: false, }, + "wrong prefix": { + target: "a.fluid.io/dataset.dsA.sched", + match: false, + }, } for index, item := range testCases {