Skip to content

Commit

Permalink
fix: move category filed from annotations to labels
Browse files Browse the repository at this point in the history
  • Loading branch information
0xff-dev committed Apr 1, 2024
1 parent b80e4e4 commit 403c750
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions api/base/v1alpha1/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const (
InputNode = "Input"
OutputNode = "Output"

// AppCategoryAnnotationKey app category, like "recommend" or "recommend,chat,role-playing". Multiple types are separated by commas
AppCategoryAnnotationKey = Group + "/app-category"
// AppCategoryLabelKey app category, like "recommend" or "recommend,chat,role-playing". Multiple types are separated by commas
AppCategoryLabelKey = Group + "/app-category"

// AppPublicLabelKey will add to app which is public
AppPublicLabelKey = Group + "/app-is-public"
Expand Down
4 changes: 2 additions & 2 deletions apiserver/pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (

func addCategory(app *v1alpha1.Application, category []*string) *v1alpha1.Application {
if len(category) == 0 {
delete(app.Annotations, v1alpha1.AppCategoryAnnotationKey)
delete(app.Labels, v1alpha1.AppCategoryLabelKey)
return app
}
if app.Annotations == nil {
Expand All @@ -54,7 +54,7 @@ func addCategory(app *v1alpha1.Application, category []*string) *v1alpha1.Applic
for i := range category {
c[i] = *category[i]
}
app.Annotations[v1alpha1.AppCategoryAnnotationKey] = strings.Join(c, ",")
app.Labels[v1alpha1.AppCategoryLabelKey] = strings.Join(c, ",")
return app
}

Expand Down
2 changes: 1 addition & 1 deletion apiserver/pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TypedObjectReferenceToInput(ref generated.TypedObjectReference) generated.T

func GetAppCategory(app *v1alpha1.Application) []*string {
category := make([]*string, 0)
categoryStr, ok := app.GetAnnotations()[v1alpha1.AppCategoryAnnotationKey]
categoryStr, ok := app.GetLabels()[v1alpha1.AppCategoryLabelKey]
if ok && len(categoryStr) > 0 {
for _, v := range strings.Split(categoryStr, ",") {
v := v
Expand Down
2 changes: 1 addition & 1 deletion apiserver/pkg/common/common_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func FilterApplicationByKeyword(keyword string) ResourceFilter {

func FilterApplicationByCategory(category string) ResourceFilter {
return func(u client.Object) bool {
categoryStr, ok := u.GetAnnotations()[v1alpha1.AppCategoryAnnotationKey]
categoryStr, ok := u.GetLabels()[v1alpha1.AppCategoryLabelKey]
if !ok {
return false
}
Expand Down

0 comments on commit 403c750

Please sign in to comment.