Documentation ¶
Index ¶
- func FlattenProperties(state map[string]any) map[string]any
- func GeneratePatch(currentState []byte, desiredState []byte, schema []byte) (jsondiff.Patch, error)
- func ParsePropertyName(propertyIdentifier string) (string, error)
- func UnflattenProperties(state map[string]any) map[string]any
- type ResourceTypeSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlattenProperties ¶
FlattenProperties takes a string-keyed map, which may contain nested objects, and recursively flattens it into a single-level map. For example:
"NumShards": 1 "ClusterEndpoint": { "Address": "test-address" "Port": 3000 }
Gets transformed to:
"NumShards": 1 "ClusterEndpoint/Address": "test-address" "ClusterEndpoint/Port": 3000
func GeneratePatch ¶
GeneratePatch takes in the current state, desired state and type schema of a resource and returns a JSON patch to update the current state to the desired state, taking into account read-only, create-only and conditional-create-only properties.
func ParsePropertyName ¶
ParsePropertyName transforms a propertyIdentifer of the form /properties/<propertyName> to <propertyName>. It returns an error if the property identifier is not in the expected format.
func UnflattenProperties ¶
UnflattenProperties takes in a map of strings to any type and returns an object with the nested properties unflattened. For example:
"NumShards": 1 "ClusterEndpoint/Address": "test-address" "ClusterEndpoint/Port": 3000
Gets transformed to:
"NumShards": 1 "ClusterEndpoint": { "Address": "test-address" "Port": 3000 }
Types ¶
type ResourceTypeSchema ¶
type ResourceTypeSchema struct { Properties map[string]any `json:"properties,omitempty"` ReadOnlyProperties []string `json:"readOnlyProperties,omitempty"` CreateOnlyProperties []string `json:"createOnlyProperties,omitempty"` ConditionalCreateOnlyProperties []string `json:"conditionalCreateOnlyProperties,omitempty"` WriteOnlyProperties []string `json:"writeOnlyProperties,omitempty"` }