common

package
v0.0.0-...-639c86f Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ImageList = []string{"IBM_SECRETSHARE_OPERATOR_IMAGE", "IBM_CS_WEBHOOK_IMAGE"}
)

Functions

func CheckMultiInstances

func CheckMultiInstances(r client.Reader) (enable bool)

CheckMultiInstance checks whether it is a MultiInstances including SaaS and on-prem MultiInstances

func CheckSaas

func CheckSaas(r client.Reader) (enable bool)

CheckSaas checks whether it is a SaaS deployment for Common Services

func CheckStorageClass

func CheckStorageClass(r client.Reader) error

CheckStorageClass gets StorageClassList in current cluster, then validates whether StorageClass created

func CompareCsCR

func CompareCsCR(csCR *apiv3.CommonService, existingCsCR *apiv3.CommonService) (needUpdate bool)

func CompareVersion

func CompareVersion(v1, v2 string) (v1IsLarger bool, err error)

CompareVersion takes vx.y.z, vx.y.z -> bool: if v1 is larger than v2

func Contains

func Contains(list []string, s string) bool

Contains returns whether the sub-string is contained

func EnsureLabelsForConfigMap

func EnsureLabelsForConfigMap(cm *corev1.ConfigMap, labels map[string]string)

EnsureLabelsForConfigMap ensures that the specifc ConfigMap has the certain labels

func EnsureLabelsForCsCR

func EnsureLabelsForCsCR(cs *apiv3.CommonService, labels map[string]string)

EnsureLabelsForConfigMap ensures that the specifc ConfigMap has the certain labels

func FieldIndexName

func FieldIndexName(field string) string

FieldIndexName constructs the name of the index over the given field, for use with an indexer.

func GetApprovalModeinNs

func GetApprovalModeinNs(r client.Reader, ns string) (approvalMode string, err error)

func GetCPFSNamespace

func GetCPFSNamespace(r client.Reader) (cpfsNamespace string)

GetCPFSNamespace returns the namespace where foundational services operator should be running

func GetCatalogSource

func GetCatalogSource(packageName, ns string, r client.Reader) (CatalogSourceName, CatalogSourceNS string)

GetCatalogSource gets CatalogSource will be used by operators

func GetCmOfMapCs

func GetCmOfMapCs(r client.Reader) (*corev1.ConfigMap, error)

GetCmOfMapCs gets ConfigMap of Common Services Maps

func GetCmOfNss

func GetCmOfNss(r client.Reader, operatorNs string) *corev1.ConfigMap

GetCmOfNss gets ConfigMap of Namespace-scope

func GetControlNs

func GetControlNs(r client.Reader) (controlNs string)

GetControlNs gets control namespace of deploying cluster scope services

func GetCsScope

func GetCsScope(cm *corev1.ConfigMap, cpfsNamespace string) ([]string, error)

GetCsScope fetchs the namespaces from its own requested-from-namespace and map-to-common-service-namespace

func GetEnableOpreqWebhook

func GetEnableOpreqWebhook() bool

GetEnableOpreqWebhook check if enable the webhook for the OperandRequest

func GetImage

func GetImage(imageName string) string

func GetNSSCMSynchronization

func GetNSSCMSynchronization() bool

GetNSSCMSynchronization returns whether NSS ConfigMap shchronization with OperatorGroup is enabled

func GetNssCmNs

func GetNssCmNs(r client.Reader, cpfsNamespace string) (nssCmNs []string)

GetNssCmNs gets namespaces from namespace-scope ConfigMap

func GetOperatorName

func GetOperatorName() (string, error)

GetOperatorName return the operator name

func GetOperatorNamespace

func GetOperatorNamespace() (string, error)

GetOperatorNamespace returns the namespace the operator should be running in.

func GetRequestNs

func GetRequestNs(r client.Reader) (requestNs []string)

GetRequestNs gets requested-from-namespace of map-to-common-service-namespace

func GetResourcesDynamically

func GetResourcesDynamically(ctx context.Context, dynamic dynamic.Interface, group string, version string, resource string) (
	[]unstructured.Unstructured, error)

func GetServicesNamespace

func GetServicesNamespace(r client.Reader) (servicesNamespace string)

GetServicesNamespace returns the namespace where foundational services CRs should be running

func GetWatchNamespace

func GetWatchNamespace() string

GetWatchNamespace returns the list of namespaces that the operator watches

func KeyToNamespacedKey

func KeyToNamespacedKey(ns string, baseKey string) string

KeyToNamespacedKey prefixes the given index key with a namespace for use in field selector indexes.

func Namespacelize

func Namespacelize(resource, placeholder, ns string) string

Namespacelize adds the namespace specified

func NewCSCache

func NewCSCache(clusterGVKList []schema.GroupVersionKind, gvkLabelMap map[schema.GroupVersionKind]filteredcache.Selector, watchNamespaceList []string) cache.NewCacheFunc

NewCSCache implements a customized cache with a for CS

func NewUnstructured

func NewUnstructured(group, kind, version string) *unstructured.Unstructured

NewUnstructured return Unstructured object

func NewUnstructuredList

func NewUnstructuredList(group, kind, version string) *unstructured.UnstructuredList

NewUnstructuredList return UnstructuredList object

func ObjectListToNewUnstructuredList

func ObjectListToNewUnstructuredList(objs interface{}) (*unstructured.UnstructuredList, error)

func ReplaceImages

func ReplaceImages(resource string) (result string)

func Reverse

func Reverse(original []string) []string

Reverse resverses the string

func UpdateAllNSList

func UpdateAllNSList(r client.Reader, c client.Client, cm *corev1.ConfigMap, nssKey, nssNs string) error

UpdateAllNSList updates all adopter and CS namespaces into NSS CR

func UpdateCsMaps

func UpdateCsMaps(cm *corev1.ConfigMap, requestNsList, servicesNS, operatorNs string) error

UpdateCsMaps will update namespaceMapping in common-service-maps

func UpdateNSList

func UpdateNSList(r client.Reader, c client.Client, cm *corev1.ConfigMap, nssKey, cpfsNamespace string, addControlNs bool) error

UpdateNSList updates adopter namespaces of Common Services

func ValidateCsMaps

func ValidateCsMaps(cm *corev1.ConfigMap) error

ValidateCsMaps checks common-service-maps has no scope overlapping

func YamlToObject

func YamlToObject(yamlContent []byte) (*unstructured.Unstructured, error)

YamlToObject converting large yaml file, we can remove it after using "apimachinery" v0.19.0

func YamlToObjects

func YamlToObjects(yamlContent []byte) ([]*unstructured.Unstructured, error)

YamlToObjects convert YAML content to unstructured objects

Types

type CSCache

type CSCache struct {
	Scheme *runtime.Scheme
	// contains filtered or unexported fields
}

CSCache is the customized cache for CS

func (CSCache) Get

func (c CSCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error

Get implements Reader If the resource is in the cache, Get function get fetch in from the informer Otherwise, resource will be get by the k8s client

func (CSCache) GetInformer

func (c CSCache) GetInformer(ctx context.Context, obj client.Object) (cache.Informer, error)

GetInformer fetches or constructs an informer for the given object that corresponds to a single API kind and resource.

func (CSCache) GetInformerForKind

func (c CSCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind) (cache.Informer, error)

GetInformerForKind is similar to GetInformer, except that it takes a group-version-kind, instead of the underlying object.

func (CSCache) IndexField

func (c CSCache) IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error

IndexField adds an indexer to the underlying cache, using extraction function to get value(s) from the given field. The filtered cache doesn't support the index yet.

func (CSCache) List

func (c CSCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error

List lists items out of the indexer and writes them to list

func (CSCache) Start

func (c CSCache) Start(ctx context.Context) error

Start runs all the informers known to this cache until the given channel is closed. It blocks.

func (CSCache) WaitForCacheSync

func (c CSCache) WaitForCacheSync(ctx context.Context) bool

WaitForCacheSync waits for all the caches to sync. Returns false if it could not sync a cache.

type CsMaps

type CsMaps struct {
	ControlNs     string      `json:"controlNamespace"`
	NsMappingList []NsMapping `json:"namespaceMapping"`
}

type NsMapping

type NsMapping struct {
	RequestNs []string `json:"requested-from-namespace"`
	CsNs      string   `json:"map-to-common-service-namespace"`
}

Jump to

Keyboard shortcuts

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