openapi

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

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 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

func PatchPropertiesChanged(patch map[string]interface{}, paths []string) ([]string, error)

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

func Pluck(obj map[string]interface{}, path ...string) (interface{}, bool)

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

func PropertiesChanged(oldObj, newObj map[string]interface{}, paths []string) ([]string, error)

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

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.

Jump to

Keyboard shortcuts

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