namespace

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// NamespacesByProjectExcludingRegistrationID is an index mapping namespaces to project that they belong into
	// The index will omit any namespaces considered to be the Project Registration namespace or a system namespace
	NamespacesByProjectExcludingRegistrationID = "helm.cattle.io/namespaces-by-project-id-excluding-registration"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker func(namespace *corev1.Namespace) bool

Checker is a function that checks a namespace object and returns true or false

type Getter

type Getter interface {
	// Has implies that the namespace has been registered
	Has(name string) bool

	// Get retrieves a registered namespace
	Get(name string) (*corev1.Namespace, bool)
}

Getter gets a namespace that has been stored in a register

type ProjectGetter

type ProjectGetter interface {
	// IsProjectRegistrationNamespace returns whether to watch for ProjectHelmCharts in the provided namespace
	IsProjectRegistrationNamespace(namespace *corev1.Namespace) bool

	// IsSystemNamespace returns whether the provided namespace is considered a system namespace
	IsSystemNamespace(namespace *corev1.Namespace) bool

	// GetTargetProjectNamespaces returns the list of namespaces that should be targeted for a given ProjectHelmChart
	// Any namespace returned by this should not be a project registration namespace or a system namespace
	GetTargetProjectNamespaces(projectHelmChart *v1alpha1.ProjectHelmChart) ([]string, error)
}

ProjectGetter allows you to get target namespaces based on a project and identify namespaces as special namespaces in a project

func NewLabelBasedProjectGetter

func NewLabelBasedProjectGetter(
	projectLabel string,
	isProjectRegistrationNamespace Checker,
	isSystemNamespace Checker,
	namespaces corecontroller.NamespaceController,
) ProjectGetter

NewLabelBasedProjectGetter returns a ProjectGetter that gets target project namespaces that meet the following criteria: 1) Must have the same projectLabel value as the namespace where the ProjectHelmChart lives in 2) Must not be a project registration namespace 3) Must not be a system namespace

func NewSingleNamespaceProjectGetter

func NewSingleNamespaceProjectGetter(
	registrationNamespace string,
	systemNamespaces []string,
	namespaces corecontroller.NamespaceController,
) ProjectGetter

NewSingleNamespaceProjectGetter returns a ProjectGetter that gets target project namespaces that meet the following criteria: 1) Must match the labels provided on spec.projectNamespaceSelector of the projectHelmChart in question 2) Must not be the registration namespace 3) Must not be part of the provided systemNamespaces

func Register

func Register(
	ctx context.Context,
	apply apply.Apply,
	systemNamespace, valuesYaml, questionsYaml string,
	opts common.Options,
	namespaces corecontroller.NamespaceController,
	namespaceCache corecontroller.NamespaceCache,
	configmaps corecontroller.ConfigMapController,
	projectHelmCharts helmprojectcontroller.ProjectHelmChartController,
	projectHelmChartCache helmprojectcontroller.ProjectHelmChartCache,
	dynamic dynamic.Interface,
) ProjectGetter

type Tracker

type Tracker interface {
	Getter

	// Set registers a namespace
	Set(namespace *corev1.Namespace)

	// Delete unregisters a namespace
	Delete(namespace *corev1.Namespace)
}

Tracker can store namespace references and get them

func NewTracker

func NewTracker() Tracker

NewTracker returns a new tracker that can track and get namespaces

Jump to

Keyboard shortcuts

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