yaml

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanMerge

func CleanMerge(yamls [][]byte) ([]byte, error)

func ContainsFlatKey

func ContainsFlatKey(source string, excludedKeys []string, keys []string) (bool, error)

func DiffFlatKeys

func DiffFlatKeys(source, target string) ([]string, error)

DiffFlatKeys finds flat keys with different values from two yamls

func Equal

func Equal(source, target string) (bool, error)

func ExtractVariableYaml

func ExtractVariableYaml(sourceTmpl string) (string, error)

ExtractVariableYaml extracts variables from go-template and packages into yaml

func Merge

func Merge(yamls [][]byte) ([]byte, error)

Merge merges a couple of yaml files into one yaml file, a field in latter file will override the same field in former file.

func MergeAndUnmarshal

func MergeAndUnmarshal(yamls [][]byte) (map[string]interface{}, error)

MergeAndUnmarshal merges a couple of yaml files into one yaml file, and return a map[string]interface{}, a field in latter file will override the same field in former file.

func SearchByPattern

func SearchByPattern(flatMap map[string]interface{}, patterns []map[string]string) ([]map[string]string, error)

SearchByPattern find all matched absolute paths from yaml by the pattern appointed input pattern: []map{name => relative-path} output: app paths found which match the relative-path rule, []{map[name]=>absolute-path} eg: sourceYaml: ---------- yaml begin env: dev svc1:

image:
  repository: go-sample-site
  tag: "0.2.1"

svc2:

image:
  repository: go-sample-site-2
  tag: "0.2.2"

imagePullSecrets:

  • name: default-secret

----------- yaml end pattern: []{"image": "repository", "tag": "tag"} output: []{{"image": "svc1.image.repository", "tag": "svc1.image.tag"}, {"image": "svc2.image.repository", "tag": "svc2.image.tag"}}

Types

type ComplexStruct

type ComplexStruct map[string]interface{}

ComplexStruct is the alias of map, so operator 'len' is supported in go-template

func (*ComplexStruct) Get

func (cs *ComplexStruct) Get(key string) interface{}

func (*ComplexStruct) Insert

func (cs *ComplexStruct) Insert(key string, notParent bool)

func (*ComplexStruct) String

func (cs *ComplexStruct) String() string

type PathPattern

type PathPattern map[string]string

Jump to

Keyboard shortcuts

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