utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package object was forked from:

https://github.com/koding/koding/blob/4e0b75243e60685f3271838d2eb08bd3801fae48/go/src/koding/kites/kloud/utils/object/fix.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertMapsToStringMaps

func ConvertMapsToStringMaps(item interface{}) (res interface{}, err error)

ConvertMapsToStringMaps recursively converts values of type map[interface{}]interface{} contained in item to map[string]interface{}. This is needed before the encoders for TOML and JSON can accept data returned by the YAML decoder.

func FixHCL

func FixHCL(v interface{})

FixHCL is a best-effort method to "fix" value representation of HCL-encoded value, so it can be marshaled to a valid JSON.

hcl.Unmarshal encodes each object as []map[string]interface{}, and kloud expects JSON objects to not be wrapped in a 1-element slice.

This function converts []map[string]interface{} to map[string]interface{} if length of the slice is 1.

BUG(rjeczalik): This is going to break templates, which have legit 1-element []map[string]interface{} values.

func FixYAML

func FixYAML(v interface{}) interface{}

FixYAML is a best-effort of fixing representation of YAML-encoded value, so it can be marshaled to a valid JSON.

YAML creates types like map[interface{}]interface{}, which are not a valid JSON types.

Related issue:

https://github.com/go-yaml/yaml/issues/139

func ToMap

func ToMap(in interface{}, tag string) (map[string]interface{}, error)

toMap converts a struct defined by `in` to a map[string]interface{}. It only extract data that is defined by the given tag.

func ToUint

func ToUint(x interface{}) uint

toUint tries to convert the given to uint type

Types

This section is empty.

Notes

Bugs

  • This is going to break templates, which have legit 1-element []map[string]interface{} values.

Jump to

Keyboard shortcuts

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