utilgo.mau.fi/util/configupgrade Index | Files

package configupgrade

import "go.mau.fi/util/configupgrade"

Index

Constants

const (
	NullTag      = "!!null"
	BoolTag      = "!!bool"
	StrTag       = "!!str"
	IntTag       = "!!int"
	FloatTag     = "!!float"
	TimestampTag = "!!timestamp"
	SeqTag       = "!!seq"
	MapTag       = "!!map"
	BinaryTag    = "!!binary"
)

Functions

func Do

func Do(configPath string, save bool, upgrader BaseUpgrader, additional ...Upgrader) ([]byte, bool, error)

Types

type BaseUpgrader

type BaseUpgrader interface {
	Upgrader
	GetBase() string
}

type CopyHelper

type CopyHelper struct {
	Base   YAMLNode
	Config YAMLNode
}

func NewHelper

func NewHelper(base, cfg *yaml.Node) *CopyHelper

func (*CopyHelper) AddSpaceBeforeComment

func (helper *CopyHelper) AddSpaceBeforeComment(path ...string)

func (*CopyHelper) Copy

func (helper *CopyHelper) Copy(allowedTypes YAMLType, path ...string)

func (*CopyHelper) Get

func (helper *CopyHelper) Get(tag YAMLType, path ...string) (string, bool)

func (*CopyHelper) GetBase

func (helper *CopyHelper) GetBase(path ...string) string

func (*CopyHelper) GetBaseNode

func (helper *CopyHelper) GetBaseNode(path ...string) *YAMLNode

func (*CopyHelper) GetNode

func (helper *CopyHelper) GetNode(path ...string) *YAMLNode

func (*CopyHelper) Set

func (helper *CopyHelper) Set(tag YAMLType, value string, path ...string)

func (*CopyHelper) SetMap

func (helper *CopyHelper) SetMap(value YAMLMap, path ...string)

type Helper

type Helper interface {
	Copy(allowedTypes YAMLType, path ...string)
	Get(tag YAMLType, path ...string) (string, bool)
	GetNode(path ...string) *YAMLNode
	GetBase(path ...string) string
	GetBaseNode(path ...string) *YAMLNode
	Set(tag YAMLType, value string, path ...string)
	SetMap(value YAMLMap, path ...string)
	AddSpaceBeforeComment(path ...string)
}

type ProxyHelper

type ProxyHelper struct {
	Prefix []string
	Target Helper
}

func (*ProxyHelper) AddSpaceBeforeComment

func (p *ProxyHelper) AddSpaceBeforeComment(path ...string)

func (*ProxyHelper) Copy

func (p *ProxyHelper) Copy(allowedTypes YAMLType, path ...string)

func (*ProxyHelper) Get

func (p *ProxyHelper) Get(tag YAMLType, path ...string) (string, bool)

func (*ProxyHelper) GetBase

func (p *ProxyHelper) GetBase(path ...string) string

func (*ProxyHelper) GetBaseNode

func (p *ProxyHelper) GetBaseNode(path ...string) *YAMLNode

func (*ProxyHelper) GetNode

func (p *ProxyHelper) GetNode(path ...string) *YAMLNode

func (*ProxyHelper) Set

func (p *ProxyHelper) Set(tag YAMLType, value string, path ...string)

func (*ProxyHelper) SetMap

func (p *ProxyHelper) SetMap(value YAMLMap, path ...string)

type ProxyUpgrader

type ProxyUpgrader struct {
	Prefix []string
	Target Upgrader
}

func (*ProxyUpgrader) DoUpgrade

func (p *ProxyUpgrader) DoUpgrade(helper Helper)

func (*ProxyUpgrader) SpacedBlocks

func (p *ProxyUpgrader) SpacedBlocks() [][]string

type SimpleUpgrader

type SimpleUpgrader func(helper Helper)

func (SimpleUpgrader) DoUpgrade

func (su SimpleUpgrader) DoUpgrade(helper Helper)

type SpacedUpgrader

type SpacedUpgrader interface {
	Upgrader
	SpacedBlocks() [][]string
}

type StructUpgrader

type StructUpgrader struct {
	SimpleUpgrader
	Blocks [][]string
	Base   string
}

func MergeUpgraders

func MergeUpgraders(base string, upgraders ...Upgrader) *StructUpgrader

func (*StructUpgrader) GetBase

func (su *StructUpgrader) GetBase() string

func (*StructUpgrader) SpacedBlocks

func (su *StructUpgrader) SpacedBlocks() [][]string

type Upgrader

type Upgrader interface {
	DoUpgrade(helper Helper)
}
var NoopUpgrader Upgrader = &noopUpgrader{}

type YAMLList

type YAMLList []YAMLNode

type YAMLMap

type YAMLMap map[string]YAMLNode

type YAMLNode

type YAMLNode struct {
	*yaml.Node
	Map  YAMLMap
	List YAMLList
	Key  *yaml.Node
}

func StringNode

func StringNode(val string) YAMLNode

func (*YAMLNode) UpdateContent

func (yn *YAMLNode) UpdateContent()

type YAMLType

type YAMLType uint32
const (
	Null YAMLType = 1 << iota
	Bool
	Str
	Int
	Float
	Timestamp
	List
	Map
	Binary
)

func (YAMLType) String

func (t YAMLType) String() string

Source Files

helper.go proxyhelper.go upgrade.go

Version
v0.8.6 (latest)
Published
Mar 16, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
1 week ago

Tools for package owners.