utils

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientForResource

func ClientForResource(pool dynamic.ClientPool, disco discovery.DiscoveryInterface, obj runtime.Object, defNs string) (dynamic.ResourceInterface, error)

ClientForResource returns the ResourceClient for a given object

func FlattenToV1

func FlattenToV1(objs []runtime.Object) []*unstructured.Unstructured

FlattenToV1 expands any List-type objects into their members, and cooerces everything to v1.Unstructured. Panics if coercion encounters an unexpected object type.

func FqName

func FqName(o metav1.Object) string

FqName returns "namespace.name"

func GroupVersionKindFor

func GroupVersionKindFor(o runtime.Object) string

GroupVersionKindFor returns a lowercased kind for an Kubernete's object

func NewMemcachedDiscoveryClient

func NewMemcachedDiscoveryClient(cl discovery.DiscoveryInterface) discovery.CachedDiscoveryInterface

NewMemcachedDiscoveryClient creates a new DiscoveryClient that caches results in memory

func Read

func Read(fs afero.Fs, vm *jsonnet.VM, path string) ([]runtime.Object, error)

Read fetches and decodes K8s objects by path. TODO: Replace this with something supporting more sophisticated content negotiation.

func ResourceNameFor

func ResourceNameFor(disco discovery.ServerResourcesInterface, o runtime.Object) string

ResourceNameFor returns a lowercase plural form of a type, for human messages. Returns lowercased kind if discovery lookup fails.

Types

type AlphabeticalOrder

type AlphabeticalOrder []*unstructured.Unstructured

AlphabeticalOrder is a `sort.Interface` that sorts the objects by namespace/name/kind alphabetical order

func (AlphabeticalOrder) Len

func (l AlphabeticalOrder) Len() int

func (AlphabeticalOrder) Less

func (l AlphabeticalOrder) Less(i, j int) bool

func (AlphabeticalOrder) Swap

func (l AlphabeticalOrder) Swap(i, j int)

type DependencyOrder

type DependencyOrder []*unstructured.Unstructured

DependencyOrder is a `sort.Interface` that *best-effort* sorts the objects so that known dependencies appear earlier in the list. The idea is to prevent *some* of the "crash-restart" loops when creating inter-dependent resources.

func (DependencyOrder) Len

func (l DependencyOrder) Len() int

func (DependencyOrder) Less

func (l DependencyOrder) Less(i, j int) bool

func (DependencyOrder) Swap

func (l DependencyOrder) Swap(i, j int)

type ServerVersion

type ServerVersion struct {
	Major int
	Minor int
}

ServerVersion captures k8s major.minor version in a parsed form

func FetchVersion

func FetchVersion(v discovery.ServerVersionInterface) (ret ServerVersion, err error)

FetchVersion fetches version information from discovery client, and parses

func ParseVersion

func ParseVersion(v *version.Info) (ret ServerVersion, err error)

ParseVersion parses version.Info into a ServerVersion struct

func (ServerVersion) Compare

func (v ServerVersion) Compare(major, minor int) int

Compare returns -1/0/+1 iff v is less than / equal / greater than major.minor

func (ServerVersion) String

func (v ServerVersion) String() string

Jump to

Keyboard shortcuts

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