Documentation
¶
Index ¶
- func GetResourceSchemasForClient(client discovery.OpenAPISchemaInterface) (openapi.Resources, error)
- func MergePatch(lastSubmitted *unstructured.Unstructured, ...) (patch []byte, patchType types.PatchType, err error)
- func PatchForResourceUpdate(resources openapi.Resources, ...) (patch []byte, patchType types.PatchType, ...)
- func PatchPropertiesChanged(patch map[string]any, paths []string) ([]string, error)
- func Pluck(obj map[string]any, path ...string) (any, bool)
- func PropertiesChanged(oldObj, newObj map[string]any, paths []string) ([]string, error)
- func StrategicMergePatch(resources openapi.Resources, lastSubmitted *unstructured.Unstructured, ...) (patch []byte, patchType types.PatchType, ...)
- func SupportsDryRun(dryRunVerifier *resource.QueryParamVerifier, gvk schema.GroupVersionKind) bool
- func ValidateAgainstSchema(resources openapi.Resources, obj *unstructured.Unstructured) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetResourceSchemasForClient ¶
func GetResourceSchemasForClient( client discovery.OpenAPISchemaInterface, ) (openapi.Resources, error)
GetResourceSchemasForClient obtains the OpenAPI schemas for all Kubernetes resources supported by client.
func MergePatch ¶
func MergePatch( lastSubmitted *unstructured.Unstructured, lastSubmittedJSON, currentSubmittedJSON, liveOldJSON []byte, ) (patch []byte, patchType types.PatchType, err error)
MergePatch is a helper to use a three-way JSON merge patch on a resource version. See for more details: https://tools.ietf.org/html/rfc7386
func PatchForResourceUpdate ¶
func PatchForResourceUpdate( resources openapi.Resources, lastSubmitted, currentSubmitted, liveOldObj *unstructured.Unstructured, ) (patch []byte, patchType types.PatchType, lookupPatchMeta strategicpatch.LookupPatchMeta, err error)
PatchForResourceUpdate introspects on the given OpenAPI spec and attempts to generate a strategic merge patch for use in a resource update. If there is no specification of how to generate a strategic merge patch, we fall back to JSON merge patch.
func PatchPropertiesChanged ¶
PatchPropertiesChanged scrapes the given patch object to see if any path specified in `paths` has been changed. Paths are specified as JSONPaths, e.g., `.spec.accessModes` refers to `{spec: {accessModes: {}}}`.
func Pluck ¶
Pluck obtains the property identified by the string components in `path`. For example, `Pluck(foo, "bar", "baz")` returns `foo.bar.baz`.
Example (PathFound) ¶
obj := map[string]any{ "a": map[string]any{ "x": map[string]any{ "foo": 1, "bar": 2, }, }, } raw, ok := Pluck(obj, "a", "x", "bar") fmt.Printf("found = %v\n", ok) fmt.Printf("a.x.bar = %v\n", raw)
Output: found = true a.x.bar = 2
Example (PathNotFound) ¶
obj := map[string]any{ "a": map[string]any{ "x": map[string]any{ "foo": 1, "bar": 2, }, }, } raw, ok := Pluck(obj, "a", "x", "baz") fmt.Printf("found = %v\n", ok) fmt.Printf("a.x.baz = %v\n", raw)
Output: found = false a.x.baz = <nil>
func PropertiesChanged ¶
PropertiesChanged compares two versions of an object to see if any path specified in `paths` has been changed. Paths are specified as JSONPaths, e.g., `.spec.accessModes` refers to `{spec: {accessModes: {}}}`.
func StrategicMergePatch ¶
func StrategicMergePatch( resources openapi.Resources, lastSubmitted *unstructured.Unstructured, lastSubmittedJSON, currentSubmittedJSON, liveOldJSON []byte, ) (patch []byte, patchType types.PatchType, lookupPatchMeta strategicpatch.LookupPatchMeta, err error)
StrategicMergePatch is a helper to use a three-way strategic merge on a resource version. See for more details: https://tools.ietf.org/html/rfc6902
func SupportsDryRun ¶
func SupportsDryRun(dryRunVerifier *resource.QueryParamVerifier, gvk schema.GroupVersionKind) bool
SupportsDryRun returns true if the given GVK supports dry-run applies.
func ValidateAgainstSchema ¶
func ValidateAgainstSchema( resources openapi.Resources, obj *unstructured.Unstructured, ) error
ValidateAgainstSchema validates a document against the given schema.
Types ¶
This section is empty.