Skip to content

Commit d49ce8d

Browse files
committed
support search inspectplan by uuid
Signed-off-by: pixiake <guofeng@yunify.com>
1 parent c57cacf commit d49ce8d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pkg/server/api/inspectPlan.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ package api
22

33
import (
44
"context"
5+
"net/http"
6+
"regexp"
7+
"strings"
8+
59
"github.com/gin-gonic/gin"
610
"github.com/kubesphere/kubeeye/apis/kubeeye/v1alpha2"
711
versionsv1alpha2 "github.com/kubesphere/kubeeye/clients/informers/externalversions/kubeeye/v1alpha2"
@@ -11,8 +15,6 @@ import (
1115
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1216
"k8s.io/apimachinery/pkg/labels"
1317
"k8s.io/apimachinery/pkg/types"
14-
"net/http"
15-
"strings"
1618
)
1719

1820
type InspectPlan struct {
@@ -250,11 +252,20 @@ func (i *InspectPlan) filter(data map[string]interface{}, f *query.Filter) bool
250252
isTag = result.Spec.Schedule != nil || result.Spec.Once != nil
251253
}
252254
case query.Name:
253-
isTag = strings.Contains(result.Name, v)
255+
if isUUID(v) {
256+
isTag = string(result.UID) == v
257+
} else {
258+
isTag = strings.Contains(result.Name, v)
259+
}
254260
}
255261
if !isTag {
256262
return false
257263
}
258264
}
259265
return true
260266
}
267+
268+
func isUUID(str string) bool {
269+
r := regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$")
270+
return r.MatchString(str)
271+
}

0 commit comments

Comments
 (0)