common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const PERMITTEDGROUPLABEL = "PERMITTED_GROUPS"

Variables

This section is empty.

Functions

func CheckGroup

func CheckGroup(ctx context.Context, user, groupName string, k8sClient client.Client) (bool, error)

CheckGroup accepts groupname and username. Fetches group and checks if user is int it.

func ContainsString

func ContainsString(sslice []string, s string) bool

ContainsString checks if a string is present in a slice of strings.

func DeletionTimeStampExists

func DeletionTimeStampExists(object client.Object) bool

DeletionTimeStampExists returns true if an object is being deleted, and false otherwise.

func IndexOf

func IndexOf(element string, a []string) (int, error)

IndexOf returns the index of the given element in the given array of strings.

func IsUserInGroup

func IsUserInGroup(user string, group userv1.Group) bool

IsUserInGroup returns true if given user is in give group

func ShouldReconcile

func ShouldReconcile(phase danav1.Phase) bool

ShouldReconcile returns true if the Phase given as argument is not Complete or Error; meaning that reconciliation needs to take place.

func ValidateNamespaceExist

func ValidateNamespaceExist(ns *objectcontext.ObjectContext) admission.Response

ValidateNamespaceExist validates that a namespace exists.

func ValidatePermissions

func ValidatePermissions(ctx context.Context, aNS []string, aNSName, bNSName, ancestorNSName, reqUser string, branch bool, k8sClient client.Client) admission.Response

ValidatePermissions checks if a registered user has the needed permissions on the namespaces and denies otherwise there are 4 scenarios in which things are allowed: if the user is in a permitted group; if the user has the needed permissions on the Ancestor of the two namespaces; if the user has the needed permissions on both namespaces; if the user has the needed permissions on the namespace from which resources are moved and both namespaces are in the same branch (only checked when the branch flag is true).

func ValidatePermittedGroups

func ValidatePermittedGroups(ctx context.Context, user string, k8sClient client.Client) (bool, error)

ValidatePermittedGroups validate if user is in a permitted group

func ValidateSecondaryRoot

func ValidateSecondaryRoot(ctx context.Context, c client.Client, aNSArray, bNSArray []string) admission.Response

ValidateSecondaryRoot denies if trying to perform UpdateQuota involving namesapces from different secondary root namespaces a secondary root is the first subnamespace after the root namespace in the hierarchy of a subnamespace.

func ValidateToNamespaceName

func ValidateToNamespaceName(ns *objectcontext.ObjectContext, toNSName string) admission.Response

ValidateToNamespaceName validates that a namespace is not trying to be migrated to be under the same namespace it's already in.

Types

This section is empty.

Jump to

Keyboard shortcuts

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