db

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultOperationsForKV        = pb.PipelineCmsConfigOperations{CanDownload: false, CanEdit: true, CanDelete: true}
	DefaultOperationsForDiceFiles = pb.PipelineCmsConfigOperations{CanDownload: true, CanEdit: true, CanDelete: true}
)
View Source
var (
	ConfigTypeKV       = "kv"
	ConfigTypeDiceFile = "dice-file"
)

Functions

This section is empty.

Types

type Client

type Client struct {
	mysqlxorm.Interface
}

func (*Client) DeleteCmsNsConfigs

func (client *Client) DeleteCmsNsConfigs(cmsNs PipelineCmsNs, keys []string, ops ...mysqlxorm.SessionOption) error

func (*Client) GetCmsNs

func (client *Client) GetCmsNs(pipelineSource apistructs.PipelineSource, ns string, ops ...mysqlxorm.SessionOption) (PipelineCmsNs, bool, error)

func (*Client) GetCmsNsConfigs

func (client *Client) GetCmsNsConfigs(cmsNs PipelineCmsNs, keys []string, ops ...mysqlxorm.SessionOption) ([]PipelineCmsConfig, error)

func (*Client) IdempotentCreateCmsNs

func (client *Client) IdempotentCreateCmsNs(pipelineSource apistructs.PipelineSource, ns string, ops ...mysqlxorm.SessionOption) (PipelineCmsNs, error)

func (*Client) IdempotentDeleteCmsNs

func (client *Client) IdempotentDeleteCmsNs(pipelineSource apistructs.PipelineSource, ns string, ops ...mysqlxorm.SessionOption) error

func (*Client) InsertOrUpdateCmsNsConfig

func (client *Client) InsertOrUpdateCmsNsConfig(cmsNs PipelineCmsNs, config PipelineCmsConfig, ops ...mysqlxorm.SessionOption) error

func (*Client) PrefixListNs

func (client *Client) PrefixListNs(pipelineSource apistructs.PipelineSource, nsPrefix string, ops ...mysqlxorm.SessionOption) ([]PipelineCmsNs, error)

func (*Client) UpdateCmsNsConfigs

func (client *Client) UpdateCmsNsConfigs(cmsNs PipelineCmsNs, configs []PipelineCmsConfig, ops ...mysqlxorm.SessionOption) error

type PipelineCmsConfig

type PipelineCmsConfig struct {
	ID uint64 `json:"id" xorm:"pk autoincr"`

	NsID uint64 `json:"nsID"`

	Key   string `json:"key"`
	Value string `json:"value"`

	Encrypt *bool `json:"encrypt"`

	Type string `json:"type"`

	Extra PipelineCmsConfigExtra `json:"extra" xorm:"json"`

	TimeCreated *time.Time `json:"timeCreated,omitempty" xorm:"created"`
	TimeUpdated *time.Time `json:"timeUpdated,omitempty" xorm:"updated"`
}

PipelineCmsConfig 配置管理命名空间下的具体配置

func (PipelineCmsConfig) BeforeSet

func (c PipelineCmsConfig) BeforeSet(fieldName string, cell xorm.Cell)

BeforeSet is invoked before FromDB order: get value from db -> invoke BeforeSet -> invoke FromDB -> struct

func (PipelineCmsConfig) Equal

func (c PipelineCmsConfig) Equal(another PipelineCmsConfig) bool

func (PipelineCmsConfig) TableName

func (PipelineCmsConfig) TableName() string

type PipelineCmsConfigExtra

type PipelineCmsConfigExtra struct {
	// Operations 从数据库取出时保证不为 nil
	Operations *pb.PipelineCmsConfigOperations `json:"operations"`
	// Comment 注释
	Comment string `json:"comment"`
	// From 配置项来源,可为空。例如:证书管理同步
	From string `json:"from"`
}

func (*PipelineCmsConfigExtra) FromDB

func (extra *PipelineCmsConfigExtra) FromDB(b []byte) error

FromDB 处理 operations 默认值,老数据无需通过 dbmigration 赋值

func (*PipelineCmsConfigExtra) ToDB

func (extra *PipelineCmsConfigExtra) ToDB() ([]byte, error)

ToDB 为 operations 赋默认值

type PipelineCmsNs

type PipelineCmsNs struct {
	ID uint64 `json:"id" xorm:"pk autoincr"`

	PipelineSource apistructs.PipelineSource `json:"pipelineSource"`

	Ns string `json:"ns"`

	TimeCreated *time.Time `json:"timeCreated,omitempty" xorm:"created"`
	TimeUpdated *time.Time `json:"timeUpdated,omitempty" xorm:"updated"`
}

PipelineCmsNs 配置管理命名空间

func (PipelineCmsNs) TableName

func (PipelineCmsNs) TableName() string

Jump to

Keyboard shortcuts

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