diff --git a/pkg/apis/metadata.go b/pkg/apis/metadata.go index ae7c4af1885..cfa915e10ee 100644 --- a/pkg/apis/metadata.go +++ b/pkg/apis/metadata.go @@ -54,6 +54,9 @@ type MetadataBaseFilterInput struct { // 同时显示用户标签 WithUserMeta *bool `json:"with_user_meta"` + // 按key模糊匹配 + KeyLike string `json:"key_like"` + // 按Key过滤 Key []string `json:"key"` diff --git a/pkg/cloudcommon/db/metadata.go b/pkg/cloudcommon/db/metadata.go index 2e517304c3c..f89fc70f330 100644 --- a/pkg/cloudcommon/db/metadata.go +++ b/pkg/cloudcommon/db/metadata.go @@ -341,6 +341,9 @@ func (manager *SMetadataManager) metaDataQuery2List(ctx context.Context, q *sqlc } func (manager *SMetadataManager) metadataBaseFilter(q *sqlchemy.SQuery, input apis.MetadataBaseFilterInput) *sqlchemy.SQuery { + if len(input.KeyLike) > 0 { + q = q.Contains("key", input.KeyLike) + } if len(input.Key) > 0 { q = q.In("key", input.Key) }