secret

package
v0.0.0-...-f4276bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 12 Imported by: 0

README

云商同步的账号凭证管理

Documentation

Index

Constants

View Source
const (
	Rpc_CreateSecret_FullMethodName   = "/go11.devcloud_mini.cmdb.secret.Rpc/CreateSecret"
	Rpc_QuerySecret_FullMethodName    = "/go11.devcloud_mini.cmdb.secret.Rpc/QuerySecret"
	Rpc_DescribeSecret_FullMethodName = "/go11.devcloud_mini.cmdb.secret.Rpc/DescribeSecret"
	Rpc_SyncResource_FullMethodName   = "/go11.devcloud_mini.cmdb.secret.Rpc/SyncResource"
)
View Source
const AppName = "secrets"

Variables

View Source
var File_cmdb_apps_secret_pb_model_proto protoreflect.FileDescriptor
View Source
var File_cmdb_apps_secret_pb_rpc_proto protoreflect.FileDescriptor
View Source
var Rpc_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "go11.devcloud_mini.cmdb.secret.Rpc",
	HandlerType: (*RpcServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateSecret",
			Handler:    _Rpc_CreateSecret_Handler,
		},
		{
			MethodName: "QuerySecret",
			Handler:    _Rpc_QuerySecret_Handler,
		},
		{
			MethodName: "DescribeSecret",
			Handler:    _Rpc_DescribeSecret_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "SyncResource",
			Handler:       _Rpc_SyncResource_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "cmdb/apps/secret/pb/rpc.proto",
}

Rpc_ServiceDesc is the grpc.ServiceDesc for Rpc service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterRpcServer

func RegisterRpcServer(s grpc.ServiceRegistrar, srv RpcServer)

Types

type DescribeSecretRequest

type DescribeSecretRequest struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*DescribeSecretRequest) Descriptor deprecated

func (*DescribeSecretRequest) Descriptor() ([]byte, []int)

Deprecated: Use DescribeSecretRequest.ProtoReflect.Descriptor instead.

func (*DescribeSecretRequest) GetId

func (x *DescribeSecretRequest) GetId() string

func (*DescribeSecretRequest) ProtoMessage

func (*DescribeSecretRequest) ProtoMessage()

func (*DescribeSecretRequest) ProtoReflect

func (x *DescribeSecretRequest) ProtoReflect() protoreflect.Message

func (*DescribeSecretRequest) Reset

func (x *DescribeSecretRequest) Reset()

func (*DescribeSecretRequest) String

func (x *DescribeSecretRequest) String() string

type QuerySecretRequest

type QuerySecretRequest struct {
	// contains filtered or unexported fields
}

func (*QuerySecretRequest) Descriptor deprecated

func (*QuerySecretRequest) Descriptor() ([]byte, []int)

Deprecated: Use QuerySecretRequest.ProtoReflect.Descriptor instead.

func (*QuerySecretRequest) ProtoMessage

func (*QuerySecretRequest) ProtoMessage()

func (*QuerySecretRequest) ProtoReflect

func (x *QuerySecretRequest) ProtoReflect() protoreflect.Message

func (*QuerySecretRequest) Reset

func (x *QuerySecretRequest) Reset()

func (*QuerySecretRequest) String

func (x *QuerySecretRequest) String() string

type RpcClient

type RpcClient interface {
	// 创建同步凭证
	CreateSecret(ctx context.Context, in *Spec, opts ...grpc.CallOption) (*Secret, error)
	// 查询同步凭证,查询列表时候,不要把key查出来
	QuerySecret(ctx context.Context, in *QuerySecretRequest, opts ...grpc.CallOption) (*SecretSet, error)
	// 查询凭证详情
	DescribeSecret(ctx context.Context, in *DescribeSecretRequest, opts ...grpc.CallOption) (*Secret, error)
	// 流式接口, 便同步边返回
	// host 01 已经同步
	// host 02 已经同步 。。。
	SyncResource(ctx context.Context, in *SyncResourceRequest, opts ...grpc.CallOption) (Rpc_SyncResourceClient, error)
}

RpcClient is the client API for Rpc 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.

func NewRpcClient

func NewRpcClient(cc grpc.ClientConnInterface) RpcClient

type RpcServer

type RpcServer interface {
	// 创建同步凭证
	CreateSecret(context.Context, *Spec) (*Secret, error)
	// 查询同步凭证,查询列表时候,不要把key查出来
	QuerySecret(context.Context, *QuerySecretRequest) (*SecretSet, error)
	// 查询凭证详情
	DescribeSecret(context.Context, *DescribeSecretRequest) (*Secret, error)
	// 流式接口, 便同步边返回
	// host 01 已经同步
	// host 02 已经同步 。。。
	SyncResource(*SyncResourceRequest, Rpc_SyncResourceServer) error
	// contains filtered or unexported methods
}

RpcServer is the server API for Rpc service. All implementations must embed UnimplementedRpcServer for forward compatibility

type Rpc_SyncResourceClient

type Rpc_SyncResourceClient interface {
	Recv() (*SyncResourceResponse, error)
	grpc.ClientStream
}

type Rpc_SyncResourceServer

type Rpc_SyncResourceServer interface {
	Send(*SyncResourceResponse) error
	grpc.ServerStream
}

type Secret

type Secret struct {

	// 元数据信息
	// @gotags: json:"meta" bson:",inline"
	Meta *resource.Meta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta" bson:",inline"`
	// 资源的定义
	// @gotags: json:"spec" bson:",inline"
	Spec *Spec `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec" bson:",inline"`
	// contains filtered or unexported fields
}

func NewSecret

func NewSecret(spec *Spec) (*Secret, error)

需要对明文数据进行加密处理

func (*Secret) Descriptor deprecated

func (*Secret) Descriptor() ([]byte, []int)

Deprecated: Use Secret.ProtoReflect.Descriptor instead.

func (*Secret) GetMeta

func (x *Secret) GetMeta() *resource.Meta

func (*Secret) GetSpec

func (x *Secret) GetSpec() *Spec

func (*Secret) ProtoMessage

func (*Secret) ProtoMessage()

func (*Secret) ProtoReflect

func (x *Secret) ProtoReflect() protoreflect.Message

func (*Secret) Reset

func (x *Secret) Reset()

func (*Secret) String

func (x *Secret) String() string

type SecretSet

type SecretSet struct {

	// 总数
	// @gotags: json:"total" bson:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total" bson:"total"`
	// 清单
	// @gotags: json:"items" bson:"items"
	Items []*Secret `protobuf:"bytes,2,rep,name=items,proto3" json:"items" bson:"items"`
	// contains filtered or unexported fields
}

func (*SecretSet) Descriptor deprecated

func (*SecretSet) Descriptor() ([]byte, []int)

Deprecated: Use SecretSet.ProtoReflect.Descriptor instead.

func (*SecretSet) GetItems

func (x *SecretSet) GetItems() []*Secret

func (*SecretSet) GetTotal

func (x *SecretSet) GetTotal() int64

func (*SecretSet) ProtoMessage

func (*SecretSet) ProtoMessage()

func (*SecretSet) ProtoReflect

func (x *SecretSet) ProtoReflect() protoreflect.Message

func (*SecretSet) Reset

func (x *SecretSet) Reset()

func (*SecretSet) String

func (x *SecretSet) String() string

type Service

type Service interface {
	RpcServer
}

type Spec

type Spec struct {

	// 是否启用, 不启用的 就不能进行资源同步
	// @gotags: json:"enabled" bson:"enabled"
	Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled" bson:"enabled"`
	// 资源的提供方
	// @gotags: json:"provider" bson:"provider"
	Provider resource1.PROVIDER `protobuf:"varint,4,opt,name=provider,proto3,enum=go11.devcloud_mini.cmdb.resource.PROVIDER" json:"provider" bson:"provider"`
	// tenxcent: SecretId
	// @gotags: json:"api_key" bson:"api_key"
	ApiKey string `protobuf:"bytes,1,opt,name=api_key,json=apiKey,proto3" json:"api_key" bson:"api_key"`
	// tenxcent: SecretKey
	// @gotags: json:"api_secret" bson:"api_secret"
	ApiSecret string `protobuf:"bytes,2,opt,name=api_secret,json=apiSecret,proto3" json:"api_secret" bson:"api_secret"`
	// 该账号 在哪些地域(Region)上资源,这个是运维或者业务提前规划, 杭州, 北京, 上海
	// @gotags: json:"resource_regions" bson:"resource_regions"
	ResourceRegions []string `protobuf:"bytes,5,rep,name=resource_regions,json=resourceRegions,proto3" json:"resource_regions" bson:"resource_regions"`
	// contains filtered or unexported fields
}

func (*Spec) Decrypt

func (s *Spec) Decrypt() error

解密

func (*Spec) Descriptor deprecated

func (*Spec) Descriptor() ([]byte, []int)

Deprecated: Use Spec.ProtoReflect.Descriptor instead.

func (*Spec) Encrypt

func (s *Spec) Encrypt() error

加密, 我们使用对称加解密(key): CBC(iv向量, 同一个密码,多次加密 获取的密文不一样) 非对称 需要一对密钥对: 私钥和公钥

func (*Spec) GetApiKey

func (x *Spec) GetApiKey() string

func (*Spec) GetApiSecret

func (x *Spec) GetApiSecret() string

func (*Spec) GetEnabled

func (x *Spec) GetEnabled() bool

func (*Spec) GetProvider

func (x *Spec) GetProvider() resource1.PROVIDER

func (*Spec) GetResourceRegions

func (x *Spec) GetResourceRegions() []string

func (*Spec) ProtoMessage

func (*Spec) ProtoMessage()

func (*Spec) ProtoReflect

func (x *Spec) ProtoReflect() protoreflect.Message

func (*Spec) Reset

func (x *Spec) Reset()

func (*Spec) String

func (x *Spec) String() string

type SyncResourceRequest

type SyncResourceRequest struct {
	SecretId string `protobuf:"bytes,1,opt,name=secret_id,json=secretId,proto3" json:"secret_id,omitempty"`
	// contains filtered or unexported fields
}

func (*SyncResourceRequest) Descriptor deprecated

func (*SyncResourceRequest) Descriptor() ([]byte, []int)

Deprecated: Use SyncResourceRequest.ProtoReflect.Descriptor instead.

func (*SyncResourceRequest) GetSecretId

func (x *SyncResourceRequest) GetSecretId() string

func (*SyncResourceRequest) ProtoMessage

func (*SyncResourceRequest) ProtoMessage()

func (*SyncResourceRequest) ProtoReflect

func (x *SyncResourceRequest) ProtoReflect() protoreflect.Message

func (*SyncResourceRequest) Reset

func (x *SyncResourceRequest) Reset()

func (*SyncResourceRequest) String

func (x *SyncResourceRequest) String() string

type SyncResourceResponse

type SyncResourceResponse struct {

	// 资源Id
	// @gotags: json:"resource_id" bson:"resource_id"
	ResourceId string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id" bson:"resource_id"`
	// 是否同步成功
	// @gotags: json:"successed" bson:"successed"
	Successed bool `protobuf:"varint,2,opt,name=successed,proto3" json:"successed" bson:"successed"`
	// 同步失败的原因
	// @gotags: json:"message" bson:"message"
	Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message" bson:"message"`
	// contains filtered or unexported fields
}

func (*SyncResourceResponse) Descriptor deprecated

func (*SyncResourceResponse) Descriptor() ([]byte, []int)

Deprecated: Use SyncResourceResponse.ProtoReflect.Descriptor instead.

func (*SyncResourceResponse) GetMessage

func (x *SyncResourceResponse) GetMessage() string

func (*SyncResourceResponse) GetResourceId

func (x *SyncResourceResponse) GetResourceId() string

func (*SyncResourceResponse) GetSuccessed

func (x *SyncResourceResponse) GetSuccessed() bool

func (*SyncResourceResponse) ProtoMessage

func (*SyncResourceResponse) ProtoMessage()

func (*SyncResourceResponse) ProtoReflect

func (x *SyncResourceResponse) ProtoReflect() protoreflect.Message

func (*SyncResourceResponse) Reset

func (x *SyncResourceResponse) Reset()

func (*SyncResourceResponse) String

func (x *SyncResourceResponse) String() string

type UnimplementedRpcServer

type UnimplementedRpcServer struct {
}

UnimplementedRpcServer must be embedded to have forward compatible implementations.

func (UnimplementedRpcServer) CreateSecret

func (UnimplementedRpcServer) CreateSecret(context.Context, *Spec) (*Secret, error)

func (UnimplementedRpcServer) DescribeSecret

func (UnimplementedRpcServer) QuerySecret

func (UnimplementedRpcServer) SyncResource

type UnsafeRpcServer

type UnsafeRpcServer interface {
	// contains filtered or unexported methods
}

UnsafeRpcServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RpcServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL