mirror of
https://github.com/openziti/zrok.git
synced 2025-06-26 12:42:18 +02:00
roughed in gprc service for secrets retrieval (#968)
This commit is contained in:
parent
210dc120d1
commit
6cf5c28f90
11
bin/generate_secrets_pb.sh
Executable file
11
bin/generate_secrets_pb.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
go install \
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
|
||||
google.golang.org/protobuf/cmd/protoc-gen-go \
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
||||
|
||||
protoc --go_out=. --go_opt=paths=source_relative \
|
||||
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
||||
controller/secretsGrpc/secrets.proto
|
||||
|
232
controller/secretsGrpc/secrets.pb.go
Normal file
232
controller/secretsGrpc/secrets.pb.go
Normal file
@ -0,0 +1,232 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.6
|
||||
// protoc v6.31.1
|
||||
// source: controller/secretsGrpc/secrets.proto
|
||||
|
||||
package secretsGrpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
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 Secret struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Secret) Reset() {
|
||||
*x = Secret{}
|
||||
mi := &file_controller_secretsGrpc_secrets_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Secret) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Secret) ProtoMessage() {}
|
||||
|
||||
func (x *Secret) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_controller_secretsGrpc_secrets_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)
|
||||
}
|
||||
|
||||
// Deprecated: Use Secret.ProtoReflect.Descriptor instead.
|
||||
func (*Secret) Descriptor() ([]byte, []int) {
|
||||
return file_controller_secretsGrpc_secrets_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Secret) GetKey() string {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Secret) GetValue() string {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SecretsRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ShareToken string `protobuf:"bytes,1,opt,name=shareToken,proto3" json:"shareToken,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SecretsRequest) Reset() {
|
||||
*x = SecretsRequest{}
|
||||
mi := &file_controller_secretsGrpc_secrets_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SecretsRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SecretsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SecretsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_controller_secretsGrpc_secrets_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)
|
||||
}
|
||||
|
||||
// Deprecated: Use SecretsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SecretsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_controller_secretsGrpc_secrets_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *SecretsRequest) GetShareToken() string {
|
||||
if x != nil {
|
||||
return x.ShareToken
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SecretsResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Secrets []*Secret `protobuf:"bytes,1,rep,name=secrets,proto3" json:"secrets,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SecretsResponse) Reset() {
|
||||
*x = SecretsResponse{}
|
||||
mi := &file_controller_secretsGrpc_secrets_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SecretsResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SecretsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *SecretsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_controller_secretsGrpc_secrets_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)
|
||||
}
|
||||
|
||||
// Deprecated: Use SecretsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*SecretsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_controller_secretsGrpc_secrets_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *SecretsResponse) GetSecrets() []*Secret {
|
||||
if x != nil {
|
||||
return x.Secrets
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_controller_secretsGrpc_secrets_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_controller_secretsGrpc_secrets_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"$controller/secretsGrpc/secrets.proto\"0\n" +
|
||||
"\x06Secret\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
|
||||
"\x05value\x18\x02 \x01(\tR\x05value\"0\n" +
|
||||
"\x0eSecretsRequest\x12\x1e\n" +
|
||||
"\n" +
|
||||
"shareToken\x18\x01 \x01(\tR\n" +
|
||||
"shareToken\"4\n" +
|
||||
"\x0fSecretsResponse\x12!\n" +
|
||||
"\asecrets\x18\x01 \x03(\v2\a.SecretR\asecrets2>\n" +
|
||||
"\aSecrets\x123\n" +
|
||||
"\fFetchSecrets\x12\x0f.SecretsRequest\x1a\x10.SecretsResponse\"\x00B1Z/github.com/openziti/zrok/controller/secretsGrpcb\x06proto3"
|
||||
|
||||
var (
|
||||
file_controller_secretsGrpc_secrets_proto_rawDescOnce sync.Once
|
||||
file_controller_secretsGrpc_secrets_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_controller_secretsGrpc_secrets_proto_rawDescGZIP() []byte {
|
||||
file_controller_secretsGrpc_secrets_proto_rawDescOnce.Do(func() {
|
||||
file_controller_secretsGrpc_secrets_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_controller_secretsGrpc_secrets_proto_rawDesc), len(file_controller_secretsGrpc_secrets_proto_rawDesc)))
|
||||
})
|
||||
return file_controller_secretsGrpc_secrets_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_controller_secretsGrpc_secrets_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_controller_secretsGrpc_secrets_proto_goTypes = []any{
|
||||
(*Secret)(nil), // 0: Secret
|
||||
(*SecretsRequest)(nil), // 1: SecretsRequest
|
||||
(*SecretsResponse)(nil), // 2: SecretsResponse
|
||||
}
|
||||
var file_controller_secretsGrpc_secrets_proto_depIdxs = []int32{
|
||||
0, // 0: SecretsResponse.secrets:type_name -> Secret
|
||||
1, // 1: Secrets.FetchSecrets:input_type -> SecretsRequest
|
||||
2, // 2: Secrets.FetchSecrets:output_type -> SecretsResponse
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_controller_secretsGrpc_secrets_proto_init() }
|
||||
func file_controller_secretsGrpc_secrets_proto_init() {
|
||||
if File_controller_secretsGrpc_secrets_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_controller_secretsGrpc_secrets_proto_rawDesc), len(file_controller_secretsGrpc_secrets_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_controller_secretsGrpc_secrets_proto_goTypes,
|
||||
DependencyIndexes: file_controller_secretsGrpc_secrets_proto_depIdxs,
|
||||
MessageInfos: file_controller_secretsGrpc_secrets_proto_msgTypes,
|
||||
}.Build()
|
||||
File_controller_secretsGrpc_secrets_proto = out.File
|
||||
file_controller_secretsGrpc_secrets_proto_goTypes = nil
|
||||
file_controller_secretsGrpc_secrets_proto_depIdxs = nil
|
||||
}
|
20
controller/secretsGrpc/secrets.proto
Normal file
20
controller/secretsGrpc/secrets.proto
Normal file
@ -0,0 +1,20 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "github.com/openziti/zrok/controller/secretsGrpc";
|
||||
|
||||
service Secrets {
|
||||
rpc FetchSecrets(SecretsRequest) returns (SecretsResponse) {}
|
||||
}
|
||||
|
||||
message Secret {
|
||||
string key = 1;
|
||||
string value = 2;
|
||||
}
|
||||
|
||||
message SecretsRequest {
|
||||
string shareToken = 1;
|
||||
}
|
||||
|
||||
message SecretsResponse {
|
||||
repeated Secret secrets = 1;
|
||||
}
|
121
controller/secretsGrpc/secrets_grpc.pb.go
Normal file
121
controller/secretsGrpc/secrets_grpc.pb.go
Normal file
@ -0,0 +1,121 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v6.31.1
|
||||
// source: controller/secretsGrpc/secrets.proto
|
||||
|
||||
package secretsGrpc
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// 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.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Secrets_FetchSecrets_FullMethodName = "/Secrets/FetchSecrets"
|
||||
)
|
||||
|
||||
// SecretsClient is the client API for Secrets 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.
|
||||
type SecretsClient interface {
|
||||
FetchSecrets(ctx context.Context, in *SecretsRequest, opts ...grpc.CallOption) (*SecretsResponse, error)
|
||||
}
|
||||
|
||||
type secretsClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewSecretsClient(cc grpc.ClientConnInterface) SecretsClient {
|
||||
return &secretsClient{cc}
|
||||
}
|
||||
|
||||
func (c *secretsClient) FetchSecrets(ctx context.Context, in *SecretsRequest, opts ...grpc.CallOption) (*SecretsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SecretsResponse)
|
||||
err := c.cc.Invoke(ctx, Secrets_FetchSecrets_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SecretsServer is the server API for Secrets service.
|
||||
// All implementations must embed UnimplementedSecretsServer
|
||||
// for forward compatibility.
|
||||
type SecretsServer interface {
|
||||
FetchSecrets(context.Context, *SecretsRequest) (*SecretsResponse, error)
|
||||
mustEmbedUnimplementedSecretsServer()
|
||||
}
|
||||
|
||||
// UnimplementedSecretsServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedSecretsServer struct{}
|
||||
|
||||
func (UnimplementedSecretsServer) FetchSecrets(context.Context, *SecretsRequest) (*SecretsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FetchSecrets not implemented")
|
||||
}
|
||||
func (UnimplementedSecretsServer) mustEmbedUnimplementedSecretsServer() {}
|
||||
func (UnimplementedSecretsServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeSecretsServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to SecretsServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeSecretsServer interface {
|
||||
mustEmbedUnimplementedSecretsServer()
|
||||
}
|
||||
|
||||
func RegisterSecretsServer(s grpc.ServiceRegistrar, srv SecretsServer) {
|
||||
// If the following call pancis, it indicates UnimplementedSecretsServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Secrets_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Secrets_FetchSecrets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SecretsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SecretsServer).FetchSecrets(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Secrets_FetchSecrets_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SecretsServer).FetchSecrets(ctx, req.(*SecretsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Secrets_ServiceDesc is the grpc.ServiceDesc for Secrets service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Secrets_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "Secrets",
|
||||
HandlerType: (*SecretsServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "FetchSecrets",
|
||||
Handler: _Secrets_FetchSecrets_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "controller/secretsGrpc/secrets.proto",
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user