This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new a8298f4 feat: added proto entity (#2144)
a8298f4 is described below
commit a8298f40038b9488e9c177af273025cff3990a1b
Author: bzp2010 <[email protected]>
AuthorDate: Sun Oct 10 21:58:45 2021 -0500
feat: added proto entity (#2144)
---
api/internal/core/entity/entity.go | 7 +++++++
api/internal/core/store/store.go | 2 +-
api/internal/core/store/storehub.go | 13 +++++++++++++
api/internal/filter/schema.go | 1 +
4 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/api/internal/core/entity/entity.go
b/api/internal/core/entity/entity.go
index 4328bec..88f1b65 100644
--- a/api/internal/core/entity/entity.go
+++ b/api/internal/core/entity/entity.go
@@ -283,3 +283,10 @@ type PluginConfig struct {
Plugins map[string]interface{} `json:"plugins"`
Labels map[string]string `json:"labels,omitempty"`
}
+
+// swagger:model Proto
+type Proto struct {
+ BaseInfo
+ Desc string `json:"desc,omitempty"`
+ Content string `json:"content"`
+}
diff --git a/api/internal/core/store/store.go b/api/internal/core/store/store.go
index 176c261..53c5f22 100644
--- a/api/internal/core/store/store.go
+++ b/api/internal/core/store/store.go
@@ -108,7 +108,7 @@ func (s *GenericStore) Init() error {
key := ret[i].Key[len(s.opt.BasePath)+1:]
objPtr, err := s.StringToObjPtr(ret[i].Value, key)
if err != nil {
- fmt.Fprintln(os.Stderr, "Error occurred while
initializing logical store: ", s.opt.BasePath)
+ _, _ = fmt.Fprintln(os.Stderr, "Error occurred while
initializing logical store: ", s.opt.BasePath)
return err
}
diff --git a/api/internal/core/store/storehub.go
b/api/internal/core/store/storehub.go
index 4ab9962..dd2c873 100644
--- a/api/internal/core/store/storehub.go
+++ b/api/internal/core/store/storehub.go
@@ -38,6 +38,7 @@ const (
HubKeyGlobalRule HubKey = "global_rule"
HubKeyServerInfo HubKey = "server_info"
HubKeyPluginConfig HubKey = "plugin_config"
+ HubKeyProto HubKey = "proto"
)
var (
@@ -202,5 +203,17 @@ func InitStores() error {
return err
}
+ err = InitStore(HubKeyProto, GenericStoreOption{
+ BasePath: conf.ETCDConfig.Prefix + "/proto",
+ ObjType: reflect.TypeOf(entity.Proto{}),
+ KeyFunc: func(obj interface{}) string {
+ r := obj.(*entity.Proto)
+ return utils.InterfaceToString(r.ID)
+ },
+ })
+ if err != nil {
+ return err
+ }
+
return nil
}
diff --git a/api/internal/filter/schema.go b/api/internal/filter/schema.go
index 9bb6ccc..4c37f26 100644
--- a/api/internal/filter/schema.go
+++ b/api/internal/filter/schema.go
@@ -43,6 +43,7 @@ var resources = map[string]string{
"consumers": "consumer",
"ssl": "ssl",
"global_rules": "global_rule",
+ "proto": "proto",
}
const (