editor

package
v2.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MarshalModeYAML = MarshalMode("yaml")
	MarshalModeJSON = MarshalMode("json")
)

Variables

View Source
var (
	MarshalModeDefault = MarshalModeYAML
	MarshalModeEnum    = []MarshalMode{MarshalModeYAML, MarshalModeJSON}
)
View Source
var LongDescription = `` /* 174-byte string literal not displayed */
View Source
var (
	SkipEditor = false
)

Functions

func CreateGetRequest added in v2.28.0

func CreateGetRequest(updateRequest interface{}, getRequestType reflect.Type) interface{}

CreateGetRequest creates a GetRequest from given type and populate it with content from updateRequest

func DeleteRecursive added in v2.28.0

func DeleteRecursive(elem interface{}, keys ...string)

func MarshalModeArgSpec

func MarshalModeArgSpec() *core.ArgSpec

func UpdateResourceEditor

func UpdateResourceEditor(resource interface{}, updateRequest interface{}, cfg *Config) (interface{}, error)

UpdateResourceEditor takes a complete resource and a partial updateRequest will return a copy of updateRequest that has been edited Only edited fields will be present in returned updateRequest If putRequest is true, all fields will be present, edited or not

func ValueMapper added in v2.28.0

func ValueMapper(dest reflect.Value, src reflect.Value, opts ...ValueMapperOpt)

ValueMapper get all fields present both in src and dest and set them in dest if argument is not zero-value in dest, it is not set fields is a list of jsonTags, if not nil, only fields with a tag in this list will be mapped

Types

type Config

type Config struct {
	// PutRequest means that the request replace all fields
	// If false, fields that were not edited will not be sent
	// If true, all fields will be sent
	PutRequest bool

	MarshalMode MarshalMode

	// Template is a template that will be shown before marshaled data in edited file
	Template string

	// IgnoreFields is a list of json tags that will be removed from marshaled data
	// The content of these fields will be lost in edited data
	IgnoreFields []string

	// If not empty, this will replace edited text as if it was edited in the terminal
	// Should be paired with global SkipEditor as true, useful for tests
	EditedResource string
}

type GetResourceFunc

type GetResourceFunc func(interface{}) (interface{}, error)

type MarshalMode

type MarshalMode = string

type ValueMapperOpt added in v2.28.0

type ValueMapperOpt func(cfg *valueMapperConfig)

func MapWithTag added in v2.28.0

func MapWithTag(includeFields ...string) ValueMapperOpt

MapWithTag will map only fields that have one of these tags as json tag

Jump to

Keyboard shortcuts

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