Back to

Package cluster

Latest Go to latest

The latest major version is v2.

Published: Jun 25, 2020 | License: Apache-2.0 | Module:



const (

	// EnvGKEProject the environment variable for the GKE project
	EnvGKEProject = "GKE_PROJECT"

	// EnvGKERegion the environment variable for the GKE region
	EnvGKERegion = "GKE_REGION"

func HasAnyKey

func HasAnyKey(labels map[string]string, filters map[string]string) bool

HasAnyKey returns true if the labels map has none of the keys in the filter

func LabelsMatch

func LabelsMatch(labels map[string]string, filter map[string]string) bool

LabelsMatch returns true if the filter labels are contained in the label map

func NewLabelValue

func NewLabelValue() (string, error)

NewLabelValue returns a cluster safe unique label we can use for locking

func RemoveLabels

func RemoveLabels(client Client, cluster *Cluster, removeLabels []string) (map[string]string, error)

RemoveLabels removes the set of labels from the cluster

type Client

type Client interface {
	// List lists the clusters in the current context - which is usually a project or user id etc
	List() ([]*Cluster, error)

	// ListFilter lists the clusters with the matching label filters
	ListFilter(strings map[string]string) ([]*Cluster, error)

	// Connect connects to the given cluster - returning an error if the connection cannot be made
	Connect(cluster *Cluster) error

	// String returns a text representation of the client
	String() string

	// SetClusterLabels adds labels to the given cluster
	SetClusterLabels(cluster *Cluster, labels map[string]string) error

	// Get looks up a given cluster by name returning nil if its not found
	Get(name string) (*Cluster, error)

	Delete(cluster *Cluster) error

Client represents a kubernetes cluster provider

type Cluster

type Cluster struct {
	Name     string
	Labels   map[string]string
	Status   string
	Location string

Cluster represents a cluster

func GetCluster

func GetCluster(client Client, name string) (*Cluster, error)

GetCluster gets a cluster by listing the clusters

func ListFilter

func ListFilter(client Client, labels map[string]string) ([]*Cluster, error)

ListFilter lists the clusters with a filter

func LockCluster

func LockCluster(client Client, lockLabels map[string]string, filterLabels map[string]string) (*Cluster, error)

LockCluster tries to use the given label and value to lock the cluster. Return nil if there are no clusters available

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier