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 ¶
const Array = "array"
Array is the name for array types
const Boolean = "boolean"
Bool is the name for boolean types
const Integer = "integer"
Integer is the name for integer types
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
const PrintColumnsKey = "x-kubernetes-print-columns"
const String = "string"
String is the name for string types
Variables ¶
This section is empty.
Functions ¶
func GetPrintColumns ¶
func GetPrintColumns(extensions spec.Extensions) (string, bool)
GetPrintColumns looks for the open API extension for the display columns.
Types ¶
type CachingOpenAPIClient ¶
type CachingOpenAPIClient struct {
// contains filtered or unexported fields
}
func NewCachingOpenAPIClient ¶
func NewCachingOpenAPIClient(client discovery.OpenAPISchemaInterface, version, cacheDir string) *CachingOpenAPIClient
NewCachingOpenAPIClient returns a new discovery.OpenAPISchemaInterface that will read the openapi spec from a local cache if it exists, and if not will then fetch an openapi spec using a client. client: used to fetch a new openapi spec if a local cache is not found version: the server version and used as part of the cache file location cacheDir: the directory under which the cache file will be written
func (*CachingOpenAPIClient) OpenAPIData ¶
func (c *CachingOpenAPIClient) OpenAPIData() (*Resources, error)
OpenAPIData returns an openapi spec. It will first attempt to read the spec from a local cache If it cannot read a local cache, it will read the file using the client and then write the cache.
type Getter ¶
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 NewOpenAPIData ¶
NewOpenAPIData parses the resource definitions in openapi data by groupversionkind and name
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