deployments

package
v4.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 1, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const PruneDeploymentsRecommendedName = "deployments"

Variables

This section is empty.

Functions

func DeploymentByDeploymentConfigIndexFunc

func DeploymentByDeploymentConfigIndexFunc(obj interface{}) ([]string, error)

DeploymentByDeploymentConfigIndexFunc indexes Deployment items by their associated DeploymentConfig, if none, index with key "orphan"

func FilterDeploymentsPredicate

func FilterDeploymentsPredicate(item *corev1.ReplicationController) bool

FilterDeploymentsPredicate is a function that returns true if the replication controller is associated with a DeploymentConfig

func FilterZeroReplicaSize

func FilterZeroReplicaSize(item *corev1.ReplicationController) bool

FilterZeroReplicaSize is a function that returns true if the replication controller size is 0

func NewCmdPruneDeployments

func NewCmdPruneDeployments(f kcmdutil.Factory, parentName, name string, streams genericclioptions.IOStreams) *cobra.Command

NewCmdPruneDeployments implements the OpenShift cli prune deployments command.

Types

type ByMostRecent

type ByMostRecent []*corev1.ReplicationController

ByMostRecent sorts deployments by most recently created.

func (ByMostRecent) Len

func (s ByMostRecent) Len() int

func (ByMostRecent) Less

func (s ByMostRecent) Less(i, j int) bool

func (ByMostRecent) Swap

func (s ByMostRecent) Swap(i, j int)

type DataSet

type DataSet interface {
	GetDeploymentConfig(deployment *corev1.ReplicationController) (*appsv1.DeploymentConfig, bool, error)
	ListDeploymentConfigs() ([]*appsv1.DeploymentConfig, error)
	ListDeployments() ([]*corev1.ReplicationController, error)
	ListDeploymentsByDeploymentConfig(config *appsv1.DeploymentConfig) ([]*corev1.ReplicationController, error)
}

DataSet provides functions for working with deployment data

func NewDataSet

func NewDataSet(deploymentConfigs []*appsv1.DeploymentConfig, deployments []*corev1.ReplicationController) DataSet

NewDataSet returns a DataSet over the specified items

type DeploymentDeleter

type DeploymentDeleter interface {
	// DeleteDeployment removes the deployment from OpenShift's storage.
	DeleteDeployment(deployment *corev1.ReplicationController) error
}

DeploymentDeleter knows how to delete deployments from OpenShift.

func NewDeploymentDeleter

func NewDeploymentDeleter(deployments corev1client.ReplicationControllersGetter) DeploymentDeleter

NewDeploymentDeleter creates a new deploymentDeleter.

type Filter

type Filter interface {
	Filter(items []*corev1.ReplicationController) []*corev1.ReplicationController
}

Filter filters the set of objects

type FilterPredicate

type FilterPredicate func(item *corev1.ReplicationController) bool

FilterPredicate is a function that returns true if the object should be included in the filtered set

func NewFilterBeforePredicate

func NewFilterBeforePredicate(d time.Duration) FilterPredicate

NewFilterBeforePredicate is a function that returns true if the build was created before the current time minus specified duration

type PruneDeploymentsOptions

type PruneDeploymentsOptions struct {
	Confirm         bool
	Orphans         bool
	KeepYoungerThan time.Duration
	KeepComplete    int
	KeepFailed      int
	Namespace       string

	AppsClient appsv1client.DeploymentConfigsGetter
	KubeClient corev1client.CoreV1Interface

	genericclioptions.IOStreams
}

PruneDeploymentsOptions holds all the required options for pruning deployments.

func NewPruneDeploymentsOptions

func NewPruneDeploymentsOptions(streams genericclioptions.IOStreams) *PruneDeploymentsOptions

func (*PruneDeploymentsOptions) Complete

func (o *PruneDeploymentsOptions) Complete(f kcmdutil.Factory, cmd *cobra.Command, args []string) error

Complete turns a partially defined PruneDeploymentsOptions into a solvent structure which can be validated and used for pruning deployments.

func (PruneDeploymentsOptions) Run

Run contains all the necessary functionality for the OpenShift cli prune deployments command.

func (PruneDeploymentsOptions) Validate

func (o PruneDeploymentsOptions) Validate() error

Validate ensures that a PruneDeploymentsOptions is valid and can be used to execute pruning.

type Pruner

type Pruner interface {
	// Prune is responsible for actual removal of deployments identified as candidates
	// for pruning based on pruning algorithm.
	Prune(deleter DeploymentDeleter) error
}

func NewPruner

func NewPruner(options PrunerOptions) Pruner

NewPruner returns a Pruner over specified data using specified options. deploymentConfigs, deployments, opts.KeepYoungerThan, opts.Orphans, opts.KeepComplete, opts.KeepFailed, deploymentPruneFunc

type PrunerOptions

type PrunerOptions struct {
	// KeepYoungerThan will filter out all objects from prune data set that are younger than the specified time duration.
	KeepYoungerThan time.Duration
	// Orphans if true will include inactive orphan deployments in candidate prune set.
	Orphans bool
	// KeepComplete is per DeploymentConfig how many of the most recent deployments should be preserved.
	KeepComplete int
	// KeepFailed is per DeploymentConfig how many of the most recent failed deployments should be preserved.
	KeepFailed int
	// DeploymentConfigs is the entire list of deploymentconfigs across all namespaces in the cluster.
	DeploymentConfigs []*appsv1.DeploymentConfig
	// Deployments is the entire list of deployments across all namespaces in the cluster.
	Deployments []*corev1.ReplicationController
}

PrunerOptions contains the fields used to initialize a new Pruner.

type Resolver

type Resolver interface {
	Resolve() ([]*corev1.ReplicationController, error)
}

Resolver knows how to resolve the set of candidate objects to prune

func NewOrphanDeploymentResolver

func NewOrphanDeploymentResolver(dataSet DataSet, deploymentStatusFilter []appsv1.DeploymentStatus) Resolver

NewOrphanDeploymentResolver returns a Resolver that matches objects with no associated DeploymentConfig and has a DeploymentStatus in filter

func NewPerDeploymentConfigResolver

func NewPerDeploymentConfigResolver(dataSet DataSet, keepComplete int, keepFailed int) Resolver

NewPerDeploymentConfigResolver returns a Resolver that selects items to prune per config

Jump to

Keyboard shortcuts

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