openapi

package
v3.0.0-...-3d101a0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 19 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 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

func PatchPropertiesChanged(patch map[string]any, 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]any, path ...string) (any, 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]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

func PropertiesChanged(oldObj, newObj map[string]any, 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 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.

Jump to

Keyboard shortcuts

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