guber

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

README

GoReportCard Widget GoDoc Widget Travis Widget Coverage Status Widget

Guber

A minimal Kubernetes client for Go.

License

   This software is licensed under the Apache License, version 2 ("ALv2"), quoted below.

   Copyright 2016 Qbox, Inc., a Delaware corporation. All rights reserved.

   Licensed under the Apache License, Version 2.0 (the "License"); you may not
   use this file except in compliance with the License. You may obtain a copy of
   the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   License for the specific language governing permissions and limitations under
   the License.
   

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log *logger

Functions

This section is empty.

Types

type AwsElasticBlockStore

type AwsElasticBlockStore struct {
	VolumeID string `json:"volumeID"`
	FSType   string `json:"fsType"`
}

Pod ==============================================================================

type Client

type Client interface {
	// Namespaces returns a NamespaceCollection.
	Namespaces() NamespaceCollection

	// Events returns a EventCollection.
	Events(namespace string) EventCollection

	// Secrets returns a SecretCollection.
	Secrets(namespace string) SecretCollection

	// Services returns a ServiceCollection.
	Services(namespace string) ServiceCollection

	// ReplicationControllers returns a ReplicationControllerCollection.
	ReplicationControllers(namespace string) ReplicationControllerCollection

	// Pods returns a PodCollection.
	Pods(namespace string) PodCollection

	// Nodes returns a NodeCollection.
	Nodes() NodeCollection
}

Client describes behavior of the root Kubernetes client object.

func NewClient

func NewClient(host string, user string, pass string, insecureHTTPS bool) Client

NewClient creates a new Client.

type Collection

type Collection interface {
	Meta() *CollectionMeta
}

Collection defines an interface for collections of Kubernetes resources.

type CollectionMeta

type CollectionMeta struct {
	DomainName string // empty unless something like ThirdPartyResource
	APIGroup   string // usually "api"
	APIVersion string // usually "v1"
	APIName    string // e.g. "replicationcontrollers"
	Kind       string // e.g. "ReplicationController"
}

CollectionMeta holds info required by all Kubernetes Resources defined.

type Container

type Container struct {
	Name            string           `json:"name"`
	Image           string           `json:"image"`
	Command         []string         `json:"command"`
	Resources       *Resources       `json:"resources"`
	Ports           []*ContainerPort `json:"ports"`
	VolumeMounts    []*VolumeMount   `json:"volumeMounts"`
	Env             []*EnvVar        `json:"env"`
	SecurityContext *SecurityContext `json:"securityContext"`
	ImagePullPolicy string           `json:"imagePullPolicy"`
}

type ContainerPort

type ContainerPort struct {
	Name          string `json:"name,omitempty"`
	ContainerPort int    `json:"containerPort"`
	Protocol      string `json:"protocol,omitempty"`
}

type ContainerState

type ContainerState struct {
	Running    *ContainerStateRunning    `json:"running"`
	Terminated *ContainerStateTerminated `json:"terminated"`
}

type ContainerStateRunning

type ContainerStateRunning struct {
	StartedAt string `json:"startedAt"` // TODO should be time type
}

type ContainerStateTerminated

type ContainerStateTerminated struct {
	ExitCode   int    `json:"exitcode"`
	StartedAt  string `json:"startedAt"`  // TODO should be time type
	FinishedAt string `json:"finishedAt"` // TODO should be time type
	Reason     string `json:"reason"`
}

type ContainerStatus

type ContainerStatus struct {
	ContainerID  string          `json:"containerID"`
	Image        string          `json:"image"`
	ImageID      string          `json:"imageID"`
	Name         string          `json:"name"`
	Ready        bool            `json:"ready"`
	RestartCount int             `json:"restartCount"`
	State        *ContainerState `json:"state"`
	LastState    *ContainerState `json:"state"`
}

type Entity

type Entity interface {
}

type EnvVar

type EnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Error404

type Error404 struct{}

func (*Error404) Error

func (e *Error404) Error() string

type Event

type Event struct {
	*ResourceDefinition

	Metadata *Metadata `json:"metadata"`
	Message  string    `json:"message"`
	Count    int       `json:"count"`
	Source   *Source   `json:"source"`
	// contains filtered or unexported fields
}

func (*Event) Delete

func (r *Event) Delete() error

func (*Event) Reload

func (r *Event) Reload() (*Event, error)

func (*Event) Save

func (r *Event) Save() error

type EventCollection

type EventCollection interface {
	Meta() *CollectionMeta
	New() *Event
	Create(e *Event) (*Event, error)
	Query(q *QueryParams) (*EventList, error)
	List() (*EventList, error)
	Get(name string) (*Event, error)
	Update(name string, r *Event) (*Event, error)
	Delete(name string) error
}

EventCollection is a Collection interface for Events.

type EventList

type EventList struct {
	Items []*Event `json:"items"`
}

type Events

type Events struct {
	Namespace string
	// contains filtered or unexported fields
}

Events implmenets EventCollection.

func (*Events) Create

func (c *Events) Create(e *Event) (*Event, error)

func (*Events) Delete

func (c *Events) Delete(name string) error

func (*Events) Get

func (c *Events) Get(name string) (*Event, error)

func (*Events) List

func (c *Events) List() (*EventList, error)

func (*Events) Meta

func (c *Events) Meta() *CollectionMeta

Meta implements the Collection interface.

func (*Events) New

func (c *Events) New() *Event

func (*Events) Query

func (c *Events) Query(q *QueryParams) (*EventList, error)

func (*Events) Update

func (c *Events) Update(name string, r *Event) (*Event, error)

type HeapsterStatMetric

type HeapsterStatMetric struct {
	Average    int `json:"average"`
	Percentile int `json:"percentile"`
	Max        int `json:"max"`
}

type HeapsterStatPeriods

type HeapsterStatPeriods struct {
	Minute *HeapsterStatMetric `json:"minute"`
	Hour   *HeapsterStatMetric `json:"hour"`
	Day    *HeapsterStatMetric `json:"day"`
}

type HeapsterStats

type HeapsterStats struct {
	Uptime int `json:"uptime"`
	Stats  map[string]*HeapsterStatPeriods
}

type ImagePullSecret

type ImagePullSecret struct {
	Name string `json:"name"`
}

type Metadata

type Metadata struct {
	Name              string            `json:"name"`
	Namespace         string            `json:"namespace"`
	Labels            map[string]string `json:"labels,omitempty"`
	CreationTimestamp string            `json:"creationTimestamp,omitempty"`
}

type Namespace

type Namespace struct {
	*ResourceDefinition

	Metadata *Metadata `json:"metadata"`
	// contains filtered or unexported fields
}

Namespace ==============================================================================

func (*Namespace) Delete

func (r *Namespace) Delete() error

func (*Namespace) Reload

func (r *Namespace) Reload() (*Namespace, error)

func (*Namespace) Save

func (r *Namespace) Save() error

type NamespaceCollection

type NamespaceCollection interface {
	Meta() *CollectionMeta
	New() *Namespace
	Create(e *Namespace) (*Namespace, error)
	Query(q *QueryParams) (*NamespaceList, error)
	List() (*NamespaceList, error)
	Get(name string) (*Namespace, error)
	Update(name string, r *Namespace) (*Namespace, error)
	Delete(name string) error
}

NamespaceCollection is a Collection interface for Namespaces.

type NamespaceList

type NamespaceList struct {
	Items []*Namespace `json:"items"`
}

type Namespaces

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

Namespaces implements NamespaceCollection.

func (*Namespaces) Create

func (c *Namespaces) Create(e *Namespace) (*Namespace, error)

func (*Namespaces) Delete

func (c *Namespaces) Delete(name string) error

func (*Namespaces) Get

func (c *Namespaces) Get(name string) (*Namespace, error)

func (*Namespaces) List

func (c *Namespaces) List() (*NamespaceList, error)

func (*Namespaces) Meta

func (c *Namespaces) Meta() *CollectionMeta

Meta implements the Collection interface.

func (*Namespaces) New

func (c *Namespaces) New() *Namespace

func (*Namespaces) Query

func (c *Namespaces) Query(q *QueryParams) (*NamespaceList, error)

func (*Namespaces) Update

func (c *Namespaces) Update(name string, r *Namespace) (*Namespace, error)

type Node

type Node struct {
	*ResourceDefinition

	Metadata *Metadata   `json:"metadata"`
	Spec     *NodeSpec   `json:"spec"`
	Status   *NodeStatus `json:"status"`
	// contains filtered or unexported fields
}

func (*Node) Delete

func (r *Node) Delete() error

func (*Node) ExternalIP

func (r *Node) ExternalIP() (ip string)

func (*Node) HeapsterStats

func (r *Node) HeapsterStats() (*HeapsterStats, error)

func (*Node) IsOutOfDisk

func (r *Node) IsOutOfDisk() bool

func (*Node) Reload

func (r *Node) Reload() (*Node, error)

func (*Node) Save

func (r *Node) Save() error

type NodeAddress

type NodeAddress struct {
	Type    string `json:"type"`
	Address string `json:"address"`
}

type NodeCollection

type NodeCollection interface {
	Meta() *CollectionMeta
	New() *Node
	Create(e *Node) (*Node, error)
	Query(q *QueryParams) (*NodeList, error)
	List() (*NodeList, error)
	Get(name string) (*Node, error)
	Update(name string, r *Node) (*Node, error)
	Delete(name string) error
}

NodeCollection is a Collection interface for Nodes.

type NodeList

type NodeList struct {
	Items []*Node `json:"items"`
}

type NodeSpec

type NodeSpec struct {
	ExternalID string `json:"externalID"`
}

Node ==============================================================================

type NodeStatus

type NodeStatus struct {
	Capacity   *NodeStatusCapacity    `json:"capacity"`
	Conditions []*NodeStatusCondition `json:"conditions"`
	Addresses  []*NodeAddress         `json:"addresses"`
}

type NodeStatusCapacity

type NodeStatusCapacity struct {
	CPU    string `json:"cpu"`
	Memory string `json:"memory"`
}

type NodeStatusCondition

type NodeStatusCondition struct {
	Type   string `json:"type"`
	Status string `json:"status"`
}

type Nodes

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

Nodes implmenets NodeCollection.

func (*Nodes) Create

func (c *Nodes) Create(e *Node) (*Node, error)

func (*Nodes) Delete

func (c *Nodes) Delete(name string) error

func (*Nodes) Get

func (c *Nodes) Get(name string) (*Node, error)

func (*Nodes) List

func (c *Nodes) List() (*NodeList, error)

func (*Nodes) Meta

func (c *Nodes) Meta() *CollectionMeta

Meta implements the Collection interface.

func (*Nodes) New

func (c *Nodes) New() *Node

func (*Nodes) Query

func (c *Nodes) Query(q *QueryParams) (*NodeList, error)

func (*Nodes) Update

func (c *Nodes) Update(name string, r *Node) (*Node, error)

type Pod

type Pod struct {
	*ResourceDefinition

	Metadata *Metadata  `json:"metadata"`
	Spec     *PodSpec   `json:"spec"`
	Status   *PodStatus `json:"status"`
	// contains filtered or unexported fields
}

func (*Pod) Delete

func (r *Pod) Delete() error

func (*Pod) HeapsterStats

func (r *Pod) HeapsterStats() (*HeapsterStats, error)

func (*Pod) IsReady

func (r *Pod) IsReady() bool

func (*Pod) Log

func (r *Pod) Log(container string) (string, error)

func (*Pod) Reload

func (r *Pod) Reload() (*Pod, error)

func (*Pod) Save

func (r *Pod) Save() error

type PodCollection

type PodCollection interface {
	Meta() *CollectionMeta
	New() *Pod
	Create(e *Pod) (*Pod, error)
	Query(q *QueryParams) (*PodList, error)
	List() (*PodList, error)
	Get(name string) (*Pod, error)
	Update(name string, r *Pod) (*Pod, error)
	Delete(name string) error
}

PodCollection is a Collection interface for Pods.

type PodList

type PodList struct {
	Items []*Pod `json:"items"`
}

type PodSpec

type PodSpec struct {
	Volumes                       []*Volume          `json:"volumes"`
	Containers                    []*Container       `json:"containers"`
	ImagePullSecrets              []*ImagePullSecret `json:"imagePullSecrets"`
	TerminationGracePeriodSeconds int                `json:"terminationGracePeriodSeconds"`
	RestartPolicy                 string             `json:"restartPolicy"`
}

type PodStatus

type PodStatus struct {
	Phase             string                `json:"phase"`
	Conditions        []*PodStatusCondition `json:"conditions"`
	ContainerStatuses []*ContainerStatus    `json:"containerStatuses"`
}

type PodStatusCondition

type PodStatusCondition struct {
	Type   string `json:"type"`
	Status string `json:"status"`
}

type PodTemplate

type PodTemplate struct {
	Metadata *Metadata `json:"metadata"`
	Spec     *PodSpec  `json:"spec"`
}

ReplicationController ==============================================================================

type Pods

type Pods struct {
	Namespace string
	// contains filtered or unexported fields
}

Pods implmenets PodCollection.

func (*Pods) Create

func (c *Pods) Create(e *Pod) (*Pod, error)

func (*Pods) Delete

func (c *Pods) Delete(name string) error

func (*Pods) Get

func (c *Pods) Get(name string) (*Pod, error)

func (*Pods) List

func (c *Pods) List() (*PodList, error)

func (*Pods) Meta

func (c *Pods) Meta() *CollectionMeta

Meta implements the Collection interface.

func (*Pods) New

func (c *Pods) New() *Pod

func (*Pods) Query

func (c *Pods) Query(q *QueryParams) (*PodList, error)

func (*Pods) Update

func (c *Pods) Update(name string, r *Pod) (*Pod, error)

type QueryParams

type QueryParams struct {
	LabelSelector string
	FieldSelector string
}

TODO not sure if this should be in the types file.. related to queries, but is a Kube-specific thing

type RealClient

type RealClient struct {
	Host     string
	Username string
	Password string
	// contains filtered or unexported fields
}

RealClient implements Client.

func (*RealClient) Delete

func (c *RealClient) Delete() *Request

Delete performs a DELETE request against a Client object.

func (*RealClient) Events

func (c *RealClient) Events(namespace string) EventCollection

Events returns a Events object from a Client object.

func (*RealClient) Get

func (c *RealClient) Get() *Request

Get performs a GET request against a Client object.

func (*RealClient) Namespaces

func (c *RealClient) Namespaces() NamespaceCollection

Namespaces returns a Namespaces object from a Client object.

func (*RealClient) Nodes

func (c *RealClient) Nodes() NodeCollection

Namespaces returns a Nodes object from a Client object.

func (*RealClient) Patch

func (c *RealClient) Patch() *Request

Patch performs a PATCH request against a Client object.

func (*RealClient) Pods

func (c *RealClient) Pods(namespace string) PodCollection

Pods returns a Pods object from a Client object.

func (*RealClient) Post

func (c *RealClient) Post() *Request

Post performs a POST request against a Client object.

func (*RealClient) ReplicationControllers

func (c *RealClient) ReplicationControllers(namespace string) ReplicationControllerCollection

ReplicationControllers returns a ReplicationControllers object from a Client object.

func (*RealClient) Secrets

func (c *RealClient) Secrets(namespace string) SecretCollection

Secrets returns a Secrets object from a Client object.

func (*RealClient) Services

func (c *RealClient) Services(namespace string) ServiceCollection

Services returns a Services object from a Client object.

type ReplicationController

type ReplicationController struct {
	*ResourceDefinition

	Metadata *Metadata                    `json:"metadata"`
	Spec     *ReplicationControllerSpec   `json:"spec"`
	Status   *ReplicationControllerStatus `json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*ReplicationController) Delete

func (r *ReplicationController) Delete() error

func (*ReplicationController) Reload

func (*ReplicationController) Save

func (r *ReplicationController) Save() error

type ReplicationControllerCollection

type ReplicationControllerCollection interface {
	Meta() *CollectionMeta
	New() *ReplicationController
	Create(e *ReplicationController) (*ReplicationController, error)
	Query(q *QueryParams) (*ReplicationControllerList, error)
	List() (*ReplicationControllerList, error)
	Get(name string) (*ReplicationController, error)
	Update(name string, r *ReplicationController) (*ReplicationController, error)
	Delete(name string) error
}

ReplicationControllerCollection is a Collection interface for ReplicationControllers.

type ReplicationControllerList

type ReplicationControllerList struct {
	Items []*ReplicationController `json:"items"`
}

type ReplicationControllerSpec

type ReplicationControllerSpec struct {
	Selector map[string]string `json:"selector"`
	Replicas int               `json:"replicas"`
	Template *PodTemplate      `json:"template"`
}

type ReplicationControllerStatus

type ReplicationControllerStatus struct {
	Replicas int `json:"replicas"`
}

type ReplicationControllers

type ReplicationControllers struct {
	Namespace string
	// contains filtered or unexported fields
}

ReplicationControllers implmenets ReplicationControllerCollection.

func (*ReplicationControllers) Create

func (*ReplicationControllers) Delete

func (c *ReplicationControllers) Delete(name string) error

func (*ReplicationControllers) Get

func (*ReplicationControllers) List

func (*ReplicationControllers) Meta

Meta implements the Collection interface.

func (*ReplicationControllers) New

func (*ReplicationControllers) Query

func (*ReplicationControllers) Update

type Request

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

func (*Request) Body

func (r *Request) Body() (string, error)

func (*Request) Collection

func (r *Request) Collection(c Collection) *Request

func (*Request) Do

func (r *Request) Do() *Request

func (*Request) Entity

func (r *Request) Entity(e Entity) *Request

func (*Request) Into

func (r *Request) Into(e Entity) error

The exit point for a Request (where error is pooped out)

func (*Request) Name

func (r *Request) Name(name string) *Request

func (*Request) Namespace

func (r *Request) Namespace(namespace string) *Request

func (*Request) Path

func (r *Request) Path(path string) *Request

func (*Request) Query

func (r *Request) Query(q *QueryParams) *Request

func (*Request) String

func (r *Request) String() string

Implement Stringer interface

type ResourceDefinition

type ResourceDefinition struct {
	Kind       string `json:"kind"`
	ApiVersion string `json:"apiVersion"`
}

Common ==============================================================================

type ResourceValues

type ResourceValues struct {
	Memory string `json:"memory,omitempty"`
	CPU    string `json:"cpu,omitempty"`
}

type Resources

type Resources struct {
	Limits   *ResourceValues `json:"limits"`
	Requests *ResourceValues `json:"requests"`
}

type Secret

type Secret struct {
	*ResourceDefinition

	Metadata *Metadata         `json:"metadata"`
	Type     string            `json:"type"`
	Data     map[string]string `json:"data"`
	// contains filtered or unexported fields
}

Secret ==============================================================================

func (*Secret) Delete

func (r *Secret) Delete() error

func (*Secret) Reload

func (r *Secret) Reload() (*Secret, error)

func (*Secret) Save

func (r *Secret) Save() error

type SecretCollection

type SecretCollection interface {
	Meta() *CollectionMeta
	New() *Secret
	Create(e *Secret) (*Secret, error)
	Query(q *QueryParams) (*SecretList, error)
	List() (*SecretList, error)
	Get(name string) (*Secret, error)
	Update(name string, r *Secret) (*Secret, error)
	Delete(name string) error
}

SecretCollection is a Collection interface for Secrets.

type SecretList

type SecretList struct {
	Items []*Secret `json:"items"`
}

type Secrets

type Secrets struct {
	Namespace string
	// contains filtered or unexported fields
}

Secrets implmenets SecretCollection.

func (*Secrets) Create

func (c *Secrets) Create(e *Secret) (*Secret, error)

func (*Secrets) Delete

func (c *Secrets) Delete(name string) error

func (*Secrets) Get

func (c *Secrets) Get(name string) (*Secret, error)

func (*Secrets) List

func (c *Secrets) List() (*SecretList, error)

func (*Secrets) Meta

func (c *Secrets) Meta() *CollectionMeta

Meta implements the Collection interface.

func (*Secrets) New

func (c *Secrets) New() *Secret

func (*Secrets) Query

func (c *Secrets) Query(q *QueryParams) (*SecretList, error)

func (*Secrets) Update

func (c *Secrets) Update(name string, r *Secret) (*Secret, error)

type SecurityContext

type SecurityContext struct {
	Privileged bool `json:"privileged"`
}

type Service

type Service struct {
	*ResourceDefinition

	Metadata *Metadata    `json:"metadata"`
	Spec     *ServiceSpec `json:"spec"`
	// contains filtered or unexported fields
}

func (*Service) Delete

func (r *Service) Delete() error

func (*Service) Reload

func (r *Service) Reload() (*Service, error)

func (*Service) Save

func (r *Service) Save() error

type ServiceCollection

type ServiceCollection interface {
	Meta() *CollectionMeta
	New() *Service
	Create(e *Service) (*Service, error)
	Query(q *QueryParams) (*ServiceList, error)
	List() (*ServiceList, error)
	Get(name string) (*Service, error)
	Update(name string, r *Service) (*Service, error)
	Delete(name string) error
}

ServiceCollection is a Collection interface for Services.

type ServiceList

type ServiceList struct {
	Items []*Service `json:"items"`
}

type ServicePort

type ServicePort struct {
	Name       string `json:"name"`
	Port       int    `json:"port"`
	Protocol   string `json:"protocol,omitempty"`
	NodePort   int    `json:"nodePort,omitempty"`
	TargetPort int    `json:"targetPort,omitempty"`
}

Service ==============================================================================

type ServiceSpec

type ServiceSpec struct {
	Type     string            `json:"type,omitempty"`
	Selector map[string]string `json:"selector"`
	Ports    []*ServicePort    `json:"ports"`

	ClusterIP string `json:"clusterIP,omitempty"`
}

type Services

type Services struct {
	Namespace string
	// contains filtered or unexported fields
}

Services implmenets ServiceCollection.

func (*Services) Create

func (c *Services) Create(e *Service) (*Service, error)

func (*Services) Delete

func (c *Services) Delete(name string) error

func (*Services) Get

func (c *Services) Get(name string) (*Service, error)

func (*Services) List

func (c *Services) List() (*ServiceList, error)

func (*Services) Meta

func (c *Services) Meta() *CollectionMeta

Meta implements the Collection interface.

func (*Services) New

func (c *Services) New() *Service

func (*Services) Query

func (c *Services) Query(q *QueryParams) (*ServiceList, error)

func (*Services) Update

func (c *Services) Update(name string, r *Service) (*Service, error)

type Source

type Source struct {
	Host string `json:"host"`
}

Event ==============================================================================

type Volume

type Volume struct {
	Name                 string                `json:"name"`
	AwsElasticBlockStore *AwsElasticBlockStore `json:"awsElasticBlockStore"`
}

type VolumeMount

type VolumeMount struct {
	Name      string `json:"name"`
	MountPath string `json:"mountPath"`
}

Jump to

Keyboard shortcuts

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