From 4671921a6fa75ab0fec1182086192cf931dc2401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Gro=C3=9Fmann?= Date: Thu, 2 Apr 2026 14:04:23 +0200 Subject: [PATCH] feat: engine management API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Großmann --- client/client.go | 84 +- client/client_test.go | 84 +- x/api/plugins/v1/api.pb.go | 824 ++++++++++++++++++ x/api/plugins/v1/api.proto | 70 ++ .../v1/pluginsv1connect/api.connect.go | 174 ++++ x/api/resolver/v1/api.pb.go | 408 +-------- x/api/resolver/v1/api.proto | 24 - .../v1/resolverv1connect/api.connect.go | 76 -- 8 files changed, 1225 insertions(+), 519 deletions(-) create mode 100644 x/api/plugins/v1/api.pb.go create mode 100644 x/api/plugins/v1/api.proto create mode 100644 x/api/plugins/v1/pluginsv1connect/api.connect.go diff --git a/client/client.go b/client/client.go index ac99d61b..677b358d 100644 --- a/client/client.go +++ b/client/client.go @@ -27,9 +27,9 @@ import ( "github.com/docker/secrets-engine/x/api" healthv1 "github.com/docker/secrets-engine/x/api/health/v1" "github.com/docker/secrets-engine/x/api/health/v1/healthv1connect" + pluginsv1 "github.com/docker/secrets-engine/x/api/plugins/v1" + "github.com/docker/secrets-engine/x/api/plugins/v1/pluginsv1connect" "github.com/docker/secrets-engine/x/api/resolver" - v1 "github.com/docker/secrets-engine/x/api/resolver/v1" - "github.com/docker/secrets-engine/x/api/resolver/v1/resolverv1connect" "github.com/docker/secrets-engine/x/secrets" ) @@ -83,7 +83,7 @@ func WithDialContext(dialContext func(ctx context.Context, network, addr string) // It is useful to set if there are hard-limits to when the client must wait // for the server to accept the request. // -// A timout of 0 means no request timeout will be applied. +// A timeout of 0 means no request timeout will be applied. // Negative durations are not allowed and will result in an error. func WithTimeout(timeout time.Duration) Option { return func(s *config) error { @@ -120,9 +120,14 @@ type config struct { responseTimeout time.Duration } +var ( + _ Client = &client{} + _ PluginManagement = &client{} +) + type client struct { resolverClient secrets.Resolver - listClient resolverv1connect.ListServiceClient + engineClient pluginsv1connect.PluginManagementServiceClient versionClient healthv1connect.VersionServiceClient } @@ -158,8 +163,20 @@ type Client interface { // Version returns the name and version reported by the daemon. Version(ctx context.Context) (DaemonVersion, error) +} +type PluginManagement interface { ListPlugins(ctx context.Context) ([]PluginInfo, error) + EnablePlugin(ctx context.Context, name string) error + DisablePlugin(ctx context.Context, name string) error +} + +func PluginManagementFromClient(c Client) (PluginManagement, error) { + m, ok := c.(PluginManagement) + if !ok { + return nil, errors.New("client does not implement PluginManagement") + } + return m, nil } func isDialError(err error) bool { @@ -209,14 +226,14 @@ func New(options ...Option) (Client, error) { } return &client{ resolverClient: resolver.NewResolverClient(c), - listClient: resolverv1connect.NewListServiceClient(c, "http://unix"), + engineClient: pluginsv1connect.NewPluginManagementServiceClient(c, "http://unix"), versionClient: healthv1connect.NewVersionServiceClient(c, "http://unix"), }, nil } func (c client) ListPlugins(ctx context.Context) ([]PluginInfo, error) { - req := connect.NewRequest(v1.ListPluginsRequest_builder{}.Build()) - resp, err := c.listClient.ListPlugins(ctx, req) + req := connect.NewRequest(pluginsv1.ListPluginsRequest_builder{}.Build()) + resp, err := c.engineClient.ListPlugins(ctx, req) if isDialError(err) { return nil, fmt.Errorf("%w: %w", ErrSecretsEngineNotAvailable, err) } @@ -233,27 +250,56 @@ func (c client) ListPlugins(ctx context.Context) ([]PluginInfo, error) { if err != nil { continue } - pattern, err := secrets.ParsePattern(item.GetPattern()) - if err != nil { - continue - } - result = append(result, PluginInfo{ + info := PluginInfo{ Name: name, Version: version, - Pattern: pattern, + Disabled: item.GetDisabled(), External: item.GetExternal(), Configurable: item.GetConfigurable(), - }) + } + if sp := item.GetSecretsProvider(); sp != nil { + pattern, err := secrets.ParsePattern(sp.GetPattern()) + if err != nil { + continue + } + info.SecretsProvider = &SecretsProviderMetadata{Pattern: pattern} + } + result = append(result, info) } return result, nil } +func (c client) EnablePlugin(ctx context.Context, name string) error { + r := pluginsv1.EnablePluginRequest_builder{}.Build() + r.SetName(name) + _, err := c.engineClient.EnablePlugin(ctx, connect.NewRequest(r)) + if isDialError(err) { + return fmt.Errorf("%w: %w", ErrSecretsEngineNotAvailable, err) + } + return err +} + +func (c client) DisablePlugin(ctx context.Context, name string) error { + r := pluginsv1.DisablePluginRequest_builder{}.Build() + r.SetName(name) + _, err := c.engineClient.DisablePlugin(ctx, connect.NewRequest(r)) + if isDialError(err) { + return fmt.Errorf("%w: %w", ErrSecretsEngineNotAvailable, err) + } + return err +} + type PluginInfo struct { - Name api.Name - Version api.Version - Pattern secrets.Pattern - External bool - Configurable bool + Name api.Name + Version api.Version + Disabled bool + External bool + Configurable bool + SecretsProvider *SecretsProviderMetadata +} + +type SecretsProviderMetadata struct { + Pattern secrets.Pattern } func dialFromPath(path string) dial { diff --git a/client/client_test.go b/client/client_test.go index 076421e8..08c99785 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -31,8 +31,8 @@ import ( "github.com/docker/secrets-engine/x/api" healthv1 "github.com/docker/secrets-engine/x/api/health/v1" "github.com/docker/secrets-engine/x/api/health/v1/healthv1connect" - resolverv1 "github.com/docker/secrets-engine/x/api/resolver/v1" - "github.com/docker/secrets-engine/x/api/resolver/v1/resolverv1connect" + pluginsv1 "github.com/docker/secrets-engine/x/api/plugins/v1" + "github.com/docker/secrets-engine/x/api/plugins/v1/pluginsv1connect" "github.com/docker/secrets-engine/x/secrets" "github.com/docker/secrets-engine/x/testhelper" ) @@ -60,14 +60,14 @@ func mockVersionEngine(t *testing.T, version, date, commitHash string) string { return socketPath } -var _ resolverv1connect.ListServiceHandler = &mockPluginsList{} +var _ pluginsv1connect.PluginManagementServiceHandler = &mockPluginsList{} type mockPluginsList struct { list []PluginInfo } -func (m mockPluginsList) ListPlugins(context.Context, *connect.Request[resolverv1.ListPluginsRequest]) (*connect.Response[resolverv1.ListPluginsResponse], error) { - var plugins []*resolverv1.Plugin +func (m mockPluginsList) ListPlugins(_ context.Context, _ *connect.Request[pluginsv1.ListPluginsRequest]) (*connect.Response[pluginsv1.ListPluginsResponse], error) { + var plugins []*pluginsv1.Plugin for _, plugin := range m.list { var name string if plugin.Name != nil { @@ -77,23 +77,33 @@ func (m mockPluginsList) ListPlugins(context.Context, *connect.Request[resolverv if plugin.Version != nil { version = plugin.Version.String() } - var pattern string - if plugin.Pattern != nil { - pattern = plugin.Pattern.String() - } - plugins = append(plugins, resolverv1.Plugin_builder{ + b := pluginsv1.Plugin_builder{ Name: proto.String(name), Version: proto.String(version), - Pattern: proto.String(pattern), + Disabled: proto.Bool(plugin.Disabled), External: proto.Bool(plugin.External), Configurable: proto.Bool(plugin.Configurable), - }.Build()) + } + if plugin.SecretsProvider != nil { + b.SecretsProvider = pluginsv1.SecretsProvider_builder{ + Pattern: proto.String(plugin.SecretsProvider.Pattern.String()), + }.Build() + } + plugins = append(plugins, b.Build()) } - return connect.NewResponse(resolverv1.ListPluginsResponse_builder{ + return connect.NewResponse(pluginsv1.ListPluginsResponse_builder{ Plugins: plugins, }.Build()), nil } +func (m mockPluginsList) EnablePlugin(_ context.Context, _ *connect.Request[pluginsv1.EnablePluginRequest]) (*connect.Response[pluginsv1.EnablePluginResponse], error) { + return connect.NewResponse(pluginsv1.EnablePluginResponse_builder{}.Build()), nil +} + +func (m mockPluginsList) DisablePlugin(_ context.Context, _ *connect.Request[pluginsv1.DisablePluginRequest]) (*connect.Response[pluginsv1.DisablePluginResponse], error) { + return connect.NewResponse(pluginsv1.DisablePluginResponse_builder{}.Build()), nil +} + type handler struct { pattern string handler http.Handler @@ -133,7 +143,7 @@ func wrapHandler(pattern string, h http.Handler) handler { func mockListPluginsEngine(t *testing.T, plugins []PluginInfo) string { t.Helper() socketPath := testhelper.RandomShortSocketName() - muxServer(t, socketPath, []handler{wrapHandler(resolverv1connect.NewListServiceHandler(&mockPluginsList{list: plugins}))}) + muxServer(t, socketPath, []handler{wrapHandler(pluginsv1connect.NewPluginManagementServiceHandler(&mockPluginsList{list: plugins}))}) return socketPath } @@ -142,22 +152,25 @@ func Test_ListPlugins(t *testing.T) { t.Run("external and internal configurable plugins", func(t *testing.T) { plugins := []PluginInfo{ { - Name: api.MustNewName("foo"), - Version: api.MustNewVersion("v1"), - Pattern: secrets.MustParsePattern("**"), - Configurable: true, + Name: api.MustNewName("foo"), + Version: api.MustNewVersion("v1"), + SecretsProvider: &SecretsProviderMetadata{Pattern: secrets.MustParsePattern("**")}, + Configurable: true, + Disabled: true, }, { - Name: api.MustNewName("bar"), - Version: api.MustNewVersion("v1"), - Pattern: secrets.MustParsePattern("**"), - External: true, + Name: api.MustNewName("bar"), + Version: api.MustNewVersion("v1"), + SecretsProvider: &SecretsProviderMetadata{Pattern: secrets.MustParsePattern("**")}, + External: true, }, } socket := mockListPluginsEngine(t, plugins) client, err := New(WithSocketPath(socket)) require.NoError(t, err) - result, err := client.ListPlugins(t.Context()) + m, err := PluginManagementFromClient(client) + require.NoError(t, err) + result, err := m.ListPlugins(t.Context()) require.NoError(t, err) assert.Equal(t, plugins, result) }) @@ -166,7 +179,9 @@ func Test_ListPlugins(t *testing.T) { socket := mockListPluginsEngine(t, plugins) client, err := New(WithSocketPath(socket)) require.NoError(t, err) - result, err := client.ListPlugins(t.Context()) + m, err := PluginManagementFromClient(client) + require.NoError(t, err) + result, err := m.ListPlugins(t.Context()) require.NoError(t, err) assert.Empty(t, result) }) @@ -176,21 +191,24 @@ func Test_ListPlugins(t *testing.T) { Name: api.MustNewName("foo"), }, { - Name: api.MustNewName("bar"), - Version: api.MustNewVersion("v1"), - Pattern: secrets.MustParsePattern("**"), + Name: api.MustNewName("bar"), + Version: api.MustNewVersion("v1"), + SecretsProvider: &SecretsProviderMetadata{Pattern: secrets.MustParsePattern("**")}, }, } socket := mockListPluginsEngine(t, plugins) client, err := New(WithSocketPath(socket)) require.NoError(t, err) - result, err := client.ListPlugins(t.Context()) + m, err := PluginManagementFromClient(client) require.NoError(t, err) + result, err := m.ListPlugins(t.Context()) + require.NoError(t, err) + assert.Equal(t, []PluginInfo{ { - Name: api.MustNewName("bar"), - Version: api.MustNewVersion("v1"), - Pattern: secrets.MustParsePattern("**"), + Name: api.MustNewName("bar"), + Version: api.MustNewVersion("v1"), + SecretsProvider: &SecretsProviderMetadata{Pattern: secrets.MustParsePattern("**")}, }, }, result) }) @@ -221,7 +239,9 @@ func TestSecretsEngineUnavailable(t *testing.T) { socketPath := testhelper.RandomShortSocketName() client, err := New(WithSocketPath(socketPath)) require.NoError(t, err) - _, err = client.ListPlugins(t.Context()) + m, err := PluginManagementFromClient(client) + require.NoError(t, err) + _, err = m.ListPlugins(t.Context()) require.ErrorIs(t, err, ErrSecretsEngineNotAvailable) _, err = client.GetSecrets(t.Context(), secrets.MustParsePattern("**")) require.ErrorIs(t, err, ErrSecretsEngineNotAvailable) diff --git a/x/api/plugins/v1/api.pb.go b/x/api/plugins/v1/api.pb.go new file mode 100644 index 00000000..5186cb06 --- /dev/null +++ b/x/api/plugins/v1/api.pb.go @@ -0,0 +1,824 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.7 +// protoc (unknown) +// source: plugins/v1/api.proto + +package pluginsv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Plugin struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name *string `protobuf:"bytes,1,opt,name=name"` + xxx_hidden_Version *string `protobuf:"bytes,2,opt,name=version"` + xxx_hidden_Disabled bool `protobuf:"varint,3,opt,name=disabled"` + xxx_hidden_External bool `protobuf:"varint,4,opt,name=external"` + xxx_hidden_Configurable bool `protobuf:"varint,5,opt,name=configurable"` + xxx_hidden_Metadata isPlugin_Metadata `protobuf_oneof:"metadata"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Plugin) Reset() { + *x = Plugin{} + mi := &file_plugins_v1_api_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Plugin) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Plugin) ProtoMessage() {} + +func (x *Plugin) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_api_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Plugin) GetName() string { + if x != nil { + if x.xxx_hidden_Name != nil { + return *x.xxx_hidden_Name + } + return "" + } + return "" +} + +func (x *Plugin) GetVersion() string { + if x != nil { + if x.xxx_hidden_Version != nil { + return *x.xxx_hidden_Version + } + return "" + } + return "" +} + +func (x *Plugin) GetDisabled() bool { + if x != nil { + return x.xxx_hidden_Disabled + } + return false +} + +func (x *Plugin) GetExternal() bool { + if x != nil { + return x.xxx_hidden_External + } + return false +} + +func (x *Plugin) GetConfigurable() bool { + if x != nil { + return x.xxx_hidden_Configurable + } + return false +} + +func (x *Plugin) GetSecretsProvider() *SecretsProvider { + if x != nil { + if x, ok := x.xxx_hidden_Metadata.(*plugin_SecretsProvider); ok { + return x.SecretsProvider + } + } + return nil +} + +func (x *Plugin) SetName(v string) { + x.xxx_hidden_Name = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 6) +} + +func (x *Plugin) SetVersion(v string) { + x.xxx_hidden_Version = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 6) +} + +func (x *Plugin) SetDisabled(v bool) { + x.xxx_hidden_Disabled = v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 6) +} + +func (x *Plugin) SetExternal(v bool) { + x.xxx_hidden_External = v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 6) +} + +func (x *Plugin) SetConfigurable(v bool) { + x.xxx_hidden_Configurable = v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 6) +} + +func (x *Plugin) SetSecretsProvider(v *SecretsProvider) { + if v == nil { + x.xxx_hidden_Metadata = nil + return + } + x.xxx_hidden_Metadata = &plugin_SecretsProvider{v} +} + +func (x *Plugin) HasName() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *Plugin) HasVersion() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 1) +} + +func (x *Plugin) HasDisabled() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 2) +} + +func (x *Plugin) HasExternal() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 3) +} + +func (x *Plugin) HasConfigurable() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 4) +} + +func (x *Plugin) HasMetadata() bool { + if x == nil { + return false + } + return x.xxx_hidden_Metadata != nil +} + +func (x *Plugin) HasSecretsProvider() bool { + if x == nil { + return false + } + _, ok := x.xxx_hidden_Metadata.(*plugin_SecretsProvider) + return ok +} + +func (x *Plugin) ClearName() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Name = nil +} + +func (x *Plugin) ClearVersion() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) + x.xxx_hidden_Version = nil +} + +func (x *Plugin) ClearDisabled() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) + x.xxx_hidden_Disabled = false +} + +func (x *Plugin) ClearExternal() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) + x.xxx_hidden_External = false +} + +func (x *Plugin) ClearConfigurable() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) + x.xxx_hidden_Configurable = false +} + +func (x *Plugin) ClearMetadata() { + x.xxx_hidden_Metadata = nil +} + +func (x *Plugin) ClearSecretsProvider() { + if _, ok := x.xxx_hidden_Metadata.(*plugin_SecretsProvider); ok { + x.xxx_hidden_Metadata = nil + } +} + +const Plugin_Metadata_not_set_case case_Plugin_Metadata = 0 +const Plugin_SecretsProvider_case case_Plugin_Metadata = 6 + +func (x *Plugin) WhichMetadata() case_Plugin_Metadata { + if x == nil { + return Plugin_Metadata_not_set_case + } + switch x.xxx_hidden_Metadata.(type) { + case *plugin_SecretsProvider: + return Plugin_SecretsProvider_case + default: + return Plugin_Metadata_not_set_case + } +} + +type Plugin_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // Name + Name *string + // Version + Version *string + // Enabled vs disabled + Disabled *bool + // External vs builtin + External *bool + // Configurable + Configurable *bool + // Type-specific fields + + // Fields of oneof xxx_hidden_Metadata: + SecretsProvider *SecretsProvider + // -- end of xxx_hidden_Metadata +} + +func (b0 Plugin_builder) Build() *Plugin { + m0 := &Plugin{} + b, x := &b0, m0 + _, _ = b, x + if b.Name != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 6) + x.xxx_hidden_Name = b.Name + } + if b.Version != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 6) + x.xxx_hidden_Version = b.Version + } + if b.Disabled != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 6) + x.xxx_hidden_Disabled = *b.Disabled + } + if b.External != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 6) + x.xxx_hidden_External = *b.External + } + if b.Configurable != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 6) + x.xxx_hidden_Configurable = *b.Configurable + } + if b.SecretsProvider != nil { + x.xxx_hidden_Metadata = &plugin_SecretsProvider{b.SecretsProvider} + } + return m0 +} + +type case_Plugin_Metadata protoreflect.FieldNumber + +func (x case_Plugin_Metadata) String() string { + md := file_plugins_v1_api_proto_msgTypes[0].Descriptor() + if x == 0 { + return "not set" + } + return protoimpl.X.MessageFieldStringOf(md, protoreflect.FieldNumber(x)) +} + +type isPlugin_Metadata interface { + isPlugin_Metadata() +} + +type plugin_SecretsProvider struct { + SecretsProvider *SecretsProvider `protobuf:"bytes,6,opt,name=secrets_provider,json=secretsProvider,oneof"` +} + +func (*plugin_SecretsProvider) isPlugin_Metadata() {} + +type SecretsProvider struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Pattern *string `protobuf:"bytes,1,opt,name=pattern"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SecretsProvider) Reset() { + *x = SecretsProvider{} + mi := &file_plugins_v1_api_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SecretsProvider) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SecretsProvider) ProtoMessage() {} + +func (x *SecretsProvider) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_api_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *SecretsProvider) GetPattern() string { + if x != nil { + if x.xxx_hidden_Pattern != nil { + return *x.xxx_hidden_Pattern + } + return "" + } + return "" +} + +func (x *SecretsProvider) SetPattern(v string) { + x.xxx_hidden_Pattern = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 1) +} + +func (x *SecretsProvider) HasPattern() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *SecretsProvider) ClearPattern() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Pattern = nil +} + +type SecretsProvider_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // Pattern + Pattern *string +} + +func (b0 SecretsProvider_builder) Build() *SecretsProvider { + m0 := &SecretsProvider{} + b, x := &b0, m0 + _, _ = b, x + if b.Pattern != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 1) + x.xxx_hidden_Pattern = b.Pattern + } + return m0 +} + +type ListPluginsRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPluginsRequest) Reset() { + *x = ListPluginsRequest{} + mi := &file_plugins_v1_api_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPluginsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPluginsRequest) ProtoMessage() {} + +func (x *ListPluginsRequest) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_api_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type ListPluginsRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 ListPluginsRequest_builder) Build() *ListPluginsRequest { + m0 := &ListPluginsRequest{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +type ListPluginsResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Plugins *[]*Plugin `protobuf:"bytes,1,rep,name=plugins"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPluginsResponse) Reset() { + *x = ListPluginsResponse{} + mi := &file_plugins_v1_api_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPluginsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPluginsResponse) ProtoMessage() {} + +func (x *ListPluginsResponse) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_api_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ListPluginsResponse) GetPlugins() []*Plugin { + if x != nil { + if x.xxx_hidden_Plugins != nil { + return *x.xxx_hidden_Plugins + } + } + return nil +} + +func (x *ListPluginsResponse) SetPlugins(v []*Plugin) { + x.xxx_hidden_Plugins = &v +} + +type ListPluginsResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Plugins []*Plugin +} + +func (b0 ListPluginsResponse_builder) Build() *ListPluginsResponse { + m0 := &ListPluginsResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Plugins = &b.Plugins + return m0 +} + +type EnablePluginRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name *string `protobuf:"bytes,1,opt,name=name"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EnablePluginRequest) Reset() { + *x = EnablePluginRequest{} + mi := &file_plugins_v1_api_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EnablePluginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EnablePluginRequest) ProtoMessage() {} + +func (x *EnablePluginRequest) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_api_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *EnablePluginRequest) GetName() string { + if x != nil { + if x.xxx_hidden_Name != nil { + return *x.xxx_hidden_Name + } + return "" + } + return "" +} + +func (x *EnablePluginRequest) SetName(v string) { + x.xxx_hidden_Name = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 1) +} + +func (x *EnablePluginRequest) HasName() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *EnablePluginRequest) ClearName() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Name = nil +} + +type EnablePluginRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Name *string +} + +func (b0 EnablePluginRequest_builder) Build() *EnablePluginRequest { + m0 := &EnablePluginRequest{} + b, x := &b0, m0 + _, _ = b, x + if b.Name != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 1) + x.xxx_hidden_Name = b.Name + } + return m0 +} + +type EnablePluginResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EnablePluginResponse) Reset() { + *x = EnablePluginResponse{} + mi := &file_plugins_v1_api_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EnablePluginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EnablePluginResponse) ProtoMessage() {} + +func (x *EnablePluginResponse) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_api_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type EnablePluginResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 EnablePluginResponse_builder) Build() *EnablePluginResponse { + m0 := &EnablePluginResponse{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +type DisablePluginRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name *string `protobuf:"bytes,1,opt,name=name"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DisablePluginRequest) Reset() { + *x = DisablePluginRequest{} + mi := &file_plugins_v1_api_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DisablePluginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DisablePluginRequest) ProtoMessage() {} + +func (x *DisablePluginRequest) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_api_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *DisablePluginRequest) GetName() string { + if x != nil { + if x.xxx_hidden_Name != nil { + return *x.xxx_hidden_Name + } + return "" + } + return "" +} + +func (x *DisablePluginRequest) SetName(v string) { + x.xxx_hidden_Name = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 1) +} + +func (x *DisablePluginRequest) HasName() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *DisablePluginRequest) ClearName() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Name = nil +} + +type DisablePluginRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Name *string +} + +func (b0 DisablePluginRequest_builder) Build() *DisablePluginRequest { + m0 := &DisablePluginRequest{} + b, x := &b0, m0 + _, _ = b, x + if b.Name != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 1) + x.xxx_hidden_Name = b.Name + } + return m0 +} + +type DisablePluginResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DisablePluginResponse) Reset() { + *x = DisablePluginResponse{} + mi := &file_plugins_v1_api_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DisablePluginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DisablePluginResponse) ProtoMessage() {} + +func (x *DisablePluginResponse) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_api_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type DisablePluginResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 DisablePluginResponse_builder) Build() *DisablePluginResponse { + m0 := &DisablePluginResponse{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +var File_plugins_v1_api_proto protoreflect.FileDescriptor + +const file_plugins_v1_api_proto_rawDesc = "" + + "\n" + + "\x14plugins/v1/api.proto\x12\n" + + "plugins.v1\"\xe8\x01\n" + + "\x06Plugin\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + + "\aversion\x18\x02 \x01(\tR\aversion\x12\x1a\n" + + "\bdisabled\x18\x03 \x01(\bR\bdisabled\x12\x1a\n" + + "\bexternal\x18\x04 \x01(\bR\bexternal\x12\"\n" + + "\fconfigurable\x18\x05 \x01(\bR\fconfigurable\x12H\n" + + "\x10secrets_provider\x18\x06 \x01(\v2\x1b.plugins.v1.SecretsProviderH\x00R\x0fsecretsProviderB\n" + + "\n" + + "\bmetadata\"+\n" + + "\x0fSecretsProvider\x12\x18\n" + + "\apattern\x18\x01 \x01(\tR\apattern\"\x14\n" + + "\x12ListPluginsRequest\"C\n" + + "\x13ListPluginsResponse\x12,\n" + + "\aplugins\x18\x01 \x03(\v2\x12.plugins.v1.PluginR\aplugins\")\n" + + "\x13EnablePluginRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\"\x16\n" + + "\x14EnablePluginResponse\"*\n" + + "\x14DisablePluginRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\"\x17\n" + + "\x15DisablePluginResponse2\x92\x02\n" + + "\x17PluginManagementService\x12N\n" + + "\vListPlugins\x12\x1e.plugins.v1.ListPluginsRequest\x1a\x1f.plugins.v1.ListPluginsResponse\x12Q\n" + + "\fEnablePlugin\x12\x1f.plugins.v1.EnablePluginRequest\x1a .plugins.v1.EnablePluginResponse\x12T\n" + + "\rDisablePlugin\x12 .plugins.v1.DisablePluginRequest\x1a!.plugins.v1.DisablePluginResponseB\xa0\x01\n" + + "\x0ecom.plugins.v1B\bApiProtoP\x01Z;github.com/docker/secrets-engine/x/api/plugins/v1;pluginsv1\xa2\x02\x03PXX\xaa\x02\n" + + "Plugins.V1\xca\x02\n" + + "Plugins\\V1\xe2\x02\x16Plugins\\V1\\GPBMetadata\xea\x02\vPlugins::V1b\beditionsp\xe8\a" + +var file_plugins_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_plugins_v1_api_proto_goTypes = []any{ + (*Plugin)(nil), // 0: plugins.v1.Plugin + (*SecretsProvider)(nil), // 1: plugins.v1.SecretsProvider + (*ListPluginsRequest)(nil), // 2: plugins.v1.ListPluginsRequest + (*ListPluginsResponse)(nil), // 3: plugins.v1.ListPluginsResponse + (*EnablePluginRequest)(nil), // 4: plugins.v1.EnablePluginRequest + (*EnablePluginResponse)(nil), // 5: plugins.v1.EnablePluginResponse + (*DisablePluginRequest)(nil), // 6: plugins.v1.DisablePluginRequest + (*DisablePluginResponse)(nil), // 7: plugins.v1.DisablePluginResponse +} +var file_plugins_v1_api_proto_depIdxs = []int32{ + 1, // 0: plugins.v1.Plugin.secrets_provider:type_name -> plugins.v1.SecretsProvider + 0, // 1: plugins.v1.ListPluginsResponse.plugins:type_name -> plugins.v1.Plugin + 2, // 2: plugins.v1.PluginManagementService.ListPlugins:input_type -> plugins.v1.ListPluginsRequest + 4, // 3: plugins.v1.PluginManagementService.EnablePlugin:input_type -> plugins.v1.EnablePluginRequest + 6, // 4: plugins.v1.PluginManagementService.DisablePlugin:input_type -> plugins.v1.DisablePluginRequest + 3, // 5: plugins.v1.PluginManagementService.ListPlugins:output_type -> plugins.v1.ListPluginsResponse + 5, // 6: plugins.v1.PluginManagementService.EnablePlugin:output_type -> plugins.v1.EnablePluginResponse + 7, // 7: plugins.v1.PluginManagementService.DisablePlugin:output_type -> plugins.v1.DisablePluginResponse + 5, // [5:8] is the sub-list for method output_type + 2, // [2:5] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_plugins_v1_api_proto_init() } +func file_plugins_v1_api_proto_init() { + if File_plugins_v1_api_proto != nil { + return + } + file_plugins_v1_api_proto_msgTypes[0].OneofWrappers = []any{ + (*plugin_SecretsProvider)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugins_v1_api_proto_rawDesc), len(file_plugins_v1_api_proto_rawDesc)), + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_plugins_v1_api_proto_goTypes, + DependencyIndexes: file_plugins_v1_api_proto_depIdxs, + MessageInfos: file_plugins_v1_api_proto_msgTypes, + }.Build() + File_plugins_v1_api_proto = out.File + file_plugins_v1_api_proto_goTypes = nil + file_plugins_v1_api_proto_depIdxs = nil +} diff --git a/x/api/plugins/v1/api.proto b/x/api/plugins/v1/api.proto new file mode 100644 index 00000000..3989e1d3 --- /dev/null +++ b/x/api/plugins/v1/api.proto @@ -0,0 +1,70 @@ +// Copyright 2026 Docker, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +edition = "2023"; + +package plugins.v1; + +option go_package = "github.com/docker/secrets-engine/x/api/plugins/v1;pluginsv1"; + + + +service PluginManagementService { + // ListPlugins returns all plugins registered with the engine. + rpc ListPlugins(ListPluginsRequest) returns (ListPluginsResponse); + // EnablePlugin enables a plugin by name. + rpc EnablePlugin(EnablePluginRequest) returns (EnablePluginResponse); + // DisablePlugin disables a plugin by name. + rpc DisablePlugin(DisablePluginRequest) returns (DisablePluginResponse); +} + +message Plugin { + // Name + string name = 1; + // Version + string version = 2; + // Enabled vs disabled + bool disabled = 3; + // External vs builtin + bool external = 4; + // Configurable + bool configurable = 5; + // Type-specific fields + oneof metadata { + SecretsProvider secrets_provider = 6; + } +} + +message SecretsProvider { + // Pattern + string pattern = 1; +} + +message ListPluginsRequest {} + +message ListPluginsResponse { + repeated Plugin plugins = 1; +} + +message EnablePluginRequest { + string name = 1; +} + +message EnablePluginResponse {} + +message DisablePluginRequest { + string name = 1; +} + +message DisablePluginResponse {} diff --git a/x/api/plugins/v1/pluginsv1connect/api.connect.go b/x/api/plugins/v1/pluginsv1connect/api.connect.go new file mode 100644 index 00000000..1367bd23 --- /dev/null +++ b/x/api/plugins/v1/pluginsv1connect/api.connect.go @@ -0,0 +1,174 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: plugins/v1/api.proto + +package pluginsv1connect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + v1 "github.com/docker/secrets-engine/x/api/plugins/v1" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // PluginManagementServiceName is the fully-qualified name of the PluginManagementService service. + PluginManagementServiceName = "plugins.v1.PluginManagementService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // PluginManagementServiceListPluginsProcedure is the fully-qualified name of the + // PluginManagementService's ListPlugins RPC. + PluginManagementServiceListPluginsProcedure = "/plugins.v1.PluginManagementService/ListPlugins" + // PluginManagementServiceEnablePluginProcedure is the fully-qualified name of the + // PluginManagementService's EnablePlugin RPC. + PluginManagementServiceEnablePluginProcedure = "/plugins.v1.PluginManagementService/EnablePlugin" + // PluginManagementServiceDisablePluginProcedure is the fully-qualified name of the + // PluginManagementService's DisablePlugin RPC. + PluginManagementServiceDisablePluginProcedure = "/plugins.v1.PluginManagementService/DisablePlugin" +) + +// PluginManagementServiceClient is a client for the plugins.v1.PluginManagementService service. +type PluginManagementServiceClient interface { + // ListPlugins returns all plugins registered with the engine. + ListPlugins(context.Context, *connect.Request[v1.ListPluginsRequest]) (*connect.Response[v1.ListPluginsResponse], error) + // EnablePlugin enables a plugin by name. + EnablePlugin(context.Context, *connect.Request[v1.EnablePluginRequest]) (*connect.Response[v1.EnablePluginResponse], error) + // DisablePlugin disables a plugin by name. + DisablePlugin(context.Context, *connect.Request[v1.DisablePluginRequest]) (*connect.Response[v1.DisablePluginResponse], error) +} + +// NewPluginManagementServiceClient constructs a client for the plugins.v1.PluginManagementService +// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for +// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply +// the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewPluginManagementServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) PluginManagementServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + pluginManagementServiceMethods := v1.File_plugins_v1_api_proto.Services().ByName("PluginManagementService").Methods() + return &pluginManagementServiceClient{ + listPlugins: connect.NewClient[v1.ListPluginsRequest, v1.ListPluginsResponse]( + httpClient, + baseURL+PluginManagementServiceListPluginsProcedure, + connect.WithSchema(pluginManagementServiceMethods.ByName("ListPlugins")), + connect.WithClientOptions(opts...), + ), + enablePlugin: connect.NewClient[v1.EnablePluginRequest, v1.EnablePluginResponse]( + httpClient, + baseURL+PluginManagementServiceEnablePluginProcedure, + connect.WithSchema(pluginManagementServiceMethods.ByName("EnablePlugin")), + connect.WithClientOptions(opts...), + ), + disablePlugin: connect.NewClient[v1.DisablePluginRequest, v1.DisablePluginResponse]( + httpClient, + baseURL+PluginManagementServiceDisablePluginProcedure, + connect.WithSchema(pluginManagementServiceMethods.ByName("DisablePlugin")), + connect.WithClientOptions(opts...), + ), + } +} + +// pluginManagementServiceClient implements PluginManagementServiceClient. +type pluginManagementServiceClient struct { + listPlugins *connect.Client[v1.ListPluginsRequest, v1.ListPluginsResponse] + enablePlugin *connect.Client[v1.EnablePluginRequest, v1.EnablePluginResponse] + disablePlugin *connect.Client[v1.DisablePluginRequest, v1.DisablePluginResponse] +} + +// ListPlugins calls plugins.v1.PluginManagementService.ListPlugins. +func (c *pluginManagementServiceClient) ListPlugins(ctx context.Context, req *connect.Request[v1.ListPluginsRequest]) (*connect.Response[v1.ListPluginsResponse], error) { + return c.listPlugins.CallUnary(ctx, req) +} + +// EnablePlugin calls plugins.v1.PluginManagementService.EnablePlugin. +func (c *pluginManagementServiceClient) EnablePlugin(ctx context.Context, req *connect.Request[v1.EnablePluginRequest]) (*connect.Response[v1.EnablePluginResponse], error) { + return c.enablePlugin.CallUnary(ctx, req) +} + +// DisablePlugin calls plugins.v1.PluginManagementService.DisablePlugin. +func (c *pluginManagementServiceClient) DisablePlugin(ctx context.Context, req *connect.Request[v1.DisablePluginRequest]) (*connect.Response[v1.DisablePluginResponse], error) { + return c.disablePlugin.CallUnary(ctx, req) +} + +// PluginManagementServiceHandler is an implementation of the plugins.v1.PluginManagementService +// service. +type PluginManagementServiceHandler interface { + // ListPlugins returns all plugins registered with the engine. + ListPlugins(context.Context, *connect.Request[v1.ListPluginsRequest]) (*connect.Response[v1.ListPluginsResponse], error) + // EnablePlugin enables a plugin by name. + EnablePlugin(context.Context, *connect.Request[v1.EnablePluginRequest]) (*connect.Response[v1.EnablePluginResponse], error) + // DisablePlugin disables a plugin by name. + DisablePlugin(context.Context, *connect.Request[v1.DisablePluginRequest]) (*connect.Response[v1.DisablePluginResponse], error) +} + +// NewPluginManagementServiceHandler builds an HTTP handler from the service implementation. It +// returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewPluginManagementServiceHandler(svc PluginManagementServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + pluginManagementServiceMethods := v1.File_plugins_v1_api_proto.Services().ByName("PluginManagementService").Methods() + pluginManagementServiceListPluginsHandler := connect.NewUnaryHandler( + PluginManagementServiceListPluginsProcedure, + svc.ListPlugins, + connect.WithSchema(pluginManagementServiceMethods.ByName("ListPlugins")), + connect.WithHandlerOptions(opts...), + ) + pluginManagementServiceEnablePluginHandler := connect.NewUnaryHandler( + PluginManagementServiceEnablePluginProcedure, + svc.EnablePlugin, + connect.WithSchema(pluginManagementServiceMethods.ByName("EnablePlugin")), + connect.WithHandlerOptions(opts...), + ) + pluginManagementServiceDisablePluginHandler := connect.NewUnaryHandler( + PluginManagementServiceDisablePluginProcedure, + svc.DisablePlugin, + connect.WithSchema(pluginManagementServiceMethods.ByName("DisablePlugin")), + connect.WithHandlerOptions(opts...), + ) + return "/plugins.v1.PluginManagementService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case PluginManagementServiceListPluginsProcedure: + pluginManagementServiceListPluginsHandler.ServeHTTP(w, r) + case PluginManagementServiceEnablePluginProcedure: + pluginManagementServiceEnablePluginHandler.ServeHTTP(w, r) + case PluginManagementServiceDisablePluginProcedure: + pluginManagementServiceDisablePluginHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedPluginManagementServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedPluginManagementServiceHandler struct{} + +func (UnimplementedPluginManagementServiceHandler) ListPlugins(context.Context, *connect.Request[v1.ListPluginsRequest]) (*connect.Response[v1.ListPluginsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("plugins.v1.PluginManagementService.ListPlugins is not implemented")) +} + +func (UnimplementedPluginManagementServiceHandler) EnablePlugin(context.Context, *connect.Request[v1.EnablePluginRequest]) (*connect.Response[v1.EnablePluginResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("plugins.v1.PluginManagementService.EnablePlugin is not implemented")) +} + +func (UnimplementedPluginManagementServiceHandler) DisablePlugin(context.Context, *connect.Request[v1.DisablePluginRequest]) (*connect.Response[v1.DisablePluginResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("plugins.v1.PluginManagementService.DisablePlugin is not implemented")) +} diff --git a/x/api/resolver/v1/api.pb.go b/x/api/resolver/v1/api.pb.go index 7b86618c..37952b80 100644 --- a/x/api/resolver/v1/api.pb.go +++ b/x/api/resolver/v1/api.pb.go @@ -308,317 +308,6 @@ func (b0 RegisterPluginResponse_builder) Build() *RegisterPluginResponse { return m0 } -type Plugin struct { - state protoimpl.MessageState `protogen:"opaque.v1"` - xxx_hidden_Name *string `protobuf:"bytes,1,opt,name=name"` - xxx_hidden_Version *string `protobuf:"bytes,2,opt,name=version"` - xxx_hidden_Pattern *string `protobuf:"bytes,3,opt,name=pattern"` - xxx_hidden_External bool `protobuf:"varint,4,opt,name=external"` - xxx_hidden_Configurable bool `protobuf:"varint,5,opt,name=configurable"` - XXX_raceDetectHookData protoimpl.RaceDetectHookData - XXX_presence [1]uint32 - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Plugin) Reset() { - *x = Plugin{} - mi := &file_resolver_v1_api_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Plugin) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Plugin) ProtoMessage() {} - -func (x *Plugin) ProtoReflect() protoreflect.Message { - mi := &file_resolver_v1_api_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -func (x *Plugin) GetName() string { - if x != nil { - if x.xxx_hidden_Name != nil { - return *x.xxx_hidden_Name - } - return "" - } - return "" -} - -func (x *Plugin) GetVersion() string { - if x != nil { - if x.xxx_hidden_Version != nil { - return *x.xxx_hidden_Version - } - return "" - } - return "" -} - -func (x *Plugin) GetPattern() string { - if x != nil { - if x.xxx_hidden_Pattern != nil { - return *x.xxx_hidden_Pattern - } - return "" - } - return "" -} - -func (x *Plugin) GetExternal() bool { - if x != nil { - return x.xxx_hidden_External - } - return false -} - -func (x *Plugin) GetConfigurable() bool { - if x != nil { - return x.xxx_hidden_Configurable - } - return false -} - -func (x *Plugin) SetName(v string) { - x.xxx_hidden_Name = &v - protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 5) -} - -func (x *Plugin) SetVersion(v string) { - x.xxx_hidden_Version = &v - protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 5) -} - -func (x *Plugin) SetPattern(v string) { - x.xxx_hidden_Pattern = &v - protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 5) -} - -func (x *Plugin) SetExternal(v bool) { - x.xxx_hidden_External = v - protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 5) -} - -func (x *Plugin) SetConfigurable(v bool) { - x.xxx_hidden_Configurable = v - protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 5) -} - -func (x *Plugin) HasName() bool { - if x == nil { - return false - } - return protoimpl.X.Present(&(x.XXX_presence[0]), 0) -} - -func (x *Plugin) HasVersion() bool { - if x == nil { - return false - } - return protoimpl.X.Present(&(x.XXX_presence[0]), 1) -} - -func (x *Plugin) HasPattern() bool { - if x == nil { - return false - } - return protoimpl.X.Present(&(x.XXX_presence[0]), 2) -} - -func (x *Plugin) HasExternal() bool { - if x == nil { - return false - } - return protoimpl.X.Present(&(x.XXX_presence[0]), 3) -} - -func (x *Plugin) HasConfigurable() bool { - if x == nil { - return false - } - return protoimpl.X.Present(&(x.XXX_presence[0]), 4) -} - -func (x *Plugin) ClearName() { - protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) - x.xxx_hidden_Name = nil -} - -func (x *Plugin) ClearVersion() { - protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) - x.xxx_hidden_Version = nil -} - -func (x *Plugin) ClearPattern() { - protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) - x.xxx_hidden_Pattern = nil -} - -func (x *Plugin) ClearExternal() { - protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) - x.xxx_hidden_External = false -} - -func (x *Plugin) ClearConfigurable() { - protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) - x.xxx_hidden_Configurable = false -} - -type Plugin_builder struct { - _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. - - // Name - Name *string - // Version - Version *string - // Pattern - Pattern *string - // External vs builtin - External *bool - // Configurable - Configurable *bool -} - -func (b0 Plugin_builder) Build() *Plugin { - m0 := &Plugin{} - b, x := &b0, m0 - _, _ = b, x - if b.Name != nil { - protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 5) - x.xxx_hidden_Name = b.Name - } - if b.Version != nil { - protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 5) - x.xxx_hidden_Version = b.Version - } - if b.Pattern != nil { - protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 5) - x.xxx_hidden_Pattern = b.Pattern - } - if b.External != nil { - protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 5) - x.xxx_hidden_External = *b.External - } - if b.Configurable != nil { - protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 5) - x.xxx_hidden_Configurable = *b.Configurable - } - return m0 -} - -type ListPluginsRequest struct { - state protoimpl.MessageState `protogen:"opaque.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPluginsRequest) Reset() { - *x = ListPluginsRequest{} - mi := &file_resolver_v1_api_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPluginsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPluginsRequest) ProtoMessage() {} - -func (x *ListPluginsRequest) ProtoReflect() protoreflect.Message { - mi := &file_resolver_v1_api_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -type ListPluginsRequest_builder struct { - _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. - -} - -func (b0 ListPluginsRequest_builder) Build() *ListPluginsRequest { - m0 := &ListPluginsRequest{} - b, x := &b0, m0 - _, _ = b, x - return m0 -} - -type ListPluginsResponse struct { - state protoimpl.MessageState `protogen:"opaque.v1"` - xxx_hidden_Plugins *[]*Plugin `protobuf:"bytes,1,rep,name=plugins"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPluginsResponse) Reset() { - *x = ListPluginsResponse{} - mi := &file_resolver_v1_api_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPluginsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPluginsResponse) ProtoMessage() {} - -func (x *ListPluginsResponse) ProtoReflect() protoreflect.Message { - mi := &file_resolver_v1_api_proto_msgTypes[4] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -func (x *ListPluginsResponse) GetPlugins() []*Plugin { - if x != nil { - if x.xxx_hidden_Plugins != nil { - return *x.xxx_hidden_Plugins - } - } - return nil -} - -func (x *ListPluginsResponse) SetPlugins(v []*Plugin) { - x.xxx_hidden_Plugins = &v -} - -type ListPluginsResponse_builder struct { - _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. - - Plugins []*Plugin -} - -func (b0 ListPluginsResponse_builder) Build() *ListPluginsResponse { - m0 := &ListPluginsResponse{} - b, x := &b0, m0 - _, _ = b, x - x.xxx_hidden_Plugins = &b.Plugins - return m0 -} - type ShutdownRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` unknownFields protoimpl.UnknownFields @@ -627,7 +316,7 @@ type ShutdownRequest struct { func (x *ShutdownRequest) Reset() { *x = ShutdownRequest{} - mi := &file_resolver_v1_api_proto_msgTypes[5] + mi := &file_resolver_v1_api_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -639,7 +328,7 @@ func (x *ShutdownRequest) String() string { func (*ShutdownRequest) ProtoMessage() {} func (x *ShutdownRequest) ProtoReflect() protoreflect.Message { - mi := &file_resolver_v1_api_proto_msgTypes[5] + mi := &file_resolver_v1_api_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -670,7 +359,7 @@ type ShutdownResponse struct { func (x *ShutdownResponse) Reset() { *x = ShutdownResponse{} - mi := &file_resolver_v1_api_proto_msgTypes[6] + mi := &file_resolver_v1_api_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -682,7 +371,7 @@ func (x *ShutdownResponse) String() string { func (*ShutdownResponse) ProtoMessage() {} func (x *ShutdownResponse) ProtoReflect() protoreflect.Message { - mi := &file_resolver_v1_api_proto_msgTypes[6] + mi := &file_resolver_v1_api_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -716,7 +405,7 @@ type GetSecretsRequest struct { func (x *GetSecretsRequest) Reset() { *x = GetSecretsRequest{} - mi := &file_resolver_v1_api_proto_msgTypes[7] + mi := &file_resolver_v1_api_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -728,7 +417,7 @@ func (x *GetSecretsRequest) String() string { func (*GetSecretsRequest) ProtoMessage() {} func (x *GetSecretsRequest) ProtoReflect() protoreflect.Message { - mi := &file_resolver_v1_api_proto_msgTypes[7] + mi := &file_resolver_v1_api_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -793,7 +482,7 @@ type GetSecretsResponse struct { func (x *GetSecretsResponse) Reset() { *x = GetSecretsResponse{} - mi := &file_resolver_v1_api_proto_msgTypes[8] + mi := &file_resolver_v1_api_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -805,7 +494,7 @@ func (x *GetSecretsResponse) String() string { func (*GetSecretsResponse) ProtoMessage() {} func (x *GetSecretsResponse) ProtoReflect() protoreflect.Message { - mi := &file_resolver_v1_api_proto_msgTypes[8] + mi := &file_resolver_v1_api_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -861,7 +550,7 @@ type GetSecretsResponse_Envelope struct { func (x *GetSecretsResponse_Envelope) Reset() { *x = GetSecretsResponse_Envelope{} - mi := &file_resolver_v1_api_proto_msgTypes[9] + mi := &file_resolver_v1_api_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -873,7 +562,7 @@ func (x *GetSecretsResponse_Envelope) String() string { func (*GetSecretsResponse_Envelope) ProtoMessage() {} func (x *GetSecretsResponse_Envelope) ProtoReflect() protoreflect.Message { - mi := &file_resolver_v1_api_proto_msgTypes[9] + mi := &file_resolver_v1_api_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1124,16 +813,7 @@ const file_resolver_v1_api_proto_rawDesc = "" + "\vengine_name\x18\x01 \x01(\tR\n" + "engineName\x12%\n" + "\x0eengine_version\x18\x02 \x01(\tR\rengineVersion\x12B\n" + - "\x0frequest_timeout\x18\x03 \x01(\v2\x19.google.protobuf.DurationR\x0erequestTimeout\"\x90\x01\n" + - "\x06Plugin\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + - "\aversion\x18\x02 \x01(\tR\aversion\x12\x18\n" + - "\apattern\x18\x03 \x01(\tR\apattern\x12\x1a\n" + - "\bexternal\x18\x04 \x01(\bR\bexternal\x12\"\n" + - "\fconfigurable\x18\x05 \x01(\bR\fconfigurable\"\x14\n" + - "\x12ListPluginsRequest\"D\n" + - "\x13ListPluginsResponse\x12-\n" + - "\aplugins\x18\x01 \x03(\v2\x13.resolver.v1.PluginR\aplugins\"\x11\n" + + "\x0frequest_timeout\x18\x03 \x01(\v2\x19.google.protobuf.DurationR\x0erequestTimeout\"\x11\n" + "\x0fShutdownRequest\"\x12\n" + "\x10ShutdownResponse\"-\n" + "\x11GetSecretsRequest\x12\x18\n" + @@ -1156,9 +836,7 @@ const file_resolver_v1_api_proto_rawDesc = "" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x012l\n" + "\x0fRegisterService\x12Y\n" + - "\x0eRegisterPlugin\x12\".resolver.v1.RegisterPluginRequest\x1a#.resolver.v1.RegisterPluginResponse2_\n" + - "\vListService\x12P\n" + - "\vListPlugins\x12\x1f.resolver.v1.ListPluginsRequest\x1a .resolver.v1.ListPluginsResponse2X\n" + + "\x0eRegisterPlugin\x12\".resolver.v1.RegisterPluginRequest\x1a#.resolver.v1.RegisterPluginResponse2X\n" + "\rPluginService\x12G\n" + "\bShutdown\x12\x1c.resolver.v1.ShutdownRequest\x1a\x1d.resolver.v1.ShutdownResponse2`\n" + "\x0fResolverService\x12M\n" + @@ -1166,43 +844,37 @@ const file_resolver_v1_api_proto_rawDesc = "" + "GetSecrets\x12\x1e.resolver.v1.GetSecretsRequest\x1a\x1f.resolver.v1.GetSecretsResponseB\xa7\x01\n" + "\x0fcom.resolver.v1B\bApiProtoP\x01Z=github.com/docker/secrets-engine/x/api/resolver/v1;resolverv1\xa2\x02\x03RXX\xaa\x02\vResolver.V1\xca\x02\vResolver\\V1\xe2\x02\x17Resolver\\V1\\GPBMetadata\xea\x02\fResolver::V1b\beditionsp\xe8\a" -var file_resolver_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_resolver_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_resolver_v1_api_proto_goTypes = []any{ (*RegisterPluginRequest)(nil), // 0: resolver.v1.RegisterPluginRequest (*RegisterPluginResponse)(nil), // 1: resolver.v1.RegisterPluginResponse - (*Plugin)(nil), // 2: resolver.v1.Plugin - (*ListPluginsRequest)(nil), // 3: resolver.v1.ListPluginsRequest - (*ListPluginsResponse)(nil), // 4: resolver.v1.ListPluginsResponse - (*ShutdownRequest)(nil), // 5: resolver.v1.ShutdownRequest - (*ShutdownResponse)(nil), // 6: resolver.v1.ShutdownResponse - (*GetSecretsRequest)(nil), // 7: resolver.v1.GetSecretsRequest - (*GetSecretsResponse)(nil), // 8: resolver.v1.GetSecretsResponse - (*GetSecretsResponse_Envelope)(nil), // 9: resolver.v1.GetSecretsResponse.Envelope - nil, // 10: resolver.v1.GetSecretsResponse.Envelope.MetadataEntry - (*durationpb.Duration)(nil), // 11: google.protobuf.Duration - (*timestamppb.Timestamp)(nil), // 12: google.protobuf.Timestamp + (*ShutdownRequest)(nil), // 2: resolver.v1.ShutdownRequest + (*ShutdownResponse)(nil), // 3: resolver.v1.ShutdownResponse + (*GetSecretsRequest)(nil), // 4: resolver.v1.GetSecretsRequest + (*GetSecretsResponse)(nil), // 5: resolver.v1.GetSecretsResponse + (*GetSecretsResponse_Envelope)(nil), // 6: resolver.v1.GetSecretsResponse.Envelope + nil, // 7: resolver.v1.GetSecretsResponse.Envelope.MetadataEntry + (*durationpb.Duration)(nil), // 8: google.protobuf.Duration + (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp } var file_resolver_v1_api_proto_depIdxs = []int32{ - 11, // 0: resolver.v1.RegisterPluginResponse.request_timeout:type_name -> google.protobuf.Duration - 2, // 1: resolver.v1.ListPluginsResponse.plugins:type_name -> resolver.v1.Plugin - 9, // 2: resolver.v1.GetSecretsResponse.envelopes:type_name -> resolver.v1.GetSecretsResponse.Envelope - 12, // 3: resolver.v1.GetSecretsResponse.Envelope.created_at:type_name -> google.protobuf.Timestamp - 12, // 4: resolver.v1.GetSecretsResponse.Envelope.resolved_at:type_name -> google.protobuf.Timestamp - 12, // 5: resolver.v1.GetSecretsResponse.Envelope.expires_at:type_name -> google.protobuf.Timestamp - 10, // 6: resolver.v1.GetSecretsResponse.Envelope.metadata:type_name -> resolver.v1.GetSecretsResponse.Envelope.MetadataEntry - 0, // 7: resolver.v1.RegisterService.RegisterPlugin:input_type -> resolver.v1.RegisterPluginRequest - 3, // 8: resolver.v1.ListService.ListPlugins:input_type -> resolver.v1.ListPluginsRequest - 5, // 9: resolver.v1.PluginService.Shutdown:input_type -> resolver.v1.ShutdownRequest - 7, // 10: resolver.v1.ResolverService.GetSecrets:input_type -> resolver.v1.GetSecretsRequest - 1, // 11: resolver.v1.RegisterService.RegisterPlugin:output_type -> resolver.v1.RegisterPluginResponse - 4, // 12: resolver.v1.ListService.ListPlugins:output_type -> resolver.v1.ListPluginsResponse - 6, // 13: resolver.v1.PluginService.Shutdown:output_type -> resolver.v1.ShutdownResponse - 8, // 14: resolver.v1.ResolverService.GetSecrets:output_type -> resolver.v1.GetSecretsResponse - 11, // [11:15] is the sub-list for method output_type - 7, // [7:11] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 8, // 0: resolver.v1.RegisterPluginResponse.request_timeout:type_name -> google.protobuf.Duration + 6, // 1: resolver.v1.GetSecretsResponse.envelopes:type_name -> resolver.v1.GetSecretsResponse.Envelope + 9, // 2: resolver.v1.GetSecretsResponse.Envelope.created_at:type_name -> google.protobuf.Timestamp + 9, // 3: resolver.v1.GetSecretsResponse.Envelope.resolved_at:type_name -> google.protobuf.Timestamp + 9, // 4: resolver.v1.GetSecretsResponse.Envelope.expires_at:type_name -> google.protobuf.Timestamp + 7, // 5: resolver.v1.GetSecretsResponse.Envelope.metadata:type_name -> resolver.v1.GetSecretsResponse.Envelope.MetadataEntry + 0, // 6: resolver.v1.RegisterService.RegisterPlugin:input_type -> resolver.v1.RegisterPluginRequest + 2, // 7: resolver.v1.PluginService.Shutdown:input_type -> resolver.v1.ShutdownRequest + 4, // 8: resolver.v1.ResolverService.GetSecrets:input_type -> resolver.v1.GetSecretsRequest + 1, // 9: resolver.v1.RegisterService.RegisterPlugin:output_type -> resolver.v1.RegisterPluginResponse + 3, // 10: resolver.v1.PluginService.Shutdown:output_type -> resolver.v1.ShutdownResponse + 5, // 11: resolver.v1.ResolverService.GetSecrets:output_type -> resolver.v1.GetSecretsResponse + 9, // [9:12] is the sub-list for method output_type + 6, // [6:9] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_resolver_v1_api_proto_init() } @@ -1216,9 +888,9 @@ func file_resolver_v1_api_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_resolver_v1_api_proto_rawDesc), len(file_resolver_v1_api_proto_rawDesc)), NumEnums: 0, - NumMessages: 11, + NumMessages: 8, NumExtensions: 0, - NumServices: 4, + NumServices: 3, }, GoTypes: file_resolver_v1_api_proto_goTypes, DependencyIndexes: file_resolver_v1_api_proto_depIdxs, diff --git a/x/api/resolver/v1/api.proto b/x/api/resolver/v1/api.proto index 68423eeb..bbdfa87e 100644 --- a/x/api/resolver/v1/api.proto +++ b/x/api/resolver/v1/api.proto @@ -44,30 +44,6 @@ message RegisterPluginResponse { google.protobuf.Duration request_timeout = 3; } -service ListService { - // ListPlugins returns all plugins registered with the engine. - rpc ListPlugins(ListPluginsRequest) returns (ListPluginsResponse); -} - -message Plugin { - // Name - string name = 1; - // Version - string version = 2; - // Pattern - string pattern = 3; - // External vs builtin - bool external = 4; - // Configurable - bool configurable = 5; -} - -message ListPluginsRequest {} - -message ListPluginsResponse { - repeated Plugin plugins = 1; -} - service PluginService { // Shutdown a plugin (let it know the runtime is going down). rpc Shutdown(ShutdownRequest) returns (ShutdownResponse); diff --git a/x/api/resolver/v1/resolverv1connect/api.connect.go b/x/api/resolver/v1/resolverv1connect/api.connect.go index aed1b38a..ee1c977a 100644 --- a/x/api/resolver/v1/resolverv1connect/api.connect.go +++ b/x/api/resolver/v1/resolverv1connect/api.connect.go @@ -23,8 +23,6 @@ const _ = connect.IsAtLeastVersion1_13_0 const ( // RegisterServiceName is the fully-qualified name of the RegisterService service. RegisterServiceName = "resolver.v1.RegisterService" - // ListServiceName is the fully-qualified name of the ListService service. - ListServiceName = "resolver.v1.ListService" // PluginServiceName is the fully-qualified name of the PluginService service. PluginServiceName = "resolver.v1.PluginService" // ResolverServiceName is the fully-qualified name of the ResolverService service. @@ -42,8 +40,6 @@ const ( // RegisterServiceRegisterPluginProcedure is the fully-qualified name of the RegisterService's // RegisterPlugin RPC. RegisterServiceRegisterPluginProcedure = "/resolver.v1.RegisterService/RegisterPlugin" - // ListServiceListPluginsProcedure is the fully-qualified name of the ListService's ListPlugins RPC. - ListServiceListPluginsProcedure = "/resolver.v1.ListService/ListPlugins" // PluginServiceShutdownProcedure is the fully-qualified name of the PluginService's Shutdown RPC. PluginServiceShutdownProcedure = "/resolver.v1.PluginService/Shutdown" // ResolverServiceGetSecretsProcedure is the fully-qualified name of the ResolverService's @@ -123,78 +119,6 @@ func (UnimplementedRegisterServiceHandler) RegisterPlugin(context.Context, *conn return nil, connect.NewError(connect.CodeUnimplemented, errors.New("resolver.v1.RegisterService.RegisterPlugin is not implemented")) } -// ListServiceClient is a client for the resolver.v1.ListService service. -type ListServiceClient interface { - // ListPlugins returns all plugins registered with the engine. - ListPlugins(context.Context, *connect.Request[v1.ListPluginsRequest]) (*connect.Response[v1.ListPluginsResponse], error) -} - -// NewListServiceClient constructs a client for the resolver.v1.ListService service. By default, it -// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends -// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or -// connect.WithGRPCWeb() options. -// -// The URL supplied here should be the base URL for the Connect or gRPC server (for example, -// http://api.acme.com or https://acme.com/grpc). -func NewListServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ListServiceClient { - baseURL = strings.TrimRight(baseURL, "/") - listServiceMethods := v1.File_resolver_v1_api_proto.Services().ByName("ListService").Methods() - return &listServiceClient{ - listPlugins: connect.NewClient[v1.ListPluginsRequest, v1.ListPluginsResponse]( - httpClient, - baseURL+ListServiceListPluginsProcedure, - connect.WithSchema(listServiceMethods.ByName("ListPlugins")), - connect.WithClientOptions(opts...), - ), - } -} - -// listServiceClient implements ListServiceClient. -type listServiceClient struct { - listPlugins *connect.Client[v1.ListPluginsRequest, v1.ListPluginsResponse] -} - -// ListPlugins calls resolver.v1.ListService.ListPlugins. -func (c *listServiceClient) ListPlugins(ctx context.Context, req *connect.Request[v1.ListPluginsRequest]) (*connect.Response[v1.ListPluginsResponse], error) { - return c.listPlugins.CallUnary(ctx, req) -} - -// ListServiceHandler is an implementation of the resolver.v1.ListService service. -type ListServiceHandler interface { - // ListPlugins returns all plugins registered with the engine. - ListPlugins(context.Context, *connect.Request[v1.ListPluginsRequest]) (*connect.Response[v1.ListPluginsResponse], error) -} - -// NewListServiceHandler builds an HTTP handler from the service implementation. It returns the path -// on which to mount the handler and the handler itself. -// -// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf -// and JSON codecs. They also support gzip compression. -func NewListServiceHandler(svc ListServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { - listServiceMethods := v1.File_resolver_v1_api_proto.Services().ByName("ListService").Methods() - listServiceListPluginsHandler := connect.NewUnaryHandler( - ListServiceListPluginsProcedure, - svc.ListPlugins, - connect.WithSchema(listServiceMethods.ByName("ListPlugins")), - connect.WithHandlerOptions(opts...), - ) - return "/resolver.v1.ListService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case ListServiceListPluginsProcedure: - listServiceListPluginsHandler.ServeHTTP(w, r) - default: - http.NotFound(w, r) - } - }) -} - -// UnimplementedListServiceHandler returns CodeUnimplemented from all methods. -type UnimplementedListServiceHandler struct{} - -func (UnimplementedListServiceHandler) ListPlugins(context.Context, *connect.Request[v1.ListPluginsRequest]) (*connect.Response[v1.ListPluginsResponse], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("resolver.v1.ListService.ListPlugins is not implemented")) -} - // PluginServiceClient is a client for the resolver.v1.PluginService service. type PluginServiceClient interface { // Shutdown a plugin (let it know the runtime is going down).