From 54e7f526a00999c3f2b1a3729199d664268f4d32 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Thu, 25 Jul 2024 23:21:37 +0200 Subject: [PATCH] feat: add flags to the extension hooks commands (#4270) * add flags to the hook commands * add flags to executed hook cmd * create hook.ImportFlags method * add changelog * Update changelog.md --- changelog.md | 1 + ignite/cmd/plugin.go | 19 ++++- .../services/plugin/grpc/v1/client_api.pb.go | 6 +- .../services/plugin/grpc/v1/interface.pb.go | 70 +++++++++++-------- .../plugin/grpc/v1/interface_command.go | 6 +- .../services/plugin/grpc/v1/interface_flag.go | 2 +- .../services/plugin/grpc/v1/interface_hook.go | 7 ++ ignite/services/plugin/grpc/v1/service.pb.go | 28 ++++---- .../plugin/grpc/v1/service_grpc.pb.go | 32 ++++++--- .../services/plugin/grpc/v1/interface.proto | 3 + 10 files changed, 114 insertions(+), 60 deletions(-) diff --git a/changelog.md b/changelog.md index b805ec0e07..f24651cce6 100644 --- a/changelog.md +++ b/changelog.md @@ -16,6 +16,7 @@ - [#4111](https://github.com/ignite/cli/pull/4111) Remove vuex generation - [#4113](https://github.com/ignite/cli/pull/4113) Generate chain config documentation automatically - [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands +- [#4270](https://github.com/ignite/cli/pull/4270) Add flags to the extension hooks commands - [#4269](https://github.com/ignite/cli/pull/4269) Add custom flag parser for extensions - [#4276](https://github.com/ignite/cli/pull/4276) Add `cosmosclient.CreateTxWithOptions` method to facilite more custom tx creation diff --git a/ignite/cmd/plugin.go b/ignite/cmd/plugin.go index a0e4fbecf0..7e9e80f23a 100644 --- a/ignite/cmd/plugin.go +++ b/ignite/cmd/plugin.go @@ -180,6 +180,7 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook *plugin.Hook) } newExecutedHook := func(hook *plugin.Hook, cmd *cobra.Command, args []string) *plugin.ExecutedHook { + hook.ImportFlags(cmd) execHook := &plugin.ExecutedHook{ Hook: hook, ExecutedCommand: &plugin.ExecutedCommand{ @@ -188,12 +189,27 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook *plugin.Hook) Args: args, OsArgs: os.Args, With: p.With, + Flags: hook.Flags, }, } execHook.ExecutedCommand.ImportFlags(cmd) return execHook } + for _, f := range hook.Flags { + var fs *flag.FlagSet + if f.Persistent { + fs = cmd.PersistentFlags() + } else { + fs = cmd.Flags() + } + + if err := f.ExportToFlagSet(fs); err != nil { + p.Error = errors.Errorf("can't attach hook flags %q to command %q", hook.Flags, hook.PlaceHookOn) + return + } + } + preRun := cmd.PreRunE cmd.PreRunE = func(cmd *cobra.Command, args []string) error { if preRun != nil { @@ -218,11 +234,10 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook *plugin.Hook) } runCmd := cmd.RunE - cmd.RunE = func(cmd *cobra.Command, args []string) error { if runCmd != nil { err := runCmd(cmd, args) - // if the command has failed the `PostRun` will not execute. here we execute the cleanup step before returnning. + // if the command has failed the `PostRun` will not execute. here we execute the cleanup step before returning. if err != nil { api, err := newAppClientAPI(cmd) if err != nil { diff --git a/ignite/services/plugin/grpc/v1/client_api.pb.go b/ignite/services/plugin/grpc/v1/client_api.pb.go index f113c3f6ca..80db976ec2 100644 --- a/ignite/services/plugin/grpc/v1/client_api.pb.go +++ b/ignite/services/plugin/grpc/v1/client_api.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: ignite/services/plugin/grpc/v1/client_api.proto @@ -137,7 +137,7 @@ func file_ignite_services_plugin_grpc_v1_client_api_proto_rawDescGZIP() []byte { } var file_ignite_services_plugin_grpc_v1_client_api_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_ignite_services_plugin_grpc_v1_client_api_proto_goTypes = []interface{}{ +var file_ignite_services_plugin_grpc_v1_client_api_proto_goTypes = []any{ (*ChainInfo)(nil), // 0: ignite.services.plugin.grpc.v1.ChainInfo } var file_ignite_services_plugin_grpc_v1_client_api_proto_depIdxs = []int32{ @@ -154,7 +154,7 @@ func file_ignite_services_plugin_grpc_v1_client_api_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_ignite_services_plugin_grpc_v1_client_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_client_api_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ChainInfo); i { case 0: return &v.state diff --git a/ignite/services/plugin/grpc/v1/interface.pb.go b/ignite/services/plugin/grpc/v1/interface.pb.go index f63e64245e..f2c521a60e 100644 --- a/ignite/services/plugin/grpc/v1/interface.pb.go +++ b/ignite/services/plugin/grpc/v1/interface.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: ignite/services/plugin/grpc/v1/interface.proto @@ -563,6 +563,8 @@ type Hook struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Indicates the command where to register the hooks. PlaceHookOn string `protobuf:"bytes,2,opt,name=place_hook_on,json=placeHookOn,proto3" json:"place_hook_on,omitempty"` + // Flags holds the list of command flags. + Flags []*Flag `protobuf:"bytes,3,rep,name=flags,proto3" json:"flags,omitempty"` } func (x *Hook) Reset() { @@ -611,6 +613,13 @@ func (x *Hook) GetPlaceHookOn() string { return "" } +func (x *Hook) GetFlags() []*Flag { + if x != nil { + return x.Flags + } + return nil +} + var File_ignite_services_plugin_grpc_v1_interface_proto protoreflect.FileDescriptor var file_ignite_services_plugin_grpc_v1_interface_proto_rawDesc = []byte{ @@ -704,15 +713,19 @@ var file_ignite_services_plugin_grpc_v1_interface_proto_rawDesc = []byte{ 0x55, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x5f, 0x42, 0x4f, 0x4f, 0x4c, 0x10, 0x05, 0x12, 0x1a, 0x0a, 0x16, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x5f, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, - 0x5f, 0x53, 0x4c, 0x49, 0x43, 0x45, 0x10, 0x06, 0x22, 0x3e, 0x0a, 0x04, 0x48, 0x6f, 0x6f, 0x6b, + 0x5f, 0x53, 0x4c, 0x49, 0x43, 0x45, 0x10, 0x06, 0x22, 0x7a, 0x0a, 0x04, 0x48, 0x6f, 0x6f, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x5f, 0x68, 0x6f, 0x6f, 0x6b, 0x5f, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x6c, 0x61, - 0x63, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x4f, 0x6e, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x63, 0x6c, - 0x69, 0x2f, 0x76, 0x32, 0x39, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x67, 0x72, 0x70, - 0x63, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x4f, 0x6e, 0x12, 0x3a, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x05, 0x66, + 0x6c, 0x61, 0x67, 0x73, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x76, 0x32, + 0x39, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -729,7 +742,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_rawDescGZIP() []byte { var file_ignite_services_plugin_grpc_v1_interface_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_ignite_services_plugin_grpc_v1_interface_proto_goTypes = []interface{}{ +var file_ignite_services_plugin_grpc_v1_interface_proto_goTypes = []any{ (Flag_Type)(0), // 0: ignite.services.plugin.grpc.v1.Flag.Type (*ExecutedCommand)(nil), // 1: ignite.services.plugin.grpc.v1.ExecutedCommand (*ExecutedHook)(nil), // 2: ignite.services.plugin.grpc.v1.ExecutedHook @@ -740,20 +753,21 @@ var file_ignite_services_plugin_grpc_v1_interface_proto_goTypes = []interface{}{ nil, // 7: ignite.services.plugin.grpc.v1.ExecutedCommand.WithEntry } var file_ignite_services_plugin_grpc_v1_interface_proto_depIdxs = []int32{ - 7, // 0: ignite.services.plugin.grpc.v1.ExecutedCommand.with:type_name -> ignite.services.plugin.grpc.v1.ExecutedCommand.WithEntry - 5, // 1: ignite.services.plugin.grpc.v1.ExecutedCommand.flags:type_name -> ignite.services.plugin.grpc.v1.Flag - 6, // 2: ignite.services.plugin.grpc.v1.ExecutedHook.hook:type_name -> ignite.services.plugin.grpc.v1.Hook - 1, // 3: ignite.services.plugin.grpc.v1.ExecutedHook.executed_command:type_name -> ignite.services.plugin.grpc.v1.ExecutedCommand - 4, // 4: ignite.services.plugin.grpc.v1.Manifest.commands:type_name -> ignite.services.plugin.grpc.v1.Command - 6, // 5: ignite.services.plugin.grpc.v1.Manifest.hooks:type_name -> ignite.services.plugin.grpc.v1.Hook - 5, // 6: ignite.services.plugin.grpc.v1.Command.flags:type_name -> ignite.services.plugin.grpc.v1.Flag - 4, // 7: ignite.services.plugin.grpc.v1.Command.commands:type_name -> ignite.services.plugin.grpc.v1.Command - 0, // 8: ignite.services.plugin.grpc.v1.Flag.type:type_name -> ignite.services.plugin.grpc.v1.Flag.Type - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 7, // 0: ignite.services.plugin.grpc.v1.ExecutedCommand.with:type_name -> ignite.services.plugin.grpc.v1.ExecutedCommand.WithEntry + 5, // 1: ignite.services.plugin.grpc.v1.ExecutedCommand.flags:type_name -> ignite.services.plugin.grpc.v1.Flag + 6, // 2: ignite.services.plugin.grpc.v1.ExecutedHook.hook:type_name -> ignite.services.plugin.grpc.v1.Hook + 1, // 3: ignite.services.plugin.grpc.v1.ExecutedHook.executed_command:type_name -> ignite.services.plugin.grpc.v1.ExecutedCommand + 4, // 4: ignite.services.plugin.grpc.v1.Manifest.commands:type_name -> ignite.services.plugin.grpc.v1.Command + 6, // 5: ignite.services.plugin.grpc.v1.Manifest.hooks:type_name -> ignite.services.plugin.grpc.v1.Hook + 5, // 6: ignite.services.plugin.grpc.v1.Command.flags:type_name -> ignite.services.plugin.grpc.v1.Flag + 4, // 7: ignite.services.plugin.grpc.v1.Command.commands:type_name -> ignite.services.plugin.grpc.v1.Command + 0, // 8: ignite.services.plugin.grpc.v1.Flag.type:type_name -> ignite.services.plugin.grpc.v1.Flag.Type + 5, // 9: ignite.services.plugin.grpc.v1.Hook.flags:type_name -> ignite.services.plugin.grpc.v1.Flag + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_ignite_services_plugin_grpc_v1_interface_proto_init() } @@ -762,7 +776,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ExecutedCommand); i { case 0: return &v.state @@ -774,7 +788,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ExecutedHook); i { case 0: return &v.state @@ -786,7 +800,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Manifest); i { case 0: return &v.state @@ -798,7 +812,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Command); i { case 0: return &v.state @@ -810,7 +824,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Flag); i { case 0: return &v.state @@ -822,7 +836,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*Hook); i { case 0: return &v.state diff --git a/ignite/services/plugin/grpc/v1/interface_command.go b/ignite/services/plugin/grpc/v1/interface_command.go index c396c75146..01721f966c 100644 --- a/ignite/services/plugin/grpc/v1/interface_command.go +++ b/ignite/services/plugin/grpc/v1/interface_command.go @@ -32,7 +32,7 @@ func (c *Command) ToCobraCommand() (*cobra.Command, error) { fs = cmd.Flags() } - if err := f.exportToFlagSet(fs); err != nil { + if err := f.ExportToFlagSet(fs); err != nil { return nil, err } } @@ -54,7 +54,7 @@ func (c *ExecutedCommand) NewFlags() (*pflag.FlagSet, error) { continue } - if err := f.exportToFlagSet(fs); err != nil { + if err := f.ExportToFlagSet(fs); err != nil { return nil, err } } @@ -71,7 +71,7 @@ func (c *ExecutedCommand) NewPersistentFlags() (*pflag.FlagSet, error) { continue } - if err := f.exportToFlagSet(fs); err != nil { + if err := f.ExportToFlagSet(fs); err != nil { return nil, err } } diff --git a/ignite/services/plugin/grpc/v1/interface_flag.go b/ignite/services/plugin/grpc/v1/interface_flag.go index c4136469f5..dca5ba203d 100644 --- a/ignite/services/plugin/grpc/v1/interface_flag.go +++ b/ignite/services/plugin/grpc/v1/interface_flag.go @@ -33,7 +33,7 @@ func newDefaultFlagValueError(typeName, value string) error { return errors.Errorf("invalid default value for plugin command %s flag: %s", typeName, value) } -func (f *Flag) exportToFlagSet(fs *pflag.FlagSet) error { +func (f *Flag) ExportToFlagSet(fs *pflag.FlagSet) error { switch f.Type { //nolint:exhaustive case Flag_TYPE_FLAG_BOOL, Flag_TYPE_FLAG_INT, diff --git a/ignite/services/plugin/grpc/v1/interface_hook.go b/ignite/services/plugin/grpc/v1/interface_hook.go index db5d02484a..bb39ef945e 100644 --- a/ignite/services/plugin/grpc/v1/interface_hook.go +++ b/ignite/services/plugin/grpc/v1/interface_hook.go @@ -1,6 +1,13 @@ package v1 +import "github.com/spf13/cobra" + // CommandPath returns the absolute command path including the binary name as prefix. func (h *Hook) CommandPath() string { return ensureFullCommandPath(h.PlaceHookOn) } + +// ImportFlags imports flags from a Cobra command. +func (h *Hook) ImportFlags(cmd *cobra.Command) { + h.Flags = extractCobraFlags(cmd) +} diff --git a/ignite/services/plugin/grpc/v1/service.pb.go b/ignite/services/plugin/grpc/v1/service.pb.go index 0845145f5f..58d6b335d9 100644 --- a/ignite/services/plugin/grpc/v1/service.pb.go +++ b/ignite/services/plugin/grpc/v1/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: ignite/services/plugin/grpc/v1/service.proto @@ -697,7 +697,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_rawDescGZIP() []byte { } var file_ignite_services_plugin_grpc_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 12) -var file_ignite_services_plugin_grpc_v1_service_proto_goTypes = []interface{}{ +var file_ignite_services_plugin_grpc_v1_service_proto_goTypes = []any{ (*ManifestRequest)(nil), // 0: ignite.services.plugin.grpc.v1.ManifestRequest (*ManifestResponse)(nil), // 1: ignite.services.plugin.grpc.v1.ManifestResponse (*ExecuteRequest)(nil), // 2: ignite.services.plugin.grpc.v1.ExecuteRequest @@ -749,7 +749,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { file_ignite_services_plugin_grpc_v1_client_api_proto_init() file_ignite_services_plugin_grpc_v1_interface_proto_init() if !protoimpl.UnsafeEnabled { - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ManifestRequest); i { case 0: return &v.state @@ -761,7 +761,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ManifestResponse); i { case 0: return &v.state @@ -773,7 +773,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ExecuteRequest); i { case 0: return &v.state @@ -785,7 +785,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ExecuteResponse); i { case 0: return &v.state @@ -797,7 +797,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookPreRequest); i { case 0: return &v.state @@ -809,7 +809,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookPreResponse); i { case 0: return &v.state @@ -821,7 +821,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookPostRequest); i { case 0: return &v.state @@ -833,7 +833,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookPostResponse); i { case 0: return &v.state @@ -845,7 +845,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookCleanUpRequest); i { case 0: return &v.state @@ -857,7 +857,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookCleanUpResponse); i { case 0: return &v.state @@ -869,7 +869,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*GetChainInfoRequest); i { case 0: return &v.state @@ -881,7 +881,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*GetChainInfoResponse); i { case 0: return &v.state diff --git a/ignite/services/plugin/grpc/v1/service_grpc.pb.go b/ignite/services/plugin/grpc/v1/service_grpc.pb.go index 759410d156..f40fafe16d 100644 --- a/ignite/services/plugin/grpc/v1/service_grpc.pb.go +++ b/ignite/services/plugin/grpc/v1/service_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.4.0 // - protoc (unknown) // source: ignite/services/plugin/grpc/v1/service.proto @@ -16,8 +16,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.62.0 or later. +const _ = grpc.SupportPackageIsVersion8 const ( InterfaceService_Manifest_FullMethodName = "/ignite.services.plugin.grpc.v1.InterfaceService/Manifest" @@ -30,6 +30,8 @@ const ( // InterfaceServiceClient is the client API for InterfaceService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// InterfaceService defines the interface that must be implemented by all plugins. type InterfaceServiceClient interface { // Manifest declares the plugin's Command(s) and Hook(s). Manifest(ctx context.Context, in *ManifestRequest, opts ...grpc.CallOption) (*ManifestResponse, error) @@ -64,8 +66,9 @@ func NewInterfaceServiceClient(cc grpc.ClientConnInterface) InterfaceServiceClie } func (c *interfaceServiceClient) Manifest(ctx context.Context, in *ManifestRequest, opts ...grpc.CallOption) (*ManifestResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ManifestResponse) - err := c.cc.Invoke(ctx, InterfaceService_Manifest_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_Manifest_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -73,8 +76,9 @@ func (c *interfaceServiceClient) Manifest(ctx context.Context, in *ManifestReque } func (c *interfaceServiceClient) Execute(ctx context.Context, in *ExecuteRequest, opts ...grpc.CallOption) (*ExecuteResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExecuteResponse) - err := c.cc.Invoke(ctx, InterfaceService_Execute_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_Execute_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -82,8 +86,9 @@ func (c *interfaceServiceClient) Execute(ctx context.Context, in *ExecuteRequest } func (c *interfaceServiceClient) ExecuteHookPre(ctx context.Context, in *ExecuteHookPreRequest, opts ...grpc.CallOption) (*ExecuteHookPreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExecuteHookPreResponse) - err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookPre_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookPre_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -91,8 +96,9 @@ func (c *interfaceServiceClient) ExecuteHookPre(ctx context.Context, in *Execute } func (c *interfaceServiceClient) ExecuteHookPost(ctx context.Context, in *ExecuteHookPostRequest, opts ...grpc.CallOption) (*ExecuteHookPostResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExecuteHookPostResponse) - err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookPost_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookPost_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -100,8 +106,9 @@ func (c *interfaceServiceClient) ExecuteHookPost(ctx context.Context, in *Execut } func (c *interfaceServiceClient) ExecuteHookCleanUp(ctx context.Context, in *ExecuteHookCleanUpRequest, opts ...grpc.CallOption) (*ExecuteHookCleanUpResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExecuteHookCleanUpResponse) - err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookCleanUp_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookCleanUp_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -111,6 +118,8 @@ func (c *interfaceServiceClient) ExecuteHookCleanUp(ctx context.Context, in *Exe // InterfaceServiceServer is the server API for InterfaceService service. // All implementations must embed UnimplementedInterfaceServiceServer // for forward compatibility +// +// InterfaceService defines the interface that must be implemented by all plugins. type InterfaceServiceServer interface { // Manifest declares the plugin's Command(s) and Hook(s). Manifest(context.Context, *ManifestRequest) (*ManifestResponse, error) @@ -298,6 +307,8 @@ const ( // ClientAPIServiceClient is the client API for ClientAPIService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// ClientAPIService defines the interface that allows plugins to get chain app analysis info. type ClientAPIServiceClient interface { // GetChainInfo returns basic chain info for the configured app GetChainInfo(ctx context.Context, in *GetChainInfoRequest, opts ...grpc.CallOption) (*GetChainInfoResponse, error) @@ -312,8 +323,9 @@ func NewClientAPIServiceClient(cc grpc.ClientConnInterface) ClientAPIServiceClie } func (c *clientAPIServiceClient) GetChainInfo(ctx context.Context, in *GetChainInfoRequest, opts ...grpc.CallOption) (*GetChainInfoResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetChainInfoResponse) - err := c.cc.Invoke(ctx, ClientAPIService_GetChainInfo_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, ClientAPIService_GetChainInfo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -323,6 +335,8 @@ func (c *clientAPIServiceClient) GetChainInfo(ctx context.Context, in *GetChainI // ClientAPIServiceServer is the server API for ClientAPIService service. // All implementations must embed UnimplementedClientAPIServiceServer // for forward compatibility +// +// ClientAPIService defines the interface that allows plugins to get chain app analysis info. type ClientAPIServiceServer interface { // GetChainInfo returns basic chain info for the configured app GetChainInfo(context.Context, *GetChainInfoRequest) (*GetChainInfoResponse, error) diff --git a/proto/ignite/services/plugin/grpc/v1/interface.proto b/proto/ignite/services/plugin/grpc/v1/interface.proto index 7747e2a644..34ecf2654b 100644 --- a/proto/ignite/services/plugin/grpc/v1/interface.proto +++ b/proto/ignite/services/plugin/grpc/v1/interface.proto @@ -144,4 +144,7 @@ message Hook { // Indicates the command where to register the hooks. string place_hook_on = 2; + + // Flags holds the list of command flags. + repeated Flag flags = 3; }