namespacedb

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNS

func AddNS(ctx context.Context, nDB *NamespaceDB, client client.Client, sns *danav1.Subnamespace) error

AddNS adds a namespace to its key if such exist, otherwise it checks whether the namespace should be the key itself and adds it to the DB.

func EnsureSNSInDB

func EnsureSNSInDB(ctx context.Context, sns *objectcontext.ObjectContext, nDB *NamespaceDB) error

EnsureSNSInDB ensures subnamespace in db if it should be.

func LocateNS

func LocateNS(nsList corev1.NamespaceList, nsName string) *corev1.Namespace

LocateNS locates a namespace by name in a given namespace list.

func MigrateNSHierarchy

func MigrateNSHierarchy(ctx context.Context, ndb *NamespaceDB, client client.Client, snsName string, destNSName string) error

MigrateNSHierarchy migrates namespace and its children hierarchy from one key to another key.

func NSListUp

func NSListUp(ns corev1.Namespace, rootNS string, nsList corev1.NamespaceList) ([]corev1.Namespace, error)

NSListUp creates a slice of all namespaces in the hierarchy from ns to rootNS.

Types

type NamespaceDB

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

NamespaceDB is an in-memory DB that contains a map with a key that is a string representing the first namespace in a hierarchy that is bound to a CRQ and not RQ, and a value that is a slice of all namespaces which are under this particular key in the hierarchy.

func Init

func Init(scheme *runtime.Scheme, logger logr.Logger) (*NamespaceDB, error)

Init initializes a new NamespaceDB instance.

func (*NamespaceDB) DeleteKey

func (ndb *NamespaceDB) DeleteKey(key string)

DeleteKey deletes a key from the database.

func (*NamespaceDB) Key

func (ndb *NamespaceDB) Key(ns string) string

Key retrieves the key that the provided namespace belongs to.

func (*NamespaceDB) KeyCount

func (ndb *NamespaceDB) KeyCount(key string) int

KeyCount returns the number of namespaces that belong to a specific key.

func (*NamespaceDB) RemoveNS

func (ndb *NamespaceDB) RemoveNS(nsname string, key string) error

RemoveNS removes a namespace from the slice of namespaces that belongs to a key.

Jump to

Keyboard shortcuts

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