spaces

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package spaces provides a cf compatible way of managing spaces in the cluster. All spaces are denoted by the label `app.kubernetes.io/managed-by=kf`.

Namespaces without that label are ignored.

Index

Examples

Constants

View Source
const (
	// Kind contains the kind for the backing Kubernetes API.
	Kind = "Space"

	// APIVersion contains the version for the backing Kubernetes API.
	APIVersion = "v1alpha1"
)

Variables

This section is empty.

Functions

func ConditionDeleted

func ConditionDeleted(_ *v1alpha1.Space, apiErr error) (bool, error)

ConditionDeleted is a ConditionFuncE that succeeds if the error returned by the cluster was a not found error.

func FormatDiff

func FormatDiff(w io.Writer, leftName, rightName string, left, right *v1alpha1.Space)

FormatDiff creates a diff between two v1alpha1.Spaces and writes it to the given writer.

func IsStatusFinal

func IsStatusFinal(space *v1alpha1.Space) bool

IsStatusFinal checks if the space has been fully synchronized.

Types

type Client

type Client interface {
	Create(obj *v1alpha1.Space, opts ...CreateOption) (*v1alpha1.Space, error)
	Update(obj *v1alpha1.Space, opts ...UpdateOption) (*v1alpha1.Space, error)
	Transform(name string, transformer Mutator) (*v1alpha1.Space, error)
	Get(name string, opts ...GetOption) (*v1alpha1.Space, error)
	Delete(name string, opts ...DeleteOption) error
	List(opts ...ListOption) ([]v1alpha1.Space, error)
	Upsert(newObj *v1alpha1.Space, merge Merger) (*v1alpha1.Space, error)
	WaitFor(ctx context.Context, name string, interval time.Duration, condition Predicate) (*v1alpha1.Space, error)
	WaitForE(ctx context.Context, name string, interval time.Duration, condition ConditionFuncE) (*v1alpha1.Space, error)

	// Utility functions
	WaitForDeletion(ctx context.Context, name string, interval time.Duration) (*v1alpha1.Space, error)

	// ClientExtension can be used by the developer to extend the client.
	ClientExtension
}

Client is the interface for interacting with v1alpha1.Space types as Space CF style objects.

func NewClient

func NewClient(kclient cv1alpha1.SpacesGetter) Client

NewClient creates a new space client.

type ClientExtension

type ClientExtension interface {
}

ClientExtension holds additional functions that should be exposed by client.

type ConditionFuncE

type ConditionFuncE func(instance *v1alpha1.Space, apiErr error) (done bool, err error)

ConditionFuncE is a callback used by WaitForE. Done should be set to true once the condition succeeds and shouldn't be called anymore. The error will be passed back to the user.

This function MAY retrieve a nil instance and an apiErr. It's up to the function to decide how to handle the apiErr.

type CreateOption

type CreateOption func(*createConfig)

CreateOption is a single option for configuring a createConfig

type CreateOptions

type CreateOptions []CreateOption

CreateOptions is a configuration set defining a createConfig

func CreateOptionDefaults

func CreateOptionDefaults() CreateOptions

CreateOptionDefaults gets the default values for Create.

func (CreateOptions) Extend

func (opts CreateOptions) Extend(other CreateOptions) CreateOptions

Extend creates a new CreateOptions with the contents of other overriding the values set in this CreateOptions.

type DeleteOption

type DeleteOption func(*deleteConfig)

DeleteOption is a single option for configuring a deleteConfig

func WithDeleteForegroundDeletion

func WithDeleteForegroundDeletion(val bool) DeleteOption

WithDeleteForegroundDeletion creates an Option that sets If the resource should be deleted in the foreground.

type DeleteOptions

type DeleteOptions []DeleteOption

DeleteOptions is a configuration set defining a deleteConfig

func DeleteOptionDefaults

func DeleteOptionDefaults() DeleteOptions

DeleteOptionDefaults gets the default values for Delete.

func (DeleteOptions) Extend

func (opts DeleteOptions) Extend(other DeleteOptions) DeleteOptions

Extend creates a new DeleteOptions with the contents of other overriding the values set in this DeleteOptions.

func (DeleteOptions) ForegroundDeletion

func (opts DeleteOptions) ForegroundDeletion() bool

ForegroundDeletion returns the last set value for ForegroundDeletion or the empty value if not set.

type GetOption

type GetOption func(*getConfig)

GetOption is a single option for configuring a getConfig

type GetOptions

type GetOptions []GetOption

GetOptions is a configuration set defining a getConfig

func GetOptionDefaults

func GetOptionDefaults() GetOptions

GetOptionDefaults gets the default values for Get.

func (GetOptions) Extend

func (opts GetOptions) Extend(other GetOptions) GetOptions

Extend creates a new GetOptions with the contents of other overriding the values set in this GetOptions.

type KfSpace

type KfSpace v1alpha1.Space

KfSpace provides a facade around v1alpha1.Space for accessing and mutating its values.

Example
space := NewKfSpace()
// Setup
space.SetName("nsname")
space.SetContainerRegistry("gcr.io/my-registry")

// Values
fmt.Println("Name:", space.GetName())
fmt.Println("Registry:", space.GetContainerRegistry())
Output:

Name: nsname
Registry: gcr.io/my-registry

func NewFromSpace

func NewFromSpace(s *v1alpha1.Space) *KfSpace

NewFromSpace casts a v1alpha1.Space into a KfSpace.

func NewKfSpace

func NewKfSpace() KfSpace

NewKfSpace creates a new KfSpace.

func (*KfSpace) AppendDomains

func (k *KfSpace) AppendDomains(domains ...v1alpha1.SpaceDomain)

AppendDomains appends to the domains for the space.

Example
space := NewKfSpace()
// Setup
space.AppendDomains(v1alpha1.SpaceDomain{Domain: "example.com"})
space.AppendDomains(v1alpha1.SpaceDomain{Domain: "other-example.com"})

// Values
var domainNames []string
for _, domain := range space.Spec.Execution.Domains {
	domainNames = append(domainNames, domain.Domain)
}
fmt.Println("Domains:", strings.Join(domainNames, ", "))
Output:

Domains: example.com, other-example.com

func (*KfSpace) DeleteQuota

func (k *KfSpace) DeleteQuota() error

DeleteQuota deletes the space quota.

func (*KfSpace) GetCPU

func (k *KfSpace) GetCPU() (resource.Quantity, bool)

GetCPU returns the quota for total CPU in a space.

func (*KfSpace) GetContainerRegistry

func (k *KfSpace) GetContainerRegistry() string

GetContainerRegistry gets the container registry for the space.

func (*KfSpace) GetDomains

func (k *KfSpace) GetDomains() []v1alpha1.SpaceDomain

GetDomains gets the domains for the space.

func (*KfSpace) GetMemory

func (k *KfSpace) GetMemory() (resource.Quantity, bool)

GetMemory returns the quota for total memory in a space.

func (*KfSpace) GetName

func (k *KfSpace) GetName() string

GetName retrieves the name of the space.

func (*KfSpace) GetQuota

func (k *KfSpace) GetQuota() v1.ResourceList

GetQuota retrieves the space quota.

func (*KfSpace) GetServices

func (k *KfSpace) GetServices() (resource.Quantity, bool)

GetServices returns the quota for total number of routes in a space.

func (*KfSpace) ResetCPU

func (k *KfSpace) ResetCPU()

ResetCPU resets the quota for total CPU in a space to unlimited.

func (*KfSpace) ResetMemory

func (k *KfSpace) ResetMemory()

ResetMemory resets the quota for total memory in a space to unlimited.

func (*KfSpace) ResetServices

func (k *KfSpace) ResetServices()

ResetServices resets the quota for total number of routes in a space to unlimited.

func (*KfSpace) SetCPU

func (k *KfSpace) SetCPU(cpuLimit resource.Quantity)

SetCPU sets the quota for total CPU in a space.

func (*KfSpace) SetContainerRegistry

func (k *KfSpace) SetContainerRegistry(registry string)

SetContainerRegistry sets the container registry for the space.

func (*KfSpace) SetMemory

func (k *KfSpace) SetMemory(memoryLimit resource.Quantity)

SetMemory sets the quota for total memory in a space.

func (*KfSpace) SetName

func (k *KfSpace) SetName(name string)

SetName sets the name of the space.

func (*KfSpace) SetServices

func (k *KfSpace) SetServices(numServices resource.Quantity)

SetServices sets the quota for total number of routes in a space.

func (*KfSpace) ToSpace

func (k *KfSpace) ToSpace() *v1alpha1.Space

ToSpace casts this alias back into a v1alpha1.Space.

type List

type List []v1alpha1.Space

List represents a collection of v1alpha1.Space.

func (List) Filter

func (list List) Filter(filter Predicate) (out List)

Filter returns a new list items for which the predicates fails removed.

type ListOption

type ListOption func(*listConfig)

ListOption is a single option for configuring a listConfig

func WithListFieldSelector

func WithListFieldSelector(val map[string]string) ListOption

WithListFieldSelector creates an Option that sets A selector on the resource's fields.

func WithListFilter added in v0.2.0

func WithListFilter(val Predicate) ListOption

WithListFilter creates an Option that sets Filter to apply.

type ListOptions

type ListOptions []ListOption

ListOptions is a configuration set defining a listConfig

func ListOptionDefaults

func ListOptionDefaults() ListOptions

ListOptionDefaults gets the default values for List.

func (ListOptions) Extend

func (opts ListOptions) Extend(other ListOptions) ListOptions

Extend creates a new ListOptions with the contents of other overriding the values set in this ListOptions.

type Merger

type Merger func(newObj, oldObj *v1alpha1.Space) *v1alpha1.Space

Merger is a type to merge an existing value with a new one.

type Mutator

type Mutator func(*v1alpha1.Space) error

Mutator is a function that changes v1alpha1.Space.

func DiffWrapper

func DiffWrapper(w io.Writer, mutator Mutator) Mutator

DiffWrapper wraps a mutator and prints out the diff between the original object and the one it returns if there's no error.

type Predicate

type Predicate func(*v1alpha1.Space) bool

Predicate is a boolean function for a v1alpha1.Space.

type UpdateOption

type UpdateOption func(*updateConfig)

UpdateOption is a single option for configuring a updateConfig

type UpdateOptions

type UpdateOptions []UpdateOption

UpdateOptions is a configuration set defining a updateConfig

func UpdateOptionDefaults

func UpdateOptionDefaults() UpdateOptions

UpdateOptionDefaults gets the default values for Update.

func (UpdateOptions) Extend

func (opts UpdateOptions) Extend(other UpdateOptions) UpdateOptions

Extend creates a new UpdateOptions with the contents of other overriding the values set in this UpdateOptions.

Directories

Path Synopsis
Package fake is a generated GoMock package.
Package fake is a generated GoMock package.

Jump to

Keyboard shortcuts

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