utils

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: Apache-2.0 Imports: 33 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 NewAuthTransport

func NewAuthTransport(inner http.RoundTripper) http.RoundTripper

NewAuthTransport returns a roundtripper that does bearer/etc authentication

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 RegisterNativeFuncs

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

RegisterNativeFuncs adds kubecfg's native jsonnet functions to provided VM

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 ImageName

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

func ParseImageName(image string) (ImageName, error)

ParseImageName parses a docker image into an ImageName struct

func (ImageName) RegistryRepoName

func (n ImageName) RegistryRepoName() string

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

func (ImageName) RegistryURL

func (n ImageName) RegistryURL() string

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

func (ImageName) String

func (n ImageName) String() string

String implements the Stringer interface

type Registry

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

Registry is a *crazy limited* Docker registry client.

func NewRegistryClient

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

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

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

type Resolver

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

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

func NewIdentityResolver

func NewIdentityResolver() Resolver

NewIdentityResolver returns a resolver that does only trivial :latest canonicalisation

func NewRegistryResolver

func NewRegistryResolver(httpClient *http.Client) Resolver

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

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