Documentation ¶
Index ¶
- Constants
- Variables
- func ClientForResource(client dynamic.Interface, mapper meta.RESTMapper, obj runtime.Object, ...) (dynamic.ResourceInterface, error)
- func CompactDecodeObject(data string, into runtime.Object) error
- func CompactEncodeObject(o runtime.Object) (string, error)
- func DeleteMetaDataAnnotation(obj metav1.Object, key string)
- func DeleteMetaDataLabel(obj metav1.Object, key string)
- func DependencyOrder(disco discovery.OpenAPISchemaInterface, mapper meta.RESTMapper, ...) (sort.Interface, error)
- func FlattenToV1(objs []runtime.Object) []*unstructured.Unstructured
- func FqName(o metav1.Object) string
- func MakeUniversalImporter(searchURLs []*url.URL, alpha bool) jsonnet.Importer
- func MaybeMarkStale(d discovery.DiscoveryInterface)
- func NewMemcachedDiscoveryClient(delegate discovery.DiscoveryInterface) discovery.CachedDiscoveryInterface
- func NewUnstructuredObject(o map[string]interface{}) (*unstructured.Unstructured, error)
- func PathToURL(path string) (string, error)
- func Read(vm *jsonnet.VM, path string, opts ...ReadOption) ([]runtime.Object, error)
- func RegisterNativeFuncs(vm *jsonnet.VM, resolver Resolver)
- func RemoveDuplicates(objs []*unstructured.Unstructured) ([]*unstructured.Unstructured, error)
- func ResourceNameFor(mapper meta.RESTMapper, o runtime.Object) string
- func SearchUp(fileName string, relativeTo string) (string, bool, error)
- func SetMetaDataAnnotation(obj metav1.Object, key, value string)
- func SetMetaDataLabel(obj metav1.Object, key, value string)
- func ToDataURL(code string) string
- type AlphabeticalOrder
- type ArrayReader
- type ImageName
- type OCIBundle
- type OCIBundleConfig
- type OpenAPISchema
- type ReadOption
- type Resolver
- type ServerVersion
Constants ¶
const ( AnnotationProvenanceFile = "kubecfg.github.com/provenance-file" AnnotationProvenancePath = "kubecfg.github.com/provenance-path" )
const ( OCIBundleBodyMediaType = "application/vnd.kubecfg.bundle.tar+gzip" OCIBundleDocsMediaType = "application/vnd.kubecfg.bundle.docs.tar+gzip" OCIBundleConfigMediaType = "application/vnd.kubecfg.bundle.config.v1+json" )
Variables ¶
var (
ErrCacheNotFound = errors.New("not found")
)
Error Constants
Functions ¶
func ClientForResource ¶ added in v0.5.0
func ClientForResource(client dynamic.Interface, mapper meta.RESTMapper, obj runtime.Object, defNs string) (dynamic.ResourceInterface, error)
ClientForResource returns the ResourceClient for a given object
func CompactDecodeObject ¶ added in v0.23.0
CompactDecodeObject does the reverse of CompactEncodeObject.
func CompactEncodeObject ¶ added in v0.23.0
CompactEncodeObject returns a compact string representation (json->gzip->base64) of an object, intended for use in last-applied-configuration annotation.
func DeleteMetaDataAnnotation ¶ added in v0.23.0
DeleteMetaDataAnnotation removes an annotation value
func DeleteMetaDataLabel ¶ added in v0.23.0
DeleteMetaDataLabel removes a label value
func DependencyOrder ¶ added in v0.2.0
func DependencyOrder(disco discovery.OpenAPISchemaInterface, mapper meta.RESTMapper, 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 MakeUniversalImporter ¶ added in v0.8.0
MakeUniversalImporter creates an importer that handles resolving imports from the filesystem and HTTP/S.
In addition to the standard importer, supports:
- URLs in import statements
- URLs in library search paths
- importing binary files (for local files and URLs)
A real-world example:
- You have https://raw.githubusercontent.com/ksonnet/ksonnet-lib/master in your search URLs.
- You evaluate a local file which calls `import "ksonnet.beta.2/k.libsonnet"`.
- If the `ksonnet.beta.2/k.libsonnet“ is not located in the current working directory, an attempt will be made to follow the search path, i.e. to download https://raw.githubusercontent.com/ksonnet/ksonnet-lib/master/ksonnet.beta.2/k.libsonnet.
- Since the downloaded `k.libsonnet“ file turn in contains `import "k8s.libsonnet"`, the import will be resolved as https://raw.githubusercontent.com/ksonnet/ksonnet-lib/master/ksonnet.beta.2/k8s.libsonnet and downloaded from that location.
func MaybeMarkStale ¶ added in v0.23.0
func MaybeMarkStale(d discovery.DiscoveryInterface)
MaybeMarkStale calls MarkStale on the discovery client, if the client is a memcachedClient.
func NewMemcachedDiscoveryClient ¶
func NewMemcachedDiscoveryClient(delegate discovery.DiscoveryInterface) discovery.CachedDiscoveryInterface
NewmemcachedDiscoveryClient creates a new CachedDiscoveryInterface which caches discovery information in memory and will stay up-to-date if Invalidate is called with regularity.
NOTE: The client will NOT resort to live lookups on cache misses.
func NewUnstructuredObject ¶ added in v0.34.3
func NewUnstructuredObject(o map[string]interface{}) (*unstructured.Unstructured, error)
NewUnstructuredObject returns a new unstructured.Unstructured object from a raw json object expressed as an untyped tree It returns an error if the object doesn't appear to be a valid k8s object. If the object is a k8s List object, the validation is performed opn the list items recursively.
func Read ¶
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
RegisterNativeFuncs adds kubecfg's native jsonnet functions to provided VM
func RemoveDuplicates ¶ added in v0.29.2
func RemoveDuplicates(objs []*unstructured.Unstructured) ([]*unstructured.Unstructured, error)
RemoveDuplicates returns error if the provided object slice contains multiple objects sharing the same version/kind/namespace/name combination that are not literal matches.
func ResourceNameFor ¶ added in v0.5.0
func ResourceNameFor(mapper meta.RESTMapper, o runtime.Object) string
ResourceNameFor returns a lowercase plural form of a type, for human messages. Returns lowercased kind if discovery lookup fails.
func SearchUp ¶ added in v0.30.0
SearchUp finds fileName somewhere in directory of relativeTo or in any of its parent directories.
func SetMetaDataAnnotation ¶ added in v0.5.0
SetMetaDataAnnotation sets an annotation value
func SetMetaDataLabel ¶ added in v0.9.0
SetMetaDataLabel 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 ArrayReader ¶ added in v0.27.0
type ArrayReader struct {
// contains filtered or unexported fields
}
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
ParseImageName parses a docker image into an ImageName struct.
func (ImageName) RegistryRepoName ¶ added in v0.3.0
RegistryRepoName returns the "repository" as used in the registry URL
func (ImageName) RegistryURL ¶ added in v0.3.0
RegistryURL returns the deduced base URL of the registry for this image
type OCIBundle ¶ added in v0.29.0
type OCIBundle struct {
// contains filtered or unexported fields
}
func NewOCIBundle ¶ added in v0.29.0
func NewOCIBundle(manifest ocispec.Manifest, config OCIBundleConfig, r io.ReadCloser) (*OCIBundle, error)
type OCIBundleConfig ¶ added in v0.29.0
type OCIBundleConfig struct { Entrypoint string `json:"entrypoint"` Metadata json.RawMessage `json:"metadata,omitempty"` }
type OpenAPISchema ¶ added in v0.9.0
type OpenAPISchema struct {
// contains filtered or unexported fields
}
OpenAPISchema represents an OpenAPI schema for a given GroupVersionKind.
func NewOpenAPISchemaFor ¶ added in v0.9.0
func NewOpenAPISchemaFor(delegate discovery.OpenAPISchemaInterface, gvk schema.GroupVersionKind) (*OpenAPISchema, error)
NewOpenAPISchemaFor returns the OpenAPISchema object ready to validate objects of given GroupVersion
func (*OpenAPISchema) Validate ¶ added in v0.9.0
func (s *OpenAPISchema) Validate(obj *unstructured.Unstructured) []error
Validate is the primary entrypoint into this class
type ReadOption ¶ added in v0.26.0
type ReadOption = acquire.ReadOption
breaks import cycle
func WithExpr ¶ added in v0.29.0
func WithExpr(expr string) ReadOption
func WithOverlayCode ¶ added in v0.29.2
func WithOverlayCode(overlayCode string) ReadOption
func WithOverlayURL ¶ added in v0.29.2
func WithOverlayURL(overlayURL string) ReadOption
func WithProvenance ¶ added in v0.26.0
func WithProvenance(show bool) ReadOption
func WithReadTwice ¶ added in v0.27.0
func WithReadTwice(twice bool) ReadOption
type Resolver ¶ added in v0.3.0
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
NewRegistryResolver returns a resolver that looks up a docker registry to resolve digests
type ServerVersion ¶ added in v0.4.0
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 GetDefaultVersion ¶ added in v0.9.0
func GetDefaultVersion() ServerVersion
GetDefaultVersion returns a default server version. This value will be updated periodically to match a current/popular version corresponding to the age of this code Current default version: 1.8
func ParseVersion ¶ added in v0.4.0
func ParseVersion(v *version.Info) (ServerVersion, 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