cms

package
v1.0.0-rc Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxKeyPipelineSource = "pipelineSource"
	CtxKeyForceDelete    = "forceDelete"
)

Variables

View Source
var EnvTransferValidator strutil.Validator = func(s string) error {

	env := strings.Replace(strings.Replace(strings.ToUpper(s), ".", "_", -1), "-", "_", -1)
	if err := strutil.Validate(env, strutil.EnvKeyValidator); err != nil {
		return errors.Errorf("failed to transfer config key to env key, config key: %s, env key: %s, err: %v",
			s, env, err)
	}
	return nil
}
View Source
var KeyValidator strutil.Validator = func(s string) error {

	keyRegexp := `^[a-zA-Z_]+[.a-zA-Z0-9_-]*$`
	valid := regexp.MustCompilePOSIX(keyRegexp).MatchString(s)
	if !valid {
		return fmt.Errorf("valid key regexp: %s", keyRegexp)
	}
	return nil
}

Functions

func NewPipelineCms

func NewPipelineCms(dbClient *dbclient.Client, rsaCrypt *encryption.RsaCrypt) *pipelineCm

Types

type ConfigManager

type ConfigManager interface {
	// IdempotentCreateNS 幂等创建 ns
	IdempotentCreateNS(ctx context.Context, ns string) error
	// IdempotentDeleteNS 幂等删除 ns,ns 下的所有配置一并删除
	IdempotentDeleteNS(ctx context.Context, ns string) error
	// PrefixListNS 获取 ns 列表,支持前缀过滤
	PrefixListNS(ctx context.Context, nsPrefix string) ([]apistructs.PipelineCmsNs, error)
	// UpdateConfigs 不存在,则创建;已存在,则更新
	UpdateConfigs(ctx context.Context, ns string, kvs map[string]apistructs.PipelineCmsConfigValue) error
	// DeleteConfigs 根据 keys 删除配置。若 ns 不存在,返回空
	DeleteConfigs(ctx context.Context, ns string, keys ...string) error
	// GetConfigs 获取 ns 下配置。若 ns 不存在,则返回空。若指定 keys,则只获取指定 key 的配置
	GetConfigs(ctx context.Context, ns string, globalDecrypt bool, keys ...apistructs.PipelineCmsConfigKey) (map[string]apistructs.PipelineCmsConfigValue, error)
}

Jump to

Keyboard shortcuts

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