conf

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigChangeEvent = "config_change"
)

Variables

This section is empty.

Functions

func RedactSecrets added in v1.1.0

func RedactSecrets(schema Schema, data map[string]any) map[string]any

RedactSecrets 按 Schema 中标记 Secret 的字段,将 map 中对应值替换为 "***"。 用于日志输出,避免泄露密钥;返回拷贝后的 map(嵌套 map 会递归拷贝路径上的节点)。

func StrictMode added in v1.1.0

func StrictMode() bool

StrictMode 是否启用配置严格校验(缺键启动失败)。 环境变量:HARBOR_CONF_STRICT=1|true|yes|on

func ValidateConfigKeys

func ValidateConfigKeys(providerName, fileName, embeddedContent, confDir string) error

ValidateConfigKeys compares keys in the embedded default YAML with the on-disk config file. For any key present in embedded but missing on disk:

  • default: yellow warning only
  • HARBOR_CONF_STRICT=1/true: return error (启动失败)

Parse failures always return error.

func ValidateSchema added in v1.1.0

func ValidateSchema(schema Schema, data map[string]any) error

ValidateSchema 校验配置 map 是否满足 Schema。

Types

type ConfServiceProvider

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

func (*ConfServiceProvider) Boot

func (*ConfServiceProvider) Conf

func (i *ConfServiceProvider) Conf() map[string]string

func (*ConfServiceProvider) Description

func (i *ConfServiceProvider) Description() string

func (*ConfServiceProvider) Register

func (i *ConfServiceProvider) Register(ctx context.Context) error

func (*ConfServiceProvider) SetApplication added in v1.1.0

func (i *ConfServiceProvider) SetApplication(app foundation.Application)

type Configure

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

func NewConfigure

func NewConfigure(app foundation.Application, bus EventBus.Bus) (*Configure, error)

func (*Configure) GetConfig

func (i *Configure) GetConfig(key string, v any) error

func (*Configure) SaveConfig

func (i *Configure) SaveConfig(fileName string, key string, value any)

type Schema added in v1.1.0

type Schema struct {
	Provider string
	File     string
	Fields   []SchemaField
}

Schema 配置 Schema。

type SchemaField added in v1.1.0

type SchemaField struct {
	Key      string
	Required bool
	Type     string // string, int, bool, float, object, array
	Secret   bool
}

SchemaField 描述配置字段约束。

Source Files

  • conf_service_provider.go
  • event.go
  • load.go
  • schema.go
  • secret.go
  • validate.go

Jump to

Keyboard shortcuts

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