Documentation ¶
Index ¶
- func GetResourceSchemasForClient(client discovery.OpenAPISchemaInterface) (openapi.Resources, error)
- func PatchForResourceUpdate(resources openapi.Resources, ...) ([]byte, types.PatchType, strategicpatch.LookupPatchMeta, error)
- func PatchPropertiesChanged(patch map[string]interface{}, paths []string) ([]string, error)
- func Pluck(obj map[string]interface{}, path ...string) (interface{}, bool)
- func PropertiesChanged(oldObj, newObj map[string]interface{}, paths []string) ([]string, error)
- func SupportsDryRun(client discovery.OpenAPISchemaInterface, gvk schema.GroupVersionKind) (bool, error)
- func ValidateAgainstSchema(resources openapi.Resources, obj *unstructured.Unstructured) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetResourceSchemasForClient ¶ added in v1.2.2
func GetResourceSchemasForClient( client discovery.OpenAPISchemaInterface, ) (openapi.Resources, error)
GetResourceSchemasForClient obtains the OpenAPI schemas for all Kubernetes resources supported by client.
func PatchForResourceUpdate ¶
func PatchForResourceUpdate( resources openapi.Resources, lastSubmitted, currentSubmitted, liveOldObj *unstructured.Unstructured, ) ([]byte, types.PatchType, strategicpatch.LookupPatchMeta, 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 ¶ added in v0.25.1
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 ¶ added in v0.15.0
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]interface{}{ "a": map[string]interface{}{ "x": map[string]interface{}{ "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]interface{}{ "a": map[string]interface{}{ "x": map[string]interface{}{ "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 ¶ added in v0.16.0
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 SupportsDryRun ¶ added in v0.25.3
func SupportsDryRun(client discovery.OpenAPISchemaInterface, gvk schema.GroupVersionKind) (bool, error)
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.