Skip to content

Commit

Permalink
feat: added proto entity (#2144)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 authored Oct 11, 2021
1 parent e432392 commit a8298f4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions api/internal/core/entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
2 changes: 1 addition & 1 deletion api/internal/core/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
13 changes: 13 additions & 0 deletions api/internal/core/store/storehub.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
HubKeyGlobalRule HubKey = "global_rule"
HubKeyServerInfo HubKey = "server_info"
HubKeyPluginConfig HubKey = "plugin_config"
HubKeyProto HubKey = "proto"
)

var (
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions api/internal/filter/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var resources = map[string]string{
"consumers": "consumer",
"ssl": "ssl",
"global_rules": "global_rule",
"proto": "proto",
}

const (
Expand Down

0 comments on commit a8298f4

Please sign in to comment.