kubernetes

package
v0.0.0-...-c4965f0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ActionConnect is the "connect" Kubernetes action
	// DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT
	ActionConnect = "connect"
	// ActionDelete is the "delete" Kubernetes action
	// DELETE
	ActionDelete = "delete"
	// ActionDeleteCollection is the "deletecollection" Kubernetes action
	// DELETE
	ActionDeleteCollection = "deletecollection"
	// ActionGet is the "get" Kubernetes action
	// GET
	ActionGet = "get"
	// ActionList is the "list" Kubernetes action
	// GET
	ActionList = "list"
	// ActionPatch is the "patch" Kubernetes action
	// PATCH
	ActionPatch = "patch"
	// ActionCreate is the "post" Kubernetes action
	// POST
	ActionCreate = "post"
	// ActionUpdate is the "put" Kubernetes action
	// PUT
	ActionUpdate = "put"
	// ActionWatch is the "watch" Kubernetes action
	// GET
	ActionWatch = "watch"
	// ActionWatchList is the "watchlist" Kubernetes action
	// GET
	ActionWatchList = "watchlist"
)

Variables

View Source
var ParametersAnnex = map[string]struct{}{}

ParametersAnnex indicates the common parameters that are displayed in an annex

View Source
var ResourcesDescriptions = ResourcesMap{}

Functions

func GetListMapKeys

func GetListMapKeys(definition spec.Schema) ([]string, error)

GetListMapKeys returns the ListMapKeys extension of a definition, or nil if not found

func GetListType

func GetListType(definition spec.Schema) (*string, error)

GetListType returns the ListType extension of a definition, or nil if not found

func GetPatchMergeKeyExtension

func GetPatchMergeKeyExtension(extensions spec.Extensions) (*string, error)

GetPatchMergeKeyExtension returns the GetPatchMergeKey extension of a definition, or nil if not found

func GetPatchStrategyExtension

func GetPatchStrategyExtension(extensions spec.Extensions) (*string, error)

GetPatchStrategyExtension returns the PatchStrategy extension of a definition, or nil if not found

func ParameterInAnnex

func ParameterInAnnex(param spec.Parameter) bool

ParameterInAnnex returns true if param is displayed in annex

Types

type APIGroup

type APIGroup string

APIGroup represents the group of a Kubernetes API

func (APIGroup) Replaces

func (o APIGroup) Replaces(p APIGroup) bool

Replaces returns true if 'o' group is replaced by 'p' group

func (APIGroup) String

func (o APIGroup) String() string

type APIKind

type APIKind string

APIKind represents the Kind of a Kubernetes resource

func (APIKind) String

func (o APIKind) String() string

type APIVersion

type APIVersion struct {
	// Version is the *1* in v1alpha2
	Version int
	// Stage is *alpha* in v1alpha2
	Stage VersionStage
	// StageVersion is *2* in v1alpha2, or nil in v1
	StageVersion *int
}

APIVersion represents the version of a Kubernetes API (v1aplha1, v1beta2, v1, v2, etc)

func NewAPIVersion

func NewAPIVersion(literal string) (apiversion *APIVersion, err error)

NewAPIVersion creates a new APIVersion struct from the literal version (for example v1alpha1)

func (*APIVersion) Equals

func (o *APIVersion) Equals(p *APIVersion) bool

Equals returns true if 'o' and 'p' represent the same version

func (*APIVersion) LessThan

func (o *APIVersion) LessThan(p *APIVersion) bool

LessThan returns true if 'o' version comes before 'p' version

func (*APIVersion) Replaces

func (o *APIVersion) Replaces(p *APIVersion) bool

Replaces returns true if 'o' version replaces 'p' version

func (*APIVersion) String

func (o *APIVersion) String() string

String returns the literal representation of an APIVersion

func (*APIVersion) UnmarshalYAML

func (o *APIVersion) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML helps unmarshal APIVersion values from YAML

type ActionExtension

type ActionExtension string

ActionExtension represents the OpenAPI extension x-bubernetes-action

func (ActionExtension) LessThan

func (o ActionExtension) LessThan(p ActionExtension) bool

LessThan returns true if o appears before p in natural order

func (ActionExtension) String

func (o ActionExtension) String() string

String returns the string representation of an ActionExtension

func (ActionExtension) Verb

func (o ActionExtension) Verb() string

Verb returns the verb associated with the action

type ActionInfo

type ActionInfo struct {
	// Path of the endpoint
	Path ActionPath
	// Kubernetes action mapped to the endpoint
	Action ActionExtension
	// Definition of the action
	Operation *spec.Operation
	// HTTP Method
	HTTPMethod string
	// Parameters of the actions at path level plus operation level
	Parameters ParametersList
}

ActionInfo contains information about a specific endpoint

type ActionInfoList

type ActionInfoList []ActionInfo

ActionInfoList represents a list of actions info

func (ActionInfoList) Len

func (a ActionInfoList) Len() int

func (ActionInfoList) Less

func (a ActionInfoList) Less(i, j int) bool

func (ActionInfoList) Swap

func (a ActionInfoList) Swap(i, j int)

type ActionPath

type ActionPath string

ActionPath represents the path of an action

func (ActionPath) LessThan

func (o ActionPath) LessThan(p ActionPath) bool

LessThan returns true if o appears before p in natural order

func (ActionPath) String

func (o ActionPath) String() string

type Actions

type Actions map[string]ActionInfoList

Actions represents a map of ActionInfo, mapped by GVK

func (Actions) Add

func (o Actions) Add(specParameters map[string]spec.Parameter, key string, operation *spec.Operation, httpMethod string, pathParameters []spec.Parameter)

Add an action to the collection of actions

func (Actions) Get

func (o Actions) Get(gvk string) ActionInfoList

Get the actions for a specific GVK

func (Actions) Sort

func (o Actions) Sort()

Sort sorts the list of actions for each GVK

type GVKExtension

type GVKExtension struct {
	Group   APIGroup
	Version APIVersion
	Kind    APIKind
}

GVKExtension represents the OpenAPI extension x-kubernetes-group-version-kind

type GVToKeyMap

type GVToKeyMap map[string][]string

GVToKeyMap maps Kubernetes resource Group/Version with Spec Definition key (without Kind) e.g. GVToKey["v1"]: "io.k8s.api.core.v1"

func (GVToKeyMap) Add

func (o GVToKeyMap) Add(key string, resource *Resource)

Add adds a new match between key and resource GV

type Key

type Key string

Key of the resource in the OpenAPI definition (e.g. io.k8s.api.core.v1.Pod)

func GetTypeNameAndKey

func GetTypeNameAndKey(s spec.Schema) (string, *Key)

GetTypeNameAndKey returns the display name of a Schema. This is the api kind for definitions and the type for primitive types.

func (Key) GoImportPrefix

func (o Key) GoImportPrefix() string

GoImportPrefix returns the path to use for this group in go import

func (Key) RemoveResourceName

func (o Key) RemoveResourceName() string

RemoveResourceName removes the last part of the key corresponding to the resource name

func (Key) ResourceName

func (o Key) ResourceName() string

ResourceName returns the resource name part of a key

func (Key) String

func (o Key) String() string

String returns a string representation of the Key

type LinkEnds

type LinkEnds map[Key][]string

LinkEnds maps definition key to a link-end

func (LinkEnds) Add

func (o LinkEnds) Add(key Key, linkend []string)

Add a new map between key and linkend

func (LinkEnds) Debug

func (o LinkEnds) Debug()

type ParameterIn

type ParameterIn string

ParameterIn represenets the position of a parameter of an operation

func (ParameterIn) LessThan

func (o ParameterIn) LessThan(p ParameterIn) bool

LessThan returns true if o appears before p in the natural order

type ParametersList

type ParametersList []spec.Parameter

ParametersList is a list of parameters

func (*ParametersList) Add

func (a *ParametersList) Add(specParameters map[string]spec.Parameter, parameter spec.Parameter)

Add a parameter to the list

func (ParametersList) Len

func (a ParametersList) Len() int

func (ParametersList) Less

func (a ParametersList) Less(i, j int) bool

func (ParametersList) Swap

func (a ParametersList) Swap(i, j int)

type Property

type Property struct {
	Name               string
	Type               string
	TypeKey            *Key
	Description        string
	Required           bool
	RetainKeysStrategy bool
	MergeStrategyKey   *string
	ListType           *string
	ListMapKeys        []string
	HardCodedValue     *string
}

Property represents a property of a definition

func NewHardCodedValueProperty

func NewHardCodedValueProperty(name string, value string) *Property

NewHardCodedValueProperty returns a property with an hardcoded value (useful for apiVersion, Kind)

func NewProperty

func NewProperty(name string, details spec.Schema, required []string) (*Property, error)

NewProperty returns a new Property from its swagger definition

type Resource

type Resource struct {
	Key Key
	GVKExtension
	Definition spec.Schema

	// Replaced indicates if this version is replaced by another one
	ReplacedBy *Key
	// Documented indicates if this resource was included in the TOC
	Documented bool
}

Resource represent a Kubernetes API resource

func (*Resource) Equals

func (o *Resource) Equals(group APIGroup, version APIVersion, kind APIKind) bool

Equals returns true if a resource is referenced by group/version/kind

func (*Resource) GetGV

func (o *Resource) GetGV() string

GetGV returns the group/version of a resource (used for apiVersion:)

func (*Resource) LessThan

func (o *Resource) LessThan(p *Resource) bool

LessThan returns true if 'o' is a newer version than 'p'

func (*Resource) Replaces

func (o *Resource) Replaces(p *Resource) bool

Replaces returns true if 'o' replaces 'p'

type ResourceList

type ResourceList []*Resource

ResourceList is the list of resources for a given Kind

func (ResourceList) Len

func (a ResourceList) Len() int

func (ResourceList) Less

func (a ResourceList) Less(i, j int) bool

func (ResourceList) Swap

func (a ResourceList) Swap(i, j int)

type ResourceMap

type ResourceMap map[APIKind]ResourceList

ResourceMap contains a map of resources, classified by Kind

func (*ResourceMap) Add

func (o *ResourceMap) Add(resource *Resource)

Add a resource to the resource list

type ResourcesMap

type ResourcesMap map[string][]descriptionInfo

type Spec

type Spec struct {
	// Swagger is the openAPI representation of the k8s spec
	// populated by calling getSwagger
	Swagger *spec.Swagger

	// Resources is the list of K8s resources
	// populated by calling getResources
	Resources *ResourceMap

	// Actions is the list of endpoints defined in the API
	Actions Actions

	// GVToKey maps beetween Kubernetes Group/Version and Swagger definition key
	GVToKey GVToKeyMap
}

Spec represents the Kubernetes API Specification

func NewSpec

func NewSpec(filename string) (*Spec, error)

NewSpec creates a new Spec from a K8s spec file

func (*Spec) GetDefinition

func (o *Spec) GetDefinition(key Key) *spec.Schema

GetDefinition returns the definition referenced by key

func (*Spec) GetResource

func (o *Spec) GetResource(group APIGroup, version APIVersion, kind APIKind, markAsDocumented bool) (Key, *spec.Schema)

GetResource returns the resource referenced by group/version/kind, or nil if not found

type VersionStage

type VersionStage int

VersionStage represents the stage of the version: alpha, beta, ga

const (
	// StageAlpha is the first stage during development
	StageAlpha VersionStage = iota
	// StageBeta is the next stage
	StageBeta
	// StageGA is the latest stage
	StageGA
)

Jump to

Keyboard shortcuts

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