configupgrade

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MPL-2.0 Imports: 5 Imported by: 43

Documentation

Index

Constants

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

Variables

This section is empty.

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 added in v0.5.0

type CopyHelper struct {
	Base   YAMLNode
	Config YAMLNode
}

func NewHelper

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

func (*CopyHelper) AddSpaceBeforeComment added in v0.5.0

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

func (*CopyHelper) Copy added in v0.5.0

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

func (*CopyHelper) Get added in v0.5.0

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

func (*CopyHelper) GetBase added in v0.5.0

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

func (*CopyHelper) GetBaseNode added in v0.5.0

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

func (*CopyHelper) GetNode added in v0.5.0

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

func (*CopyHelper) Set added in v0.5.0

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

func (*CopyHelper) SetMap added in v0.5.0

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 added in v0.5.0

type ProxyHelper struct {
	Prefix []string
	Target Helper
}

func (*ProxyHelper) AddSpaceBeforeComment added in v0.5.0

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

func (*ProxyHelper) Copy added in v0.5.0

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

func (*ProxyHelper) Get added in v0.5.0

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

func (*ProxyHelper) GetBase added in v0.5.0

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

func (*ProxyHelper) GetBaseNode added in v0.5.0

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

func (*ProxyHelper) GetNode added in v0.5.0

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

func (*ProxyHelper) Set added in v0.5.0

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

func (*ProxyHelper) SetMap added in v0.5.0

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

type ProxyUpgrader added in v0.5.0

type ProxyUpgrader struct {
	Prefix []string
	Target Upgrader
}

func (*ProxyUpgrader) DoUpgrade added in v0.5.0

func (p *ProxyUpgrader) DoUpgrade(helper Helper)

func (*ProxyUpgrader) SpacedBlocks added in v0.5.0

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 added in v0.5.0

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

Jump to

Keyboard shortcuts

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