util

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Camel added in v0.19.0

func Camel(in string) string

Camel converts from snake_case to camelCase

func CheckForElidedFields

func CheckForElidedFields(struct_ interface{}) report.Report

Report an ErrFieldElided warning for any non-zero top-level fields in the specified output struct. The caller will probably want to use translate.PrefixReport() to reparent the report into the right place in the `json` hierarchy, and then TranslateReportPaths() to map back into `yaml` space.

func Snake added in v0.19.0

func Snake(in string) string

Snake converts from camelCase (not CamelCase) to snake_case

func Translate

func Translate(cfg Config, translateMethod string, options common.TranslateOptions) (interface{}, report.Report, error)

Translate translates cfg to the corresponding Ignition config version using the named translation method on cfg, and returns the marshaled Ignition config. It returns a report of any errors or warnings in the source and resultant config. If the report has fatal errors or it encounters other problems translating, an error is returned.

func TranslateBytes

func TranslateBytes(input []byte, container interface{}, translateMethod string, options common.TranslateBytesOptions) ([]byte, report.Report, error)

TranslateBytes unmarshals the Butane config specified in input into the struct pointed to by container, translates it to the corresponding Ignition config version using the named translation method, and returns the marshaled Ignition config. It returns a report of any errors or warnings in the source and resultant config. If the report has fatal errors or it encounters other problems translating, an error is returned.

func TranslateBytesYAML

func TranslateBytesYAML(input []byte, container interface{}, translateMethod string, options common.TranslateBytesOptions) ([]byte, report.Report, error)

func TranslateReportPaths

func TranslateReportPaths(r report.Report, ts translate.TranslationSet) report.Report

TranslateReportPaths takes a report with a mix of json (camelCase) and yaml (snake_case) paths, and a set of translation rules. It applies those rules and converts all json paths to snake-cased yaml.

Types

type Config added in v0.19.0

type Config interface {
	FieldFilters() *FieldFilters
}

type FieldFilters added in v0.19.0

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

func NewFilters added in v0.19.0

func NewFilters(v any, filters FilterMap) FieldFilters

func NewFiltersIgnoreZero added in v0.19.0

func NewFiltersIgnoreZero(v any, filters FilterMap, ignoreZero []string) FieldFilters

func (FieldFilters) Lookup added in v0.19.0

func (ff FieldFilters) Lookup(filter string) error

func (FieldFilters) Verify added in v0.19.0

func (ff FieldFilters) Verify(v any) report.Report

type FilterMap added in v0.19.0

type FilterMap map[string]error

Jump to

Keyboard shortcuts

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