Documentation ¶
Index ¶
- Constants
- Variables
- func KubeShortForm(resource string) string
- func ObjectPath(obj KubeObject) (string, error)
- type Deployable
- type Deployment
- func (d *Deployment) Add(obj KubeObject) error
- func (d *Deployment) AddDeployment(deployment Deployment) (err error)
- func (d *Deployment) Diff(other *Deployment) string
- func (d *Deployment) Equal(other *Deployment) bool
- func (d *Deployment) Get(name string) (KubeObject, error)
- func (d Deployment) Len() int
- func (d Deployment) Objects() []KubeObject
- func (d Deployment) ObjectsOfVersionKind(version, kind string) (objs []KubeObject)
- func (d *Deployment) PathDiff(other *Deployment) (added, removed, modified []string)
- func (d *Deployment) String() string
- type DiffStat
- type KubeCluster
- type KubeObject
Constants ¶
const DefaultContext = ""
DefaultContext is the current kubectl context and is represented with an empty string.
Variables ¶
var ( // ErrorConflict is returned when an object with an identical path already exists in the Deployment. ErrorConflict = errors.New("name/namespace combination already exists for type") )
Functions ¶
func KubeShortForm ¶ added in v1.0.0
func ObjectPath ¶ added in v1.0.0
func ObjectPath(obj KubeObject) (string, error)
ObjectPath returns the full path of an object. This uses the format "<apiVersion>/namespaces/<namespace>/<kind>/<name>"
Types ¶
type Deployable ¶
type Deployable interface { // Deployment creates a new Deployment based on the types current state. Errors are returned if not possible. Deployment() (*Deployment, error) // Images returns the images required for deployment Images() []*image.Image }
A Deployable can produce a Deployment
type Deployment ¶
type Deployment struct {
// contains filtered or unexported fields
}
A Deployment is a representation of a Kubernetes cluster's object registry. It can be used to specify objects to be deployed and is how the current state of a deployment is returned. The key of objects is formed by "<apiVersion>/namespaces/<namespace>/<kind>/<name>"
func DeploymentFromDocMap ¶ added in v1.0.0
func DeploymentFromDocMap(docs map[string]*pb.Document) (deploy *Deployment, err error)
DeploymentFromDocMap produces a new Deployment from a map of Documents.
func (*Deployment) Add ¶
func (d *Deployment) Add(obj KubeObject) error
Add inserts an object into a deployment. The object must be a valid Kubernetes object or it will fail. There can only be a single object of the same name, namespace, and type. Objects are deep-copied into the Deployment.
func (*Deployment) AddDeployment ¶
func (d *Deployment) AddDeployment(deployment Deployment) (err error)
AddDeployment inserts the contents of one Deployment into another.
func (*Deployment) Diff ¶
func (d *Deployment) Diff(other *Deployment) string
Diff returns the difference between the textual representation of two deployments
func (*Deployment) Equal ¶
func (d *Deployment) Equal(other *Deployment) bool
Equal performs a deep equality check between Deployments. Internal ordering is ignored.
func (*Deployment) Get ¶ added in v1.0.0
func (d *Deployment) Get(name string) (KubeObject, error)
Get returns the object with the given path from the Deployment. Error is returned if object does not exist.
func (Deployment) Len ¶
func (d Deployment) Len() int
Len returns the number of objects in a Deployment.
func (Deployment) Objects ¶
func (d Deployment) Objects() []KubeObject
Objects returns the contents of a Deployment. No ordering guarantees are given.
func (Deployment) ObjectsOfVersionKind ¶ added in v1.0.0
func (d Deployment) ObjectsOfVersionKind(version, kind string) (objs []KubeObject)
ObjectsOfVersionKind returns all objects matching the given Version and Kind. No ordering guarantees are given. If an empty string is given for either selector, all options for that selector will be returned.
func (*Deployment) PathDiff ¶ added in v1.0.0
func (d *Deployment) PathDiff(other *Deployment) (added, removed, modified []string)
PathDiff returns the list of the paths of objects. Currently doesn't detect modifications
func (*Deployment) String ¶
func (d *Deployment) String() string
String returns a JSON representation of a Deployment
type DiffStat ¶ added in v1.0.0
type DiffStat struct { IndexNew []string IndexModified []string IndexDeleted []string ClusterNew []string ClusterModified []string ClusterDeleted []string }
func Stat ¶ added in v1.0.0
func Stat(index, head, cluster *Deployment) DiffStat
Stat returns change information about a deployment.
type KubeCluster ¶
KubeCluster is able to deploy to Kubernetes clusters. This is a very simple implementation with no error recovery.
func NewKubeClusterFromContext ¶
func NewKubeClusterFromContext(name string) (*KubeCluster, error)
NewKubeClusterFromContext creates a KubeCluster using a Kubernetes client with the configuration of the given context. If the context name is empty, the default context will be used.
func (*KubeCluster) Context ¶
func (c *KubeCluster) Context() string
Context returns the kubectl context being used
func (*KubeCluster) Deploy ¶
func (c *KubeCluster) Deploy(dep *Deployment, update, deleteModifiedPods bool) error
Deploy creates/updates the Deployment's objects on the Kubernetes cluster. Currently no error recovery is implemented; if there is an error the deployment process will immediately halt and return the error. If update is not set, will error if objects exist. If deleteModifiedPods is set, pods of modified RCs will be deleted.
func (*KubeCluster) Deployment ¶ added in v1.0.0
func (c *KubeCluster) Deployment() (*Deployment, error)
func (*KubeCluster) Get ¶ added in v1.0.0
func (c *KubeCluster) Get(kind, namespace, name string, export bool) (KubeObject, error)
Get retrieves an objects from a cluster using it's namespace name and API version.
type KubeObject ¶
type KubeObject interface { meta.ObjectMetaAccessor runtime.Object }
A KubeObject is an alias for Kubernetes objects.
func AsKubeObject ¶ added in v1.0.0
func AsKubeObject(runtimeObj runtime.Object) (KubeObject, error)
asKubeObject attempts use the object as a KubeObject. It will return an error if not possible.
func BaseObject ¶ added in v1.0.0
func BaseObject(kind string) KubeObject
BaseObject returns a Kubernetes object of the given kind to be used to populate. Nil is returned if the Kind is unknown
func KubeObjectFromDocument ¶ added in v1.0.0
func KubeObjectFromDocument(path string, doc *pb.Document) (KubeObject, error)