Documentation ¶
Index ¶
- Constants
- Variables
- func CreateGetRequest(updateRequest interface{}, getRequestType reflect.Type) interface{}
- func DeleteRecursive(elem interface{}, keys ...string)
- func MarshalModeArgSpec() *core.ArgSpec
- func UpdateResourceEditor(resource interface{}, updateRequest interface{}, cfg *Config) (interface{}, error)
- func ValueMapper(dest reflect.Value, src reflect.Value, opts ...ValueMapperOpt)
- type Config
- type GetResourceFunc
- type MarshalMode
- type ValueMapperOpt
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
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 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
Click to show internal directories.
Click to hide internal directories.