openapi

package
v1.7.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package openapi is a collection of libraries for fetching the openapi spec from a Kubernetes server and then indexing the type definitions. The openapi spec contains the object model definitions and extensions metadata such as the patchStrategy and patchMergeKey for creating patches.

Index

Constants

View Source
const Array = "array"

Array is the name for array types

View Source
const Boolean = "boolean"

Bool is the name for boolean types

View Source
const Integer = "integer"

Integer is the name for integer types

View Source
const Map = "object"

Map is the name for map types types.go struct fields that are maps will have an open API type "object" types.go struct fields that are actual objects appearing as a struct in a types.go file will have no type defined and have a json pointer reference to the type definition

View Source
const String = "string"

String is the name for string types

Variables

This section is empty.

Functions

This section is empty.

Types

type Getter

type Getter interface {
	// openAPIData returns the parsed openAPIData
	Get() (*Resources, error)
}

Getter is an interface for fetching openapi specs and parsing them into an Resources struct

func NewOpenAPIGetter

func NewOpenAPIGetter(cacheDir, serverVersion string, openAPIClient discovery.OpenAPISchemaInterface) Getter

NewOpenAPIGetter returns an object to return OpenAPIDatas which either read from a local file cache or read from a server, and then stored in memory for subsequent invocations

type Kind

type Kind struct {
	// Name is the lookup key given to this Kind by the open API spec.
	// May not contain any semantic meaning or relation to the API definition,
	// simply must be unique for each object definition in the Open API spec.
	// e.g. io.k8s.kubernetes.pkg.apis.apps.v1beta1.Deployment
	Name string

	// IsResource is true if the Kind is a Resource (it has API endpoints)
	// e.g. Deployment is a Resource, DeploymentStatus is NOT a Resource
	IsResource bool

	// GroupVersionKind uniquely defines a resource type in the Kubernetes API
	// and is present for all resources.
	// Empty for non-resource Kinds (e.g. those without APIs).
	// e.g. "Group": "apps", "Version": "v1beta1", "Kind": "Deployment"
	GroupVersionKind schema.GroupVersionKind

	// Present only for definitions that represent primitive types with additional
	// semantic meaning beyond just string, integer, boolean - e.g.
	// Fields with a PrimitiveType should follow the validation of the primitive type.
	// io.k8s.apimachinery.pkg.apis.meta.v1.Time
	// io.k8s.apimachinery.pkg.util.intstr.IntOrString
	PrimitiveType string

	// Extensions are openapi extensions for the object definition.
	Extensions spec.Extensions

	// Fields are the fields defined for this Kind
	Fields map[string]Type
}

Kind defines a Kubernetes object Kind

type Resources

type Resources struct {
	// GroupVersionKindToName maps GroupVersionKinds to Type names
	GroupVersionKindToName map[schema.GroupVersionKind]string
	// NameToDefinition maps Type names to TypeDefinitions
	NameToDefinition map[string]Kind
}

Resources contains the object definitions for Kubernetes resource apis Fields are public for binary serialization (private fields don't get serialized)

func (Resources) LookupResource

func (r Resources) LookupResource(groupVersionKind schema.GroupVersionKind) (Kind, bool)

LookupResource returns the Kind for the specified groupVersionKind

type Type

type Type struct {
	// Name is the name of the type
	TypeName string

	// IsKind is true if the definition represents a Kind
	IsKind bool
	// IsPrimitive is true if the definition represents a primitive type - e.g. string, boolean, integer
	IsPrimitive bool
	// IsArray is true if the definition represents an array type
	IsArray bool
	// IsMap is true if the definition represents a map type
	IsMap bool

	// ElementType will be specified for arrays and maps
	// if IsMap == true, then ElementType is the type of the value (key is always string)
	// if IsArray == true, then ElementType is the type of the element
	ElementType *Type

	// Extensions are extensions for this field and may contain
	// metadata from the types.go struct field tags.
	// e.g. contains patchStrategy, patchMergeKey, etc
	Extensions spec.Extensions
}

Type defines a field type and are expected to be one of: - IsKind - IsMap - IsArray - IsPrimitive

Jump to

Keyboard shortcuts

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