common

package
v1.1.0-beta1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ResourceKindReplicaSet            = "replicaset"
	ResourceKindService               = "service"
	ResourceKindDeployment            = "deployment"
	ResourceKindPod                   = "pod"
	ResourceKindEvent                 = "event"
	ResourceKindReplicationController = "replicationcontroller"
	ResourceKindDaemonSet             = "daemonset"
)

List of all resource kinds supported by the UI.

Variables

This section is empty.

Functions

func FilterNamespacedPodsBySelector

func FilterNamespacedPodsBySelector(pods []api.Pod, namespace string,
	resourceSelector map[string]string) []api.Pod

func FilterPodsByLabelSelector

func FilterPodsByLabelSelector(pods []api.Pod, labelSelector *unversioned.LabelSelector) []api.Pod

func FilterPodsBySelector

func FilterPodsBySelector(pods []api.Pod, resourceSelector map[string]string) []api.Pod

Returns pods targeted by given selector.

func GetContainerImages

func GetContainerImages(podTemplate *api.PodSpec) []string

GetContainerImages returns container image strings from the given pod spec.

func IsLabelSelectorMatching

func IsLabelSelectorMatching(selector map[string]string,
	labelSelector *unversioned.LabelSelector) bool

Returns true when a resrouce (Service / Pod) with the given selector targets the same Pod (or itself) that a Daemon Set with the given selector.

func IsSelectorMatching

func IsSelectorMatching(labelSelector map[string]string,
	testedObjectLabels map[string]string) bool

IsSelectorMatching returns true when an object with the given selector targets the same Resources (or subset) that the tested object with the given selector.

Types

type DaemonSetListChannel

type DaemonSetListChannel struct {
	List  chan *extensions.DaemonSetList
	Error chan error
}

List and error channels to Nodes.

func GetDaemonSetListChannel

func GetDaemonSetListChannel(client client.DaemonSetsNamespacer, numReads int) DaemonSetListChannel

Returns a pair of channels to a DaemonSet list and errors that both must be read numReads times.

type DeploymentListChannel

type DeploymentListChannel struct {
	List  chan *extensions.DeploymentList
	Error chan error
}

List and error channels to Deployments.

func GetDeploymentListChannel

func GetDeploymentListChannel(client client.DeploymentsNamespacer, numReads int) DeploymentListChannel

Returns a pair of channels to a Deployment list and errors that both must be read numReads times.

type Endpoint

type Endpoint struct {
	// Hostname, either as a domain name or IP address.
	Host string `json:"host"`

	// List of ports opened for this endpoint on the hostname.
	Ports []ServicePort `json:"ports"`
}

Endpoint describes an endpoint that is host and a list of available ports for that host.

func GetExternalEndpoints

func GetExternalEndpoints(resourceSelector map[string]string, allPods []api.Pod,
	service api.Service, nodes []api.Node) []Endpoint

GetExternalEndpoints returns array of external endpoints for resources targeted by given selector.

func GetInternalEndpoint

func GetInternalEndpoint(serviceName, namespace string, ports []api.ServicePort) Endpoint

GetInternalEndpoint returns internal endpoint name for the given service properties, e.g., "my-service.namespace 80/TCP" or "my-service 53/TCP,53/UDP".

type Event

type Event struct {
	ObjectMeta ObjectMeta `json:"objectMeta"`
	TypeMeta   TypeMeta   `json:"typeMeta"`

	// A human-readable description of the status of related object.
	Message string `json:"message"`

	// Component from which the event is generated.
	SourceComponent string `json:"sourceComponent"`

	// Host name on which the event is generated.
	SourceHost string `json:"sourceHost"`

	// Reference to a piece of an object, which triggered an event. For example
	// "spec.containers{name}" refers to container within pod with given name, if no container
	// name is specified, for example "spec.containers[2]", then it refers to container with
	// index 2 in this pod.
	SubObject string `json:"object"`

	// The number of times this event has occurred.
	Count int `json:"count"`

	// The time at which the event was first recorded.
	FirstSeen unversioned.Time `json:"firstSeen"`

	// The time at which the most recent occurrence of this event was recorded.
	LastSeen unversioned.Time `json:"lastSeen"`

	// Short, machine understandable string that gives the reason
	// for this event being generated.
	Reason string `json:"reason"`

	// Event type (at the moment only normal and warning are supported).
	Type string `json:"type"`
}

Event is a single event representation.

type EventList

type EventList struct {
	// Namespace.
	Namespace string `json:"namespace"`

	// List of events from given namespace.
	Events []Event `json:"events"`
}

Events response structure.

type EventListChannel

type EventListChannel struct {
	List  chan *api.EventList
	Error chan error
}

List and error channels to Nodes.

func GetEventListChannel

func GetEventListChannel(client client.EventNamespacer, numReads int) EventListChannel

Returns a pair of channels to an Event list and errors that both must be read numReads times.

func GetNamespacedEventListChannel

func GetNamespacedEventListChannel(client client.EventNamespacer, numReads int,
	namespace string, options api.ListOptions) EventListChannel

type NodeListChannel

type NodeListChannel struct {
	List  chan *api.NodeList
	Error chan error
}

List and error channels to Nodes.

func GetNodeListChannel

func GetNodeListChannel(client client.NodesInterface, numReads int) NodeListChannel

Returns a pair of channels to a Node list and errors that both must be read numReads times.

type ObjectMeta

type ObjectMeta struct {
	// Name is unique within a namespace. Name is primarily intended for creation
	// idempotence and configuration definition.
	Name string `json:"name,omitempty"`

	// Namespace defines the space within which name must be unique. An empty namespace is
	// equivalent to the "default" namespace, but "default" is the canonical representation.
	// Not all objects are required to be scoped to a namespace - the value of this field for
	// those objects will be empty.
	Namespace string `json:"namespace,omitempty"`

	// Labels are key value pairs that may be used to scope and select individual resources.
	// Label keys are of the form:
	//     label-key ::= prefixed-name | name
	//     prefixed-name ::= prefix '/' name
	//     prefix ::= DNS_SUBDOMAIN
	//     name ::= DNS_LABEL
	// The prefix is optional.  If the prefix is not specified, the key is assumed to be private
	// to the user.  Other system components that wish to use labels must specify a prefix.
	Labels map[string]string `json:"labels,omitempty"`

	// Annotations are unstructured key value data stored with a resource that may be set by
	// external tooling. They are not queryable and should be preserved when modifying
	// objects.  Annotation keys have the same formatting restrictions as Label keys. See the
	// comments on Labels for details.
	Annotations map[string]string `json:"annotations,omitempty"`

	// CreationTimestamp is a timestamp representing the server time when this object was
	// created. It is not guaranteed to be set in happens-before order across separate operations.
	// Clients may not set this value. It is represented in RFC3339 form and is in UTC.
	CreationTimestamp unversioned.Time `json:"creationTimestamp,omitempty"`
}

ObjectMeta is metadata about an instance of a resource.

func NewObjectMeta

func NewObjectMeta(k8SObjectMeta api.ObjectMeta) ObjectMeta

Returns internal endpoint name for the given service properties, e.g., NewObjectMeta creates a new instance of ObjectMeta struct based on K8s object meta.

type PodInfo

type PodInfo struct {
	// Number of pods that are created.
	Current int `json:"current"`

	// Number of pods that are desired.
	Desired int `json:"desired"`

	// Number of pods that are currently running.
	Running int `json:"running"`

	// Number of pods that are currently waiting.
	Pending int `json:"pending"`

	// Number of pods that are failed.
	Failed int `json:"failed"`

	// Unique warning messages related to pods in this resource.
	Warnings []Event `json:"warnings"`
}

PodInfo represents aggregate information about controller's pods.

func GetPodInfo

func GetPodInfo(current int, desired int, pods []api.Pod) PodInfo

GetPodInfo returns aggregate information about a group of pods.

type PodListChannel

type PodListChannel struct {
	List  chan *api.PodList
	Error chan error
}

List and error channels to Nodes.

func GetNamespacedPodListChannel

func GetNamespacedPodListChannel(client client.PodsNamespacer, numReads int,
	namespace string, options api.ListOptions) PodListChannel

func GetPodListChannel

func GetPodListChannel(client client.PodsNamespacer, numReads int) PodListChannel

Returns a pair of channels to a Pod list and errors that both must be read numReads times.

type RESTClient

type RESTClient interface {
	Delete() *restclient.Request
}

RESTClient is an interface for REST operations used in this file.

type ReplicaSetListChannel

type ReplicaSetListChannel struct {
	List  chan *extensions.ReplicaSetList
	Error chan error
}

List and error channels to Replica Sets.

func GetReplicaSetListChannel

func GetReplicaSetListChannel(client client.ReplicaSetsNamespacer, numReads int) ReplicaSetListChannel

Returns a pair of channels to a ReplicaSet list and errors that both must be read numReads times.

type ReplicationControllerListChannel

type ReplicationControllerListChannel struct {
	List  chan *api.ReplicationControllerList
	Error chan error
}

List and error channels to Nodes.

func GetReplicationControllerListChannel

func GetReplicationControllerListChannel(client client.ReplicationControllersNamespacer,
	numReads int) ReplicationControllerListChannel

Returns a pair of channels to a Replication Controller list and errors that both must be read numReads times.

type ResourceChannels

type ResourceChannels struct {
	// List and error channels to Replication Controllers.
	ReplicationControllerList ReplicationControllerListChannel

	// List and error channels to Replica Sets.
	ReplicaSetList ReplicaSetListChannel

	// List and error channels to Deployments.
	DeploymentList DeploymentListChannel

	// List and error channels to Daemon Sets.
	DaemonSetList DaemonSetListChannel

	// List and error channels to Services.
	ServiceList ServiceListChannel

	// List and error channels to Pods.
	PodList PodListChannel

	// List and error channels to Events.
	EventList EventListChannel

	// List and error channels to Nodes.
	NodeList NodeListChannel
}

ResourceChannels struct holds channels to resource lists. Each list channel is paired with an error channel which *must* be read sequentially: first read the list channel and then the error channel.

This struct can be used when there are multiple clients that want to process, e.g., a list of pods. With this helper, the list can be read only once from the backend and distributed asynchronously to clients that need it.

When a channel is nil, it means that no resource list is available for getting.

Each channel pair can be read up to N times. N is specified upon creation of the channels.

type ResourceKind

type ResourceKind string

ResourceKind is an unique name for each resource. It can used for API discovery and generic code that does things based on the kind. For example, there may be a generic "deleter" that based on resource kind, name and namespace deletes it.

type ResourceVerber

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

ResourceVerber is a struct responsible for doing common verb operations on resources, like DELETE, PUT, UPDATE.

func NewResourceVerber

func NewResourceVerber(client RESTClient, extensionsClient RESTClient) ResourceVerber

NewResourceVerber creates a new resource verber that uses the given client for performing operations.

func (*ResourceVerber) Delete

func (verber *ResourceVerber) Delete(kind string, namespace string, name string) error

Delete deletes the resource of the given kind in the given namespace with the given name.

type ServiceListChannel

type ServiceListChannel struct {
	List  chan *api.ServiceList
	Error chan error
}

List and error channels to Services.

func GetServiceListChannel

func GetServiceListChannel(client client.ServicesNamespacer, numReads int) ServiceListChannel

Returns a pair of channels to a Service list and errors that both must be read numReads times.

type ServicePort

type ServicePort struct {
	// Positive port number.
	Port int `json:"port"`

	// Protocol name, e.g., TCP or UDP.
	Protocol api.Protocol `json:"protocol"`
}

ServicePort is a pair of port and protocol, e.g. a service endpoint.

func GetServicePorts

func GetServicePorts(apiPorts []api.ServicePort) []ServicePort

GetServicePorts returns human readable name for the given service ports list.

type TypeMeta

type TypeMeta struct {
	// Kind is a string value representing the REST resource this object represents.
	// Servers may infer this from the endpoint the client submits requests to.
	// In smalllettercase.
	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds
	Kind ResourceKind `json:"kind,omitempty"`
}

TypeMeta describes an individual object in an API response or request with strings representing the type of the object.

func NewTypeMeta

func NewTypeMeta(kind ResourceKind) TypeMeta

NewTypeMeta creates new type mete for the resource kind.

Jump to

Keyboard shortcuts

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