secret

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP_NAME   = "secret"
	SECRET_KEY = "23gs6gxHrz1kNEvshRmunkXbwIiaEcYfh+EMu+e9ewA="
)
View Source
const (
	SYNCER_PREFIX = "syncer"
)
View Source
const (
	TASK_LABLE_SECRET_ID = "secret_id"
)

Variables

This section is empty.

Functions

func GetSyncerName

func GetSyncerName(t resource.TYPE) string

func NewSecretSet

func NewSecretSet() *types.Set[*Secret]

func RegistrySyncer

func RegistrySyncer(t resource.TYPE, s Syncer)

Types

type CreateSecretRequest

type CreateSecretRequest struct {
	// 是否启用
	Enabled *bool `json:"enabled" gorm:"column:enabled"`
	// 名称
	Name string `json:"name" gorm:"column:name"`
	// 尝试
	Vendor resource.VENDOR `json:"vendor" gorm:"column:vendor"`
	// Vmware
	Address string `json:"address" gorm:"column:address"`
	// 需要被脱敏
	// Musk
	ApiKey string `json:"api_key" gorm:"column:api_key"`
	// ApiKey
	ApiSecret string `json:"api_secret" mask:",5,4" gorm:"column:api_secret"`
	// 资源所在区域
	Regions []string `json:"regions" gorm:"column:regions;serializer:json;type:json"`
	// 资源列表
	ResourceType []resource.TYPE `json:"resource_type" gorm:"column:resource_type;serializer:json;type:json"`
	// 同步分页大小
	SyncLimit int64 `json:"sync_limit" gorm:"column:sync_limit"`
	// contains filtered or unexported fields
}

func NewCreateSecretRequest

func NewCreateSecretRequest() *CreateSecretRequest

func (*CreateSecretRequest) DecryptedApiSecret

func (r *CreateSecretRequest) DecryptedApiSecret() error

func (*CreateSecretRequest) EncryptedApiSecret

func (r *CreateSecretRequest) EncryptedApiSecret() error

func (*CreateSecretRequest) GetEnabled

func (r *CreateSecretRequest) GetEnabled() bool

func (*CreateSecretRequest) GetSyncLimit

func (r *CreateSecretRequest) GetSyncLimit() int64

func (*CreateSecretRequest) SetEnabled

func (r *CreateSecretRequest) SetEnabled(v bool) *CreateSecretRequest

func (*CreateSecretRequest) SetIsEncrypted

func (r *CreateSecretRequest) SetIsEncrypted(v bool) *CreateSecretRequest

type DescribeSecretRequest

type DescribeSecretRequest struct {
	policy.ResourceScope
	Id string `json:"id"`
}

func NewDescribeSecretRequest

func NewDescribeSecretRequest(id string) *DescribeSecretRequest

type QuerySecretRequest

type QuerySecretRequest struct {
	policy.ResourceScope
	// 分页请求
	*request.PageRequest
}

func NewQuerySecretRequest

func NewQuerySecretRequest() *QuerySecretRequest

type QuerySyncLogRequest

type QuerySyncLogRequest struct {
	TaskId int `json:"task_id"`
}

type ResourceResponse

type ResourceResponse struct {
	Success    bool
	InstanceId string             `json:"instance_id"`
	Resource   *resource.Resource `json:"resource"`
	Message    string             `json:"message"`
}

func (ResourceResponse) String

func (t ResourceResponse) String() string

type Secret

type Secret struct {
	model.Meta
	CreateSecretRequest `bson:"inline"`
}

func NewSecret

func NewSecret(in *CreateSecretRequest) *Secret

func (*Secret) SetDefault

func (s *Secret) SetDefault() *Secret

func (*Secret) String

func (s *Secret) String() string

func (*Secret) TableName

func (s *Secret) TableName() string

type Service

type Service interface {
	// 用于Secret的管理(后台管理员配置)
	// 创建secret
	CreateSecret(context.Context, *CreateSecretRequest) (*Secret, error)
	// 查询secret
	QuerySecret(context.Context, *QuerySecretRequest) (*types.Set[*Secret], error)
	// 查询详情, 已解密, API层需要脱敏
	DescribeSecret(context.Context, *DescribeSecretRequest) (*Secret, error)

	// 使用task模块来执行异步任务, 通过TaskId查询异步任务状态
	SyncResource(context.Context, *SyncResourceRequest) (*types.Set[*task.Task], error)
}

func GetService

func GetService() Service

type SyncRecord

type SyncRecord struct {
}

每个资源的同步日志

type SyncResourceHandleFunc

type SyncResourceHandleFunc func(ResourceResponse)

type SyncResourceRequest

type SyncResourceRequest struct {
	Id string `json:"id"`
}

func NewSyncResourceRequest

func NewSyncResourceRequest(id string) *SyncResourceRequest

type SyncResourceTask

type SyncResourceTask struct {
}

同步记录(task) 有状态

type Syncer

type Syncer interface {
	// 资源同步
	Sync(ctx context.Context, ins *Secret, region string, rt resource.TYPE) *task.Task
}

func GetSyncer

func GetSyncer(t resource.TYPE) Syncer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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