api-machinery

command module
v0.0.0-...-f7aa2fe Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

API machinery

Rest Mappping

Map a GroupVersionKind to HTTP REST endpoint in Kubernetes API Server and vice versa.

For example:

# /api/v1/namespaces/default/pods

# KindFor:
# -> GroupVersionKind: v1.Pod

# -> runtime.Object: &v1.Pod{}

Scheme

Scheme is a registry maintaining a mapping of Kinds (strings) to Types (structs).

Schemes are dynamic - new types can be appended.

Let say we have an Go Struct for a CRD object:

type Foo struct {
    metav1.TypeMeta   `json:",inline"`
    metav1.ObjectMeta `json:"metadata,omitempty"`

    Spec   FooSpec   `json:"spec"`
    Status FooStatus `json:"status"`
}

We can register the CRD object to the scheme by:

scheme := runtime.NewScheme()
scheme.AddKnownTypes(schema.GroupVersion{
    Group:   "example.com",
    Version: "v1",
}, &Foo{})

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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