namespaces

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package namespaces provides the functionality to manage namespaces.

Package namespaces provides the functionality to manage namespaces.

Package namespaces provides the functionality to manage namespaces.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNamespaceNotExist appears when the namespace does not exist.
	ErrNamespaceNotExist = errors.New("namespace does not exist")

	// ErrNamespaceNotExist appears when the namespace does not exist.
	NewErrNamespaceNotExist = func(namespace string) error {
		return fmt.Errorf("'%s': %w", namespace, ErrNamespaceNotExist)
	}

	// ErrNamespaceAlreadyExists appears when the namespace already exists.
	ErrNamespaceAlreadyExists = errors.New("namespace already exists")

	// ErrNamespaceAlreadyExists appears when the namespace already exists.
	NewErrNamespaceAlreadyExists = func(namespace string) error {
		return fmt.Errorf("'%s': %w", namespace, ErrNamespaceAlreadyExists)
	}

	// ErrNamespaceNotManagedByEverest appears when the namespace is not managed by Everest.
	ErrNamespaceNotManagedByEverest = errors.New("namespace is not managed by Everest")

	// ErrNamespaceNotManagedByEverest appears when the namespace is not managed by Everest.
	NewErrNamespaceNotManagedByEverest = func(namespace string) error {
		return fmt.Errorf("'%s': %w", namespace, ErrNamespaceNotManagedByEverest)
	}

	// // ErrNamespaceAlreadyManagedByEverest appears when the namespace is already owned by Everest.
	ErrNamespaceAlreadyManagedByEverest = errors.New("namespace already exists and is managed by Everest")

	// ErrNamespaceAlreadyManagedByEverest appears when the namespace is already owned by Everest.
	NewErrNamespaceAlreadyManagedByEverest = func(namespace string) error {
		return fmt.Errorf("'%s': %s", namespace, ErrNamespaceAlreadyManagedByEverest)
	}

	// ErrNamespaceListEmpty appears when the provided list of the namespaces is considered empty.
	ErrNamespaceListEmpty = errors.New("namespace list is empty. Specify at least one namespace")

	// ErrNamespaceReserved appears when some of the provided names are forbidden to use.
	ErrNamespaceReserved = func(ns string) error {
		return fmt.Errorf("'%s' namespace is reserved for Everest internals. Please specify another namespace", ns)
	}

	// ErrOperatorsNotSelected appears when no operators are selected for installation.
	ErrOperatorsNotSelected = errors.New("no operators selected for installation. Minimum one operator must be selected")

	// ErrCannotRemoveOperators appears when user tries to delete operator from namespace.
	ErrCannotRemoveOperators = errors.New("cannot remove operators")

	// ErrNamespaceNotEmpty is returned when the namespace is not empty.
	ErrNamespaceNotEmpty = errors.New("cannot remove namespace with running database clusters")

	// ErrInteractiveModeDisabled is returned when interactive mode is disabled.
	ErrInteractiveModeDisabled = errors.New("interactive mode is disabled")
)

nolint:gochecknoglobals

Functions

func NewRemoveNamespaceSteps

func NewRemoveNamespaceSteps(namespace string, keepNs bool, k kubernetes.KubernetesConnector) []steps.Step

NewRemoveNamespaceSteps returns the steps to remove a namespace.

func ParseNamespaceNames added in v1.5.0

func ParseNamespaceNames(namespaces string) []string

ParseNamespaceNames parses a comma-separated namespaces string. It returns a list of namespaces. Note: namespace names are not validated. Use validateNamespaceNames to validate them.

Types

type NamespaceAddConfig

type NamespaceAddConfig struct {
	// NamespaceList is a list of namespaces to be managed by Everest and install operators.
	// The property shall be set in case the namespaces are parsed and validated using ValidateNamespaces func.
	// Otherwise, use Populate function to asked user to provide the namespaces in interactive mode.
	NamespaceList []string
	// SkipWizard is set if the wizard should be skipped.
	SkipWizard bool
	// KubeconfigPath is the path to the kubeconfig file.
	KubeconfigPath string
	// DisableTelemetry is set if telemetry should be disabled.
	DisableTelemetry bool
	// TakeOwnership make an existing namespace managed by Everest.
	TakeOwnership bool
	// ClusterType is the type of the Kubernetes environment.
	// If it is not set, the environment will be detected.
	ClusterType kubernetes.ClusterType
	// SkipEnvDetection skips detecting the Kubernetes environment.
	// If it is set, the environment will not be detected.
	// Set ClusterType if the environment is known and set this flag to avoid detection duplication.
	SkipEnvDetection bool
	// AskOperators is set in case it is needed to use interactive mode and
	// ask user to provide DB operators to be installed into namespaces managed by Everest.
	// AskOperators bool
	// Operators configurations for the operators to be installed into namespaces managed by Everest.
	Operators OperatorConfig
	// Pretty if set print the output in pretty mode.
	Pretty bool
	// Update is set if the existing namespace needs to be updated.
	// This flag is set internally only, so that the add functionality may
	// be re-used for updating the namespace as well.
	Update bool
	// Helm related options
	HelmConfig helm.CLIOptions
}

NamespaceAddConfig is the configuration for adding namespaces.

func NewNamespaceAddConfig added in v1.5.0

func NewNamespaceAddConfig() NamespaceAddConfig

NewNamespaceAddConfig returns a new NamespaceAddConfig.

func (*NamespaceAddConfig) PopulateNamespaces added in v1.5.0

func (cfg *NamespaceAddConfig) PopulateNamespaces(ctx context.Context) error

PopulateNamespaces function to fill the configuration with the required NamespaceList. This function shall be called only in cases when there is no other way to obtain values for NamespaceList. User will be asked to provide the namespaces in interactive mode (if it is enabled). Provided by user namespaces will be parsed, validated and stored in the NamespaceList property. Note: in case NamespaceList is not empty - it will be overwritten by user's input.

func (*NamespaceAddConfig) PopulateOperators added in v1.5.0

func (cfg *NamespaceAddConfig) PopulateOperators(ctx context.Context) error

PopulateOperators function to fill the configuration with the required Operators. This function shall be called only in cases when there is no other way to obtain values for Operators. User will be asked to provide the operators in interactive mode (if it is enabled). Provided by user operators will be stored in the Operators property. Note: Operators property will be overwritten by user's input.

func (*NamespaceAddConfig) ValidateNamespaces added in v1.5.0

func (cfg *NamespaceAddConfig) ValidateNamespaces(ctx context.Context, nsList []string) error

ValidateNamespaces validates the provided list of namespaces. It validates: - namespace names - namespace ownership

type NamespaceAdder

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

NamespaceAdder provides the functionality to add namespaces.

func NewNamespaceAdd

func NewNamespaceAdd(c NamespaceAddConfig, l *zap.SugaredLogger) (*NamespaceAdder, error)

NewNamespaceAdd returns a new CLI operation to add namespaces.

func (*NamespaceAdder) GetNamespaceInstallSteps added in v1.5.0

func (n *NamespaceAdder) GetNamespaceInstallSteps(ctx context.Context, dbNSChartVersion string) ([]steps.Step, error)

GetNamespaceInstallSteps returns the steps to install namespaces.

func (*NamespaceAdder) Run

func (n *NamespaceAdder) Run(ctx context.Context) error

Run namespace add operation.

type NamespaceInfo added in v1.5.0

type NamespaceInfo struct {
	// Name is the namespace name.
	Name string
	// InstalledOperators is a list of installed Percona operators in the namespace.
	InstalledOperators []string
}

NamespaceInfo contains information about a namespace.

type NamespaceListConfig added in v1.5.0

type NamespaceListConfig struct {
	// KubeconfigPath is a path to a kubeconfig
	KubeconfigPath string
	// Pretty if set print the output in pretty mode.
	Pretty bool
	// ListAllNamespaces if set, list all namespaces.
	// Note: this flag skips namespaces that cannot be added to Everest management
	// (i.e. Kubernetes system, specific to cloud providers and Everest Core namespaces).
	ListAllNamespaces bool
}

NamespaceListConfig is the configuration for the namespace listing operation.

type NamespaceLister added in v1.5.0

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

NamespaceLister is the CLI operation to list namespaces.

func NewNamespaceLister added in v1.5.0

func NewNamespaceLister(c NamespaceListConfig, l *zap.SugaredLogger) (*NamespaceLister, error)

NewNamespaceLister returns a new CLI operation to list namespaces.

func (*NamespaceLister) Run added in v1.5.0

func (nsL *NamespaceLister) Run(ctx context.Context) ([]NamespaceInfo, error)

Run the namespace list operation.

type NamespaceRemoveConfig

type NamespaceRemoveConfig struct {
	// NamespaceList is a list of namespaces to be removed.
	// The property shall be set explicitly after the provided namespaces are parsed and validated using ValidateNamespaces func.
	NamespaceList []string
	// KubeconfigPath is a path to a kubeconfig
	KubeconfigPath string
	// Force delete a namespace by deleting databases in it.
	Force bool
	// If set, keep the namespace but remove all resources from it.
	KeepNamespace bool
	// Pretty if set print the output in pretty mode.
	Pretty bool
}

NamespaceRemoveConfig is the configuration for the namespace removal operation.

func (*NamespaceRemoveConfig) ValidateNamespaces added in v1.5.0

func (cfg *NamespaceRemoveConfig) ValidateNamespaces(ctx context.Context, nsList []string) error

ValidateNamespaces validates the provided list of namespaces. It validates: - namespace names - namespace ownership

type NamespaceRemover

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

NamespaceRemover is the CLI operation to remove namespaces.

func NewNamespaceRemove

func NewNamespaceRemove(c NamespaceRemoveConfig, l *zap.SugaredLogger) (*NamespaceRemover, error)

NewNamespaceRemove returns a new CLI operation to remove namespaces.

func (*NamespaceRemover) Run

func (r *NamespaceRemover) Run(ctx context.Context) error

Run the namespace removal operation.

type OperatorConfig

type OperatorConfig struct {
	PG    bool // is set if PostgresSQL shall be installed.
	PSMDB bool // is set if MongoDB shall be installed.
	PXC   bool // is set if XtraDB Cluster shall be installed.
}

OperatorConfig identifies which operators shall be installed.

Jump to

Keyboard shortcuts

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