structure

package module
v0.63.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Overview

Package structure defines a helper to retrieve structured data from the config

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnmarshalKey

func UnmarshalKey(cfg model.Reader, key string, target interface{}, opts ...UnmarshalKeyOption) error

UnmarshalKey retrieves data from the config at the given key and deserializes it to be stored on the target struct.

When DD_CONF_NODETREEMODEL is enabled we use the implementation using reflection, and do not depend upon details of the data model of the config. Target struct can use of struct tag of "yaml", "json", or "mapstructure" to rename fields

Else the viper/legacy version is used.

Types

type UnmarshalKeyOption

type UnmarshalKeyOption func(*featureSet)

UnmarshalKeyOption is an option that affects the enabled features in UnmarshalKey

var ConvertEmptyStringToNil UnmarshalKeyOption = func(fs *featureSet) {
	fs.convertEmptyStrNil = true
}

ConvertEmptyStringToNil allows UnmarshalKey to implicitly convert empty strings into nil slices

var EnableSquash UnmarshalKeyOption = func(fs *featureSet) {
	fs.allowSquash = true
}

EnableSquash allows UnmarshalKey to take advantage of `mapstructure`s `squash` feature a squashed field hoists its fields up a level in the marshalled representation and directly embeds them

var ImplicitlyConvertArrayToMapSet UnmarshalKeyOption = func(fs *featureSet) {
	fs.convertArrayToMap = true
}

ImplicitlyConvertArrayToMapSet allows UnmarshalKey to implicitly convert an array of []interface{} to a map[interface{}]bool

Jump to

Keyboard shortcuts

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