You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ro...@apache.org on 2025/08/10 10:01:45 UTC

(dubbo-admin) branch develop updated: chore: add index example and rename files (#1311)

This is an automated email from the ASF dual-hosted git repository.

robocanic pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-admin.git


The following commit(s) were added to refs/heads/develop by this push:
     new 5961eb25 chore: add index example and rename files (#1311)
5961eb25 is described below

commit 5961eb257d4384c7f50266075ba23c7b9e71a696
Author: robb <ro...@gmail.com>
AuthorDate: Sun Aug 10 18:01:40 2025 +0800

    chore: add index example and rename files (#1311)
---
 .../resource/apis/mesh/v1alpha1/instance_index.go  | 25 ++++++++++++++++++++++
 pkg/core/store/{storeregistry.go => factory.go}    |  0
 pkg/core/store/{indexregistry.go => indexer.go}    |  0
 3 files changed, 25 insertions(+)

diff --git a/pkg/core/resource/apis/mesh/v1alpha1/instance_index.go b/pkg/core/resource/apis/mesh/v1alpha1/instance_index.go
new file mode 100644
index 00000000..32240c19
--- /dev/null
+++ b/pkg/core/resource/apis/mesh/v1alpha1/instance_index.go
@@ -0,0 +1,25 @@
+package v1alpha1
+
+import (
+	"fmt"
+
+	"github.com/apache/dubbo-admin/pkg/core/store"
+	"k8s.io/client-go/tools/cache"
+)
+
+func init() {
+	store.RegisterIndexers(InstanceKind, map[string]cache.IndexFunc{
+		"AppName": byAppName,
+	})
+}
+
+func byAppName(obj interface{}) ([]string, error) {
+	instance, ok := obj.(InstanceResource)
+	if !ok {
+		return nil, fmt.Errorf("invalid object type, required %s, got %v", InstanceKind, obj)
+	}
+	if instance.Spec == nil {
+		return []string{}, nil
+	}
+	return []string{instance.Spec.AppName}, nil
+}
diff --git a/pkg/core/store/storeregistry.go b/pkg/core/store/factory.go
similarity index 100%
rename from pkg/core/store/storeregistry.go
rename to pkg/core/store/factory.go
diff --git a/pkg/core/store/indexregistry.go b/pkg/core/store/indexer.go
similarity index 100%
rename from pkg/core/store/indexregistry.go
rename to pkg/core/store/indexer.go