common

package
v4.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 36 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 CompareObj

func CompareObj(newObj *unstructured.Unstructured, existingObj *unstructured.Unstructured) (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 EncodeBase64

func EncodeBase64(data []byte) string

EncodeBase64 encodes data to base64 string

func EnsureLabels

func EnsureLabels(resource *unstructured.Unstructured, labels map[string]string)

EnsureLabels ensures that the specifc resource has the certain labels

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 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, error)

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 GetFirstNCharacter

func GetFirstNCharacter(str string, n int) string

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) ([]string, error)

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 GetPackageNameByServiceName

func GetPackageNameByServiceName(opreg *odlm.OperandRegistry, operatorName string) string

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 GetUtilsImage added in v4.12.0

func GetUtilsImage() string

func GetWatchNamespace

func GetWatchNamespace() string

GetWatchNamespace returns the list of namespaces that the operator watches

func Namespacelize

func Namespacelize(resource, placeholder, ns string) string

Namespacelize adds the namespace specified

func NewCSCache

func NewCSCache(watchNamespaceList []string, opts ctrl.Options) ctrl.Options

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 ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads file from local path

func ReplaceImages

func ReplaceImages(resource string) (result string)

func Reverse

func Reverse(original []string) []string

Reverse resverses the string

func SanitizeData

func SanitizeData(data interface{}, valueType string, isEmpty bool) interface{}

SanitizeData keep the key-value pair in the map if the value fulfill the valueType and requirement

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 UpdateOpRegUserManaged

func UpdateOpRegUserManaged(opreg *odlm.OperandRegistry, operatorName string, value bool) error

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 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