utils

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2018 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientForResource added in v0.5.0

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

ClientForResource returns the ResourceClient for a given object

func DependencyOrder added in v0.2.0

func DependencyOrder(disco ServerResourcesSwaggerSchema, list []*unstructured.Unstructured) (sort.Interface, error)

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 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 added in v0.5.0

func FqName(o metav1.Object) string

FqName returns "namespace.name"

func NewAuthTransport added in v0.3.0

func NewAuthTransport(inner http.RoundTripper) http.RoundTripper

NewAuthTransport returns a roundtripper that does bearer/etc authentication

func NewInvalidTypeError added in v0.5.0

func NewInvalidTypeError(expected reflect.Kind, observed reflect.Kind, fieldName string) error

NewInvalidTypeError creates an InvalidTypeError object

func NewMemcachedDiscoveryClient

func NewMemcachedDiscoveryClient(cl discovery.DiscoveryInterface) discovery.CachedDiscoveryInterface

NewMemcachedDiscoveryClient creates a new DiscoveryClient that caches results in memory

func Read

func Read(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 RegisterNativeFuncs added in v0.3.0

func RegisterNativeFuncs(vm *jsonnet.VM, resolver Resolver)

RegisterNativeFuncs adds kubecfg's native jsonnet functions to provided VM

func ResourceNameFor added in v0.5.0

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.

func SetMetaDataAnnotation added in v0.5.0

func SetMetaDataAnnotation(obj metav1.Object, key, value string)

SetMetaDataAnnotation sets an annotation value

Types

type AlphabeticalOrder added in v0.2.0

type AlphabeticalOrder []*unstructured.Unstructured

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

func (AlphabeticalOrder) Len added in v0.2.0

func (l AlphabeticalOrder) Len() int

func (AlphabeticalOrder) Less added in v0.2.0

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

func (AlphabeticalOrder) Swap added in v0.2.0

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

type ImageName added in v0.3.0

type ImageName struct {
	// eg: "myregistryhost:5000/fedora/httpd:version1.0"
	Registry   string // "myregistryhost:5000"
	Repository string // "fedora"
	Name       string // "httpd"
	Tag        string // "version1.0"
	Digest     string
}

ImageName represents the parts of a docker image name

func ParseImageName added in v0.3.0

func ParseImageName(image string) (ImageName, error)

ParseImageName parses a docker image into an ImageName struct

func (ImageName) RegistryRepoName added in v0.3.0

func (n ImageName) RegistryRepoName() string

RegistryRepoName returns the "repository" as used in the registry URL

func (ImageName) RegistryURL added in v0.3.0

func (n ImageName) RegistryURL() string

RegistryURL returns the deduced base URL of the registry for this image

func (ImageName) String added in v0.3.0

func (n ImageName) String() string

String implements the Stringer interface

type InvalidTypeError added in v0.5.0

type InvalidTypeError struct {
	ExpectedKind reflect.Kind
	ObservedKind reflect.Kind
	FieldName    string
}

InvalidTypeError is returned when an invalid type is encountered

func (*InvalidTypeError) Error added in v0.5.0

func (i *InvalidTypeError) Error() string

type Registry added in v0.3.0

type Registry struct {
	URL    string
	Client *http.Client
}

Registry is a *crazy limited* Docker registry client.

func NewRegistryClient added in v0.3.0

func NewRegistryClient(client *http.Client, url string) *Registry

NewRegistryClient creates a new Registry client using the given http client and base URL.

func (*Registry) ManifestDigest added in v0.3.0

func (r *Registry) ManifestDigest(reponame, tag string) (string, error)

ManifestDigest fetches the manifest digest for a given reponame and tag.

type Resolver added in v0.3.0

type Resolver interface {
	Resolve(image *ImageName) error
}

Resolver is able to resolve docker image names into more specific forms

func NewIdentityResolver added in v0.3.0

func NewIdentityResolver() Resolver

NewIdentityResolver returns a resolver that does only trivial :latest canonicalisation

func NewRegistryResolver added in v0.3.0

func NewRegistryResolver(httpClient *http.Client) Resolver

NewRegistryResolver returns a resolver that looks up a docker registry to resolve digests

type ServerResourcesSwaggerSchema added in v0.6.0

type ServerResourcesSwaggerSchema interface {
	discovery.ServerResourcesInterface
	discovery.SwaggerSchemaInterface
}

A subset of discovery.DiscoveryInterface

type ServerVersion added in v0.4.0

type ServerVersion struct {
	Major int
	Minor int
}

ServerVersion captures k8s major.minor version in a parsed form

func FetchVersion added in v0.4.0

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

FetchVersion fetches version information from discovery client, and parses

func ParseVersion added in v0.4.0

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

ParseVersion parses version.Info into a ServerVersion struct

func (ServerVersion) Compare added in v0.4.0

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 added in v0.4.0

func (v ServerVersion) String() string

type SwaggerSchema added in v0.5.0

type SwaggerSchema struct {
	// contains filtered or unexported fields
}

SwaggerSchema represents an OpenAPI/Swagger schema

func NewSwaggerSchemaFor added in v0.5.0

func NewSwaggerSchemaFor(delegate discovery.SwaggerSchemaInterface, gv schema.GroupVersion) (*SwaggerSchema, error)

NewSwaggerSchemaFor returns the SwaggerSchema object ready to validate objects of given GroupVersion

func (*SwaggerSchema) Validate added in v0.5.0

func (s *SwaggerSchema) Validate(obj *unstructured.Unstructured) []error

Validate is the primary entrypoint into this class

func (*SwaggerSchema) ValidateObject added in v0.5.0

func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName string) []error

ValidateObject validates a JSON object against the schema

type TypeNotFoundError added in v0.5.0

type TypeNotFoundError string

TypeNotFoundError is returned when specified type can not found in schema

func (TypeNotFoundError) Error added in v0.5.0

func (tnfe TypeNotFoundError) Error() string

Jump to

Keyboard shortcuts

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