kube

package
v0.0.0-...-5952ad4 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PresubmitJob  ProwJobType = "presubmit"
	PostsubmitJob             = "postsubmit"
	PeriodicJob               = "periodic"
	BatchJob                  = "batch"
)
View Source
const (
	TriggeredState ProwJobState = "triggered"
	PendingState                = "pending"
	SuccessState                = "success"
	FailureState                = "failure"
	AbortedState                = "aborted"
	ErrorState                  = "error"
)
View Source
const (
	ProwNamespace    = "default"
	TestPodNamespace = "test-pods"
)
View Source
const (
	Evicted = "Evicted"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// If Logger is non-nil, log all method calls with it.
	Logger Logger
	// contains filtered or unexported fields
}

Client interacts with the Kubernetes api-server.

func NewClient

func NewClient(c *Cluster, namespace string) (*Client, error)

NewClient returns an authenticated Client using the keys in the Cluster.

func NewClientFromFile

func NewClientFromFile(clusterPath, namespace string) (*Client, error)

NewClientFromFile reads a Cluster object at clusterPath and returns an authenticated client using the keys within.

func NewClientInCluster

func NewClientInCluster(namespace string) (*Client, error)

NewClientInCluster creates a Client that works from within a pod.

func NewFakeClient

func NewFakeClient() *Client

NewFakeClient creates a client that doesn't do anything.

func (*Client) CreatePod

func (c *Client) CreatePod(p Pod) (Pod, error)

func (*Client) CreateProwJob

func (c *Client) CreateProwJob(j ProwJob) (ProwJob, error)

func (*Client) DeletePod

func (c *Client) DeletePod(name string) error

func (*Client) DeleteProwJob

func (c *Client) DeleteProwJob(name string) error

func (*Client) GetLog

func (c *Client) GetLog(pod string) ([]byte, error)

func (*Client) GetPod

func (c *Client) GetPod(name string) (Pod, error)

func (*Client) GetProwJob

func (c *Client) GetProwJob(name string) (ProwJob, error)

func (*Client) ListPods

func (c *Client) ListPods(labels map[string]string) ([]Pod, error)

func (*Client) ListProwJobs

func (c *Client) ListProwJobs(labels map[string]string) ([]ProwJob, error)

func (*Client) Namespace

func (c *Client) Namespace(ns string) *Client

Namespace returns a copy of the client pointing at the specified namespace.

func (*Client) ReplaceProwJob

func (c *Client) ReplaceProwJob(name string, job ProwJob) (ProwJob, error)

func (*Client) ReplaceSecret

func (c *Client) ReplaceSecret(name string, s Secret) error

type Cluster

type Cluster struct {
	// The IP address of the cluster's master endpoint.
	Endpoint string `yaml:"endpoint"`
	// Base64-encoded public cert used by clients to authenticate to the
	// cluster endpoint.
	ClientCertificate string `yaml:"clientCertificate"`
	// Base64-encoded private key used by clients..
	ClientKey string `yaml:"clientKey"`
	// Base64-encoded public certificate that is the root of trust for the
	// cluster.
	ClusterCACertificate string `yaml:"clusterCaCertificate"`
}

Cluster represents the information necessary to talk to a Kubernetes master endpoint.

type ConfigMapKeySelector

type ConfigMapKeySelector struct {
	Name string `json:"name,omitempty"`
	Key  string `json:"key,omitempty"`
}

type ConfigMapSource

type ConfigMapSource struct {
	Name string `json:"name,omitempty"`
}

type ConflictError

type ConflictError error

type Container

type Container struct {
	Name    string   `json:"name,omitempty"`
	Image   string   `json:"image,omitempty"`
	Command []string `json:"command,omitempty"`
	Args    []string `json:"args,omitempty"`
	WorkDir string   `json:"workingDir,omitempty"`
	Env     []EnvVar `json:"env,omitempty"`
	Ports   []Port   `json:"ports,omitempty"`

	Resources       Resources        `json:"resources,omitempty"`
	SecurityContext *SecurityContext `json:"securityContext,omitempty"`
	VolumeMounts    []VolumeMount    `json:"volumeMounts,omitempty"`
}

type DownwardAPIFile

type DownwardAPIFile struct {
	Path  string              `json:"path"`
	Field ObjectFieldSelector `json:"fieldRef,omitempty"`
}

type DownwardAPISource

type DownwardAPISource struct {
	Items []DownwardAPIFile `json:"items,omitempty"`
}

type EnvVar

type EnvVar struct {
	Name      string        `json:"name,omitempty"`
	Value     string        `json:"value,omitempty"`
	ValueFrom *EnvVarSource `json:"valueFrom,omitempty"`
}

type EnvVarSource

type EnvVarSource struct {
	ConfigMap ConfigMapKeySelector `json:"configMapKeyRef,omitempty"`
}

type HostPathSource

type HostPathSource struct {
	Path string `json:"path,omitempty"`
}

type Job

type Job struct {
	Metadata ObjectMeta `json:"metadata,omitempty"`
	Spec     JobSpec    `json:"spec,omitempty"`
	Status   JobStatus  `json:"status,omitempty"`
}

func (*Job) Complete

func (j *Job) Complete() bool

type JobSpec

type JobSpec struct {
	Completions           *int `json:"completions,omitempty"`
	Parallelism           *int `json:"parallelism,omitempty"`
	ActiveDeadlineSeconds int  `json:"activeDeadlineSeconds,omitempty"`

	Template PodTemplateSpec `json:"template,omitempty"`
}

type JobStatus

type JobStatus struct {
	StartTime      time.Time `json:"startTime,omitempty"`
	CompletionTime time.Time `json:"completionTime,omitempty"`
	Active         int       `json:"active,omitempty"`
	Succeeded      int       `json:"succeeded,omitempty"`
	Failed         int       `json:"failed,omitempty"`
}

type Logger

type Logger interface {
	Printf(s string, v ...interface{})
}

type ObjectFieldSelector

type ObjectFieldSelector struct {
	FieldPath string `json:"fieldPath"`
}

type ObjectMeta

type ObjectMeta struct {
	Name        string            `json:"name,omitempty"`
	Namespace   string            `json:"namespace,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`

	ResourceVersion string `json:"resourceVersion,omitempty"`
	UID             string `json:"uid,omitempty"`
}

type Pod

type Pod struct {
	Metadata ObjectMeta `json:"metadata,omitempty"`
	Spec     PodSpec    `json:"spec,omitempty"`
	Status   PodStatus  `json:"status,omitempty"`
}

type PodPhase

type PodPhase string
const (
	PodPending   PodPhase = "Pending"
	PodRunning   PodPhase = "Running"
	PodSucceeded PodPhase = "Succeeded"
	PodFailed    PodPhase = "Failed"
	PodUnknown   PodPhase = "Unknown"
)

type PodSpec

type PodSpec struct {
	Volumes       []Volume          `json:"volumes,omitempty"`
	Containers    []Container       `json:"containers,omitempty"`
	RestartPolicy string            `json:"restartPolicy,omitempty"`
	NodeSelector  map[string]string `json:"nodeSelector,omitempty"`
}

type PodStatus

type PodStatus struct {
	Phase     PodPhase  `json:"phase,omitempty"`
	Message   string    `json:"message,omitempty"`
	Reason    string    `json:"reason,omitempty"`
	StartTime time.Time `json:"startTime,omitempty"`
}

type PodTemplateSpec

type PodTemplateSpec struct {
	Metadata ObjectMeta `json:"metadata,omitempty"`
	Spec     PodSpec    `json:"spec,omitempty"`
}

type Port

type Port struct {
	ContainerPort int `json:"containerPort,omitempty"`
	HostPort      int `json:"hostPort,omitempty"`
}

type ProwJob

type ProwJob struct {
	APIVersion string        `json:"apiVersion,omitempty"`
	Kind       string        `json:"kind,omitempty"`
	Metadata   ObjectMeta    `json:"metadata,omitempty"`
	Spec       ProwJobSpec   `json:"spec,omitempty"`
	Status     ProwJobStatus `json:"status,omitempty"`
}

func (*ProwJob) Complete

func (j *ProwJob) Complete() bool

type ProwJobAgent

type ProwJobAgent string
const (
	KubernetesAgent ProwJobAgent = "kubernetes"
	JenkinsAgent                 = "jenkins"
)

type ProwJobSpec

type ProwJobSpec struct {
	Type  ProwJobType  `json:"type,omitempty"`
	Agent ProwJobAgent `json:"agent,omitempty"`
	Job   string       `json:"job,omitempty"`
	Refs  Refs         `json:"refs,omitempty"`

	Report       bool   `json:"report,omitempty"`
	Context      string `json:"context,omitempty"`
	RerunCommand string `json:"rerun_command,omitempty"`

	PodSpec PodSpec `json:"pod_spec,omitempty"`

	RunAfterSuccess []ProwJobSpec `json:"run_after_success,omitempty"`
}

type ProwJobState

type ProwJobState string

type ProwJobStatus

type ProwJobStatus struct {
	StartTime       time.Time    `json:"startTime,omitempty"`
	CompletionTime  time.Time    `json:"completionTime,omitempty"`
	State           ProwJobState `json:"state,omitempty"`
	Description     string       `json:"description,omitempty"`
	URL             string       `json:"url,omitempty"`
	PodName         string       `json:"pod_name,omitempty"`
	BuildID         string       `json:"build_id,omitempty"`
	JenkinsQueueURL string       `json:"jenkins_queue_url,omitempty"`
	JenkinsEnqueued bool         `json:"jenkins_enqueued,omitempty"`
	JenkinsBuildID  string       `json:"jenkins_build_id,omitempty"`
}

type ProwJobType

type ProwJobType string

type Pull

type Pull struct {
	Number int    `json:"number,omitempty"`
	Author string `json:"author,omitempty"`
	SHA    string `json:"sha,omitempty"`
}

type Refs

type Refs struct {
	Org  string `json:"org,omitempty"`
	Repo string `json:"repo,omitempty"`

	BaseRef string `json:"base_ref,omitempty"`
	BaseSHA string `json:"base_sha,omitempty"`

	Pulls []Pull `json:"pulls,omitempty"`
}

func (Refs) String

func (r Refs) String() string

type ResourceRequest

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

type Resources

type Resources struct {
	Requests *ResourceRequest `json:"requests,omitempty"`
	Limits   *ResourceRequest `json:"limits,omitempty"`
}

type Secret

type Secret struct {
	Metadata ObjectMeta        `json:"metadata,omitempty"`
	Data     map[string]string `json:"data,omitempty"`
}

type SecretSource

type SecretSource struct {
	Name        string `json:"secretName,omitempty"`
	DefaultMode int32  `json:"defaultMode,omitempty"`
}

type SecurityContext

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

type Volume

type Volume struct {
	Name        string             `json:"name,omitempty"`
	Secret      *SecretSource      `json:"secret,omitempty"`
	DownwardAPI *DownwardAPISource `json:"downwardAPI,omitempty"`
	HostPath    *HostPathSource    `json:"hostPath,omitempty"`
	ConfigMap   *ConfigMapSource   `json:"configMap,omitempty"`
}

type VolumeMount

type VolumeMount struct {
	Name      string `json:"name,omitempty"`
	ReadOnly  bool   `json:"readOnly,omitempty"`
	MountPath string `json:"mountPath,omitempty"`
}

Jump to

Keyboard shortcuts

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