util

package
v0.0.0-...-5d42de7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: Apache-2.0 Imports: 66 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// OPENSHIFT denotes to create an OpenShift routes
	OPENSHIFT = "OPENSHIFT"
	// NONE denotes no exposed service
	NONE = "NONE"
	// NODEPORT denotes to create a NodePort service
	NODEPORT = "NODEPORT"
	// LOADBALANCER denotes to create a LoadBalancer service
	LOADBALANCER = "LOADBALANCER"
)
View Source
const (
	// AlertCRDName is the name of an Alert CRD
	AlertCRDName = "alerts.synopsys.com"
	// BlackDuckCRDName is the name of the Black Duck CRD
	BlackDuckCRDName = "blackducks.synopsys.com"
	// OpsSightCRDName is the name of an OpsSight CRD
	OpsSightCRDName = "opssights.synopsys.com"
	// PrmCRDName is the name of the Polaris Reporting Module CRD
	PrmCRDName = "prms.synopsys.com"

	// OperatorName is the name of an Operator
	OperatorName = "synopsys-operator"
	// AlertName is the name of an Alert app
	AlertName = "alert"
	// BlackDuckName is the name of the Black Duck app
	BlackDuckName = "blackduck"
	// OpsSightName is the name of an OpsSight app
	OpsSightName = "opssight"
	// PrmName is the name of the Prm app
	PrmName = "prm"
)

Variables

This section is empty.

Functions

func ArePodsReady

func ArePodsReady(clientset *kubernetes.Clientset, namespace string, labelSelector string) (bool, error)

ArePodsReady returns whether the pods are ready or not. Returns an error if pods will never become ready.

func Base64Decode

func Base64Decode(data string) (string, error)

Base64Decode will return a decoded string using a URL-compatible base64 format; decoding may return an error, which you can check if you don’t already know the input to be well-formed.

func Base64Encode

func Base64Encode(data []byte) string

Base64Encode will return an encoded string using a URL-compatible base64 format

func BoolToPtr

func BoolToPtr(b bool) *bool

BoolToPtr will convert bool to pointer

func CheckAndUpdateNamespace

func CheckAndUpdateNamespace(kubeClient *kubernetes.Clientset, resourceName string, namespace string, name string, version string, isDelete bool) (bool, error)

CheckAndUpdateNamespace will check whether the namespace is exist and if exist, update the version label in namespace of the updated/deleted resource

func CheckResourceNamespace

func CheckResourceNamespace(kubeClient *kubernetes.Clientset, namespace string, label string, isOperator bool) (bool, error)

CheckResourceNamespace checks whether namespace is having any resource types

func ConvertYamlFileToRuntimeObjects

func ConvertYamlFileToRuntimeObjects(stringContent string) (map[string]runtime.Object, error)

ConvertYamlFileToRuntimeObjects converts the yaml file string to map of runtime object

func CreateAlert

func CreateAlert(alertClientset *alertclientset.Clientset, namespace string, createAlert *alertapi.Alert) (*alertapi.Alert, error)

CreateAlert will create alert in the cluster

func CreateBlackduck

func CreateBlackduck(blackduckClientset *hubclientset.Clientset, namespace string, createHub *blackduckapi.Blackduck) (*blackduckapi.Blackduck, error)

CreateBlackduck will create hub in the cluster

func CreateClusterRoleBinding

func CreateClusterRoleBinding(namespace string, name string, serviceAccountName string, clusterRoleAPIGroup string, clusterRoleKind string, clusterRoleName string) *components.ClusterRoleBinding

CreateClusterRoleBinding creates a cluster role binding

func CreateConfigMapVolume

func CreateConfigMapVolume(volumeName string, mapName string, defaultMode int) (*components.Volume, error)

CreateConfigMapVolume will mount the config map for a pod

func CreateContainer

func CreateContainer(config *horizonapi.ContainerConfig, envs []*horizonapi.EnvConfig, volumeMounts []*horizonapi.VolumeMountConfig, ports []*horizonapi.PortConfig,
	actionConfig *horizonapi.ActionConfig, preStopConfig *horizonapi.ActionConfig, livenessProbeConfigs []*horizonapi.ProbeConfig, readinessProbeConfigs []*horizonapi.ProbeConfig) (*components.Container, error)

CreateContainer will create the container

func CreateDeployment

func CreateDeployment(deploymentConfig *horizonapi.DeploymentConfig, pod *components.Pod, labels map[string]string, labelSelector map[string]string) *components.Deployment

CreateDeployment will create a deployment

func CreateDeploymentFromContainer

func CreateDeploymentFromContainer(deploymentConfig *horizonapi.DeploymentConfig, podConfig *PodConfig, labelSelector map[string]string) (*components.Deployment, error)

CreateDeploymentFromContainer will create a deployment with multiple containers inside a pod

func CreateEmptyDirVolume

func CreateEmptyDirVolume(volumeName string, sizeLimit string) (*components.Volume, error)

CreateEmptyDirVolume will create a empty directory for a pod

func CreateEmptyDirVolumeWithoutSizeLimit

func CreateEmptyDirVolumeWithoutSizeLimit(volumeName string) (*components.Volume, error)

CreateEmptyDirVolumeWithoutSizeLimit will create a empty directory for a pod

func CreateExecContainerRequest

func CreateExecContainerRequest(clientset *kubernetes.Clientset, pod *corev1.Pod, command string) *rest.Request

CreateExecContainerRequest will create the request to exec into Kubernetes pod

func CreateGCEPersistentDiskVolume

func CreateGCEPersistentDiskVolume(volumeName string, diskName string, fsType string) *components.Volume

CreateGCEPersistentDiskVolume will create a GCE Persistent disk volume for a pod

func CreateHelmActionConfiguration

func CreateHelmActionConfiguration(kubeConfig, kubeContext, namespace string) (*action.Configuration, error)

CreateHelmActionConfiguration creates an action.Configuration that points to the specified cluster and namespace

func CreateNamespace

func CreateNamespace(clientset *kubernetes.Clientset, namespace string) (*corev1.Namespace, error)

CreateNamespace will create the namespace

func CreateOpsSight

func CreateOpsSight(opssightClientset *opssightclientset.Clientset, namespace string, opssight *opssightapi.OpsSight) (*opssightapi.OpsSight, error)

CreateOpsSight will create opsSight in the cluster

func CreatePersistentVolume

func CreatePersistentVolume(clientset *kubernetes.Clientset, name string, storageClass string, claimSize string, nfsPath string, nfsServer string) (*corev1.PersistentVolume, error)

CreatePersistentVolume will create the persistent volume

func CreatePersistentVolumeClaim

func CreatePersistentVolumeClaim(name string, namespace string, pvcClaimSize string, storageClass string, accessMode horizonapi.PVCAccessModeType) (*components.PersistentVolumeClaim, error)

CreatePersistentVolumeClaim will create the persistent volume claim

func CreatePersistentVolumeClaimVolume

func CreatePersistentVolumeClaimVolume(volumeName string, pvcName string) (*components.Volume, error)

CreatePersistentVolumeClaimVolume will create a PVC claim for a pod

func CreatePod

func CreatePod(podConfig *PodConfig) (*components.Pod, error)

CreatePod will create the pod

func CreateReplicationController

func CreateReplicationController(replicationControllerConfig *horizonapi.ReplicationControllerConfig, pod *components.Pod, labels map[string]string,
	labelSelector map[string]string) *components.ReplicationController

CreateReplicationController will create a replication controller

func CreateReplicationControllerFromContainer

func CreateReplicationControllerFromContainer(replicationControllerConfig *horizonapi.ReplicationControllerConfig, podConfig *PodConfig, labelSelector map[string]string) (*components.ReplicationController, error)

CreateReplicationControllerFromContainer will create a replication controller with multiple containers inside a pod

func CreateRoute

func CreateRoute(routeClient *routeclient.RouteV1Client, namespace string, route *routev1.Route) (*routev1.Route, error)

CreateRoute creates an OpenShift routes

func CreateSecret

func CreateSecret(clientset *kubernetes.Clientset, namespace string, name string, stringData map[string]string) (*corev1.Secret, error)

CreateSecret will create the secret

func CreateSecretFromFile

func CreateSecretFromFile(clientset *kubernetes.Clientset, jsonFile string, namespace string, name string, dataKey string) (*corev1.Secret, error)

CreateSecretFromFile will create the secret from file

func CreateSecretVolume

func CreateSecretVolume(volumeName string, secretName string, defaultMode int) (*components.Volume, error)

CreateSecretVolume will mount the secret for a pod

func CreateService

func CreateService(name string, selectLabel map[string]string, namespace string, port int32, target int32, serviceType horizonapi.ServiceType, label map[string]string) *components.Service

CreateService will create the service

func CreateServiceAccount

func CreateServiceAccount(namespace string, name string) *components.ServiceAccount

CreateServiceAccount creates a service account

func CreateServiceWithMultiplePort

func CreateServiceWithMultiplePort(name string, selectLabel map[string]string, namespace string, ports []int32, serviceType horizonapi.ServiceType, label map[string]string) *components.Service

CreateServiceWithMultiplePort will create the service with multiple port

func CreateWithHelm3

func CreateWithHelm3(releaseName, namespace, chartURL string, vals map[string]interface{}, kubeConfig string, dryRun bool) error

CreateWithHelm3 uses the helm NewInstall action to create a resource in the cluster Modified from https://github.com/openshift/console/blob/cdf6b189b71e488033ecaba7d90258d9f9453478/pkg/helm/actions/install_chart.go Helm Actions: https://github.com/helm/helm/tree/9bc7934f350233fa72a11d2d29065aa78ab62792/pkg/action

func DeleteAlert

func DeleteAlert(clientSet *alertclientset.Clientset, name string, namespace string, options *metav1.DeleteOptions) error

DeleteAlert will delete Alert in the cluster

func DeleteBlackduck

func DeleteBlackduck(blackduckClientset *hubclientset.Clientset, name string, namespace string, options *metav1.DeleteOptions) error

DeleteBlackduck will delete Blackduck in the cluster

func DeleteClusterRole

func DeleteClusterRole(clientset *kubernetes.Clientset, name string) error

DeleteClusterRole delete a cluster role

func DeleteClusterRoleBinding

func DeleteClusterRoleBinding(clientset *kubernetes.Clientset, name string) error

DeleteClusterRoleBinding delete a cluster role binding

func DeleteConfigMap

func DeleteConfigMap(clientset *kubernetes.Clientset, namespace string, name string) error

DeleteConfigMap will delete the config map

func DeleteCustomResourceDefinition

func DeleteCustomResourceDefinition(apiExtensionClient *apiextensionsclient.Clientset, name string) error

DeleteCustomResourceDefinition deletes the custom resource defintion

func DeleteDeployment

func DeleteDeployment(clientset *kubernetes.Clientset, namespace string, name string) error

DeleteDeployment will delete the deployment corresponding to a namespace and name

func DeleteNamespace

func DeleteNamespace(clientset *kubernetes.Clientset, namespace string) error

DeleteNamespace will delete the namespace

func DeleteOpsSight

func DeleteOpsSight(clientSet *opssightclientset.Clientset, name string, namespace string, options *metav1.DeleteOptions) error

DeleteOpsSight will delete OpsSight in the cluster

func DeletePVC

func DeletePVC(clientset *kubernetes.Clientset, namespace string, name string) error

DeletePVC will delete the PVC information for the input pvc name inside the input namespace

func DeletePersistentVolume

func DeletePersistentVolume(clientset *kubernetes.Clientset, name string) error

DeletePersistentVolume will delete the persistent volume

func DeletePod

func DeletePod(clientset *kubernetes.Clientset, namespace string, name string) error

DeletePod will delete the input pods corresponding to a namespace

func DeleteReplicationController

func DeleteReplicationController(clientset *kubernetes.Clientset, namespace string, name string) error

DeleteReplicationController will delete the replication controller corresponding to a namespace and name

func DeleteResourceNamespace

func DeleteResourceNamespace(kubeClient *kubernetes.Clientset, resourceName string, namespace string, name string, isOperator bool) error

DeleteResourceNamespace deletes the namespace if none of the other resource types are running

func DeleteRole

func DeleteRole(clientset *kubernetes.Clientset, namespace string, name string) error

DeleteRole delete a role

func DeleteRoleBinding

func DeleteRoleBinding(clientset *kubernetes.Clientset, namespace string, name string) error

DeleteRoleBinding delete a role binding

func DeleteRoute

func DeleteRoute(routeClient *routeclient.RouteV1Client, namespace string, name string) error

DeleteRoute deletes an OpenShift routes

func DeleteSecret

func DeleteSecret(clientset *kubernetes.Clientset, namespace string, name string) error

DeleteSecret will delete the secret

func DeleteService

func DeleteService(clientset *kubernetes.Clientset, namespace string, name string) error

DeleteService will delete the service information for the input service name inside the input namespace

func DeleteServiceAccount

func DeleteServiceAccount(clientset *kubernetes.Clientset, namespace string, name string) error

DeleteServiceAccount delete a service account

func DeleteWithHelm3

func DeleteWithHelm3(releaseName, namespace, kubeConfig string) error

DeleteWithHelm3 uses the helm NewUninstall action to delete a resource from the cluster

func EncodeStringToBase64

func EncodeStringToBase64(str string) string

EncodeStringToBase64 will return encoded string to base64

func EnsureFilterPodsByNamePrefixInNamespaceToZero

func EnsureFilterPodsByNamePrefixInNamespaceToZero(clientset *kubernetes.Clientset, namespace string, prefix string) error

EnsureFilterPodsByNamePrefixInNamespaceToZero filters the pods based on the prefix and make sure that it is zero

func ExecContainer

func ExecContainer(kubeConfig *rest.Config, request *rest.Request, command []string) (string, error)

ExecContainer will exec into the container and run the commands provided in the input

func FilterPodByNamePrefix

func FilterPodByNamePrefix(pods *corev1.PodList, prefix string) *corev1.Pod

FilterPodByNamePrefix will filter the pod based on pod name prefix from a list a pods

func FilterPodByNamePrefixInNamespace

func FilterPodByNamePrefixInNamespace(clientset *kubernetes.Clientset, namespace string, prefix string) (*corev1.Pod, error)

FilterPodByNamePrefixInNamespace will filter the pod based on pod name prefix from a list a pods in a given namespace

func GeneratePemSelfSignedCertificateAndKey

func GeneratePemSelfSignedCertificateAndKey(name pkix.Name) (string, string, error)

GeneratePemSelfSignedCertificateAndKey returns a self-signed certificate and its key

func GetActionConfigurations

func GetActionConfigurations(host, namespace, token string, transport *http.RoundTripper) *action.Configuration

GetActionConfigurations creates an action.Configuration that points to the specified cluster and namespace TODO - this function specifies more values than CreateHelmActionConfiguration(), consider using this

func GetAlert

func GetAlert(clientSet *alertclientset.Clientset, namespace string, name string, options metav1.GetOptions) (*alertapi.Alert, error)

GetAlert will get Alert in the cluster

func GetAlertDefault

func GetAlertDefault() *alertv1.AlertSpec

GetAlertDefault creates an Alert crd configuration object with defaults

func GetAlertTemplate

func GetAlertTemplate() *alertv1.AlertSpec

GetAlertTemplate returns the required fields for Alert

func GetAlerts

func GetAlerts(clientSet *alertclientset.Clientset) (*alertapi.AlertList, error)

GetAlerts gets all alerts

func GetBaseYaml

func GetBaseYaml(baseurl string, appName string, version string, fileName string) (string, error)

GetBaseYaml returns the base yaml as string for the given app and version

func GetBlackDuckDefaultBDBA

func GetBlackDuckDefaultBDBA() *blackduckv1.BlackduckSpec

GetBlackDuckDefaultBDBA returns a BlackDuck with BDBA

func GetBlackDuckDefaultEphemeral

func GetBlackDuckDefaultEphemeral() *blackduckv1.BlackduckSpec

GetBlackDuckDefaultEphemeral returns a BlackDuck with ephemeral storage

func GetBlackDuckDefaultEphemeralCustomAuthCA

func GetBlackDuckDefaultEphemeralCustomAuthCA() *blackduckv1.BlackduckSpec

GetBlackDuckDefaultEphemeralCustomAuthCA returns a BlackDuck with ephemeral storage using custom auth CA

func GetBlackDuckDefaultExternalDB

func GetBlackDuckDefaultExternalDB() *blackduckv1.BlackduckSpec

GetBlackDuckDefaultExternalDB returns a BlackDuck with an external Data Base

func GetBlackDuckDefaultExternalPersistentStorageLatest

func GetBlackDuckDefaultExternalPersistentStorageLatest() *blackduckv1.BlackduckSpec

GetBlackDuckDefaultExternalPersistentStorageLatest creates a BlackDuck crd configuration object with defaults and external persistent storage for latest BlackDuck

func GetBlackDuckDefaultExternalPersistentStorageV1

func GetBlackDuckDefaultExternalPersistentStorageV1() *blackduckv1.BlackduckSpec

GetBlackDuckDefaultExternalPersistentStorageV1 creates a BlackDuck crd configuration object with defaults and external persistent storage for V1 BlackDuck

func GetBlackDuckDefaultIPV6Disabled

func GetBlackDuckDefaultIPV6Disabled() *blackduckv1.BlackduckSpec

GetBlackDuckDefaultIPV6Disabled returns a BlackDuck with IPV6 Disabled

func GetBlackDuckDefaultPersistentStorageLatest

func GetBlackDuckDefaultPersistentStorageLatest() *blackduckv1.BlackduckSpec

GetBlackDuckDefaultPersistentStorageLatest creates a Black Duck crd configuration object with defaults and persistent storage

func GetBlackDuckDefaultPersistentStorageV1

func GetBlackDuckDefaultPersistentStorageV1() *blackduckv1.BlackduckSpec

GetBlackDuckDefaultPersistentStorageV1 creates a BlackDuck crd configuration object with defaults and persistent storage for V1 BlackDuck

func GetBlackDuckTemplate

func GetBlackDuckTemplate() *blackduckv1.BlackduckSpec

GetBlackDuckTemplate returns the required fields for Black Duck

func GetBlackduck

func GetBlackduck(blackduckClientset *hubclientset.Clientset, namespace string, name string, options metav1.GetOptions) (*blackduckapi.Blackduck, error)

GetBlackduck will get hubs in the cluster

func GetCRDNamesFromConfigMap

func GetCRDNamesFromConfigMap(kubeClient *kubernetes.Clientset, namespace string) (string, error)

GetCRDNamesFromConfigMap get CRD names from the Synopsys Operator config map

func GetClusterRole

func GetClusterRole(clientset *kubernetes.Clientset, name string) (*rbacv1.ClusterRole, error)

GetClusterRole get a cluster role

func GetClusterRoleBinding

func GetClusterRoleBinding(clientset *kubernetes.Clientset, name string) (*rbacv1.ClusterRoleBinding, error)

GetClusterRoleBinding get a cluster role

func GetClusterScope

func GetClusterScope(apiExtensionClient *apiextensionsclient.Clientset) bool

GetClusterScope returns whether any of the CRD is cluster scope

func GetClusterScopeByName

func GetClusterScopeByName(apiExtensionClient *apiextensionsclient.Clientset, name string) bool

GetClusterScopeByName returns whether the CRD is cluster scope

func GetConfigMap

func GetConfigMap(clientset *kubernetes.Clientset, namespace string, name string) (*corev1.ConfigMap, error)

GetConfigMap will get the config map

func GetCustomResourceDefinition

func GetCustomResourceDefinition(apiExtensionClient *apiextensionsclient.Clientset, name string) (*apiextensions.CustomResourceDefinition, error)

GetCustomResourceDefinition get the custom resource defintion

func GetDeployment

func GetDeployment(clientset *kubernetes.Clientset, namespace string, name string) (*appsv1.Deployment, error)

GetDeployment will get the deployment corresponding to a namespace and name

func GetImageName

func GetImageName(image string) (string, error)

GetImageName takes a docker image string and returns the name

func GetImageTag

func GetImageTag(image string) (string, error)

GetImageTag takes a docker image string and returns the tag

func GetKubernetesVersion

func GetKubernetesVersion(clientset *kubernetes.Clientset) (string, error)

GetKubernetesVersion will return the kubernetes version

func GetNamespace

func GetNamespace(clientset *kubernetes.Clientset, namespace string) (*corev1.Namespace, error)

GetNamespace will get the namespace

func GetOpenShiftSecurityConstraint

func GetOpenShiftSecurityConstraint(osSecurityClient *securityclient.SecurityV1Client, name string) (*securityv1.SecurityContextConstraints, error)

GetOpenShiftSecurityConstraint gets an OpenShift security constraints

func GetOperatorNamespace

func GetOperatorNamespace(clientset *kubernetes.Clientset, namespace string) ([]string, error)

GetOperatorNamespace uses labels to return the namespace of the synopsys operator based on the provided namespace. In cluster scoped mode it will return the namespaces of all operators if provided namespace=NamespaceAll. In namespace scoped mode it will return nil if there is no operator in the namespace

func GetOperatorNamespaceByCRDScope

func GetOperatorNamespaceByCRDScope(kubeClient *kubernetes.Clientset, crdName string, scope apiextensions.ResourceScope, namespace string) (string, error)

GetOperatorNamespaceByCRDScope get the operator namespace by CRD scope

func GetOperatorRoleBindings

func GetOperatorRoleBindings(clientset *kubernetes.Clientset, namespace string) ([]string, []string, error)

GetOperatorRoleBindings returns the cluster role bindings of the synopsys operator based on the labels

func GetOperatorRoles

func GetOperatorRoles(clientset *kubernetes.Clientset, namespace string) ([]string, []string, error)

GetOperatorRoles returns the roles or the cluster role of the synopsys operator based on the labels

func GetOpsSight

func GetOpsSight(opssightClientset *opssightclientset.Clientset, namespace string, name string, options metav1.GetOptions) (*opssightapi.OpsSight, error)

GetOpsSight will get OpsSight in the cluster

func GetOpsSightDefault

func GetOpsSightDefault() *opssightv1.OpsSightSpec

GetOpsSightDefault returns the required fields for OpsSight

func GetOpsSightDefaultWithIPV6DisabledBlackDuck

func GetOpsSightDefaultWithIPV6DisabledBlackDuck() *opssightv1.OpsSightSpec

GetOpsSightDefaultWithIPV6DisabledBlackDuck retuns an OpsSight with a BlackDuck and IPV6 disabled

func GetOpsSightUpstream

func GetOpsSightUpstream() *opssightv1.OpsSightSpec

GetOpsSightUpstream returns the required fields for an upstream OpsSight

func GetOpsSights

func GetOpsSights(clientSet *opssightclientset.Clientset) (*opssightapi.OpsSightList, error)

GetOpsSights gets all opssights

func GetPVC

func GetPVC(clientset *kubernetes.Clientset, namespace string, name string) (*corev1.PersistentVolumeClaim, error)

GetPVC will get the PVC for the given name

func GetPod

func GetPod(clientset *kubernetes.Clientset, namespace string, name string) (*corev1.Pod, error)

GetPod will get the input pods corresponding to a namespace

func GetRandomString

func GetRandomString(n int) (string, error)

GetRandomString returns a random hexadecimal string of length n.

func GetReplicationController

func GetReplicationController(clientset *kubernetes.Clientset, namespace string, name string) (*corev1.ReplicationController, error)

GetReplicationController will get the replication controller corresponding to a namespace and name

func GetResourceName

func GetResourceName(name string, appName string, defaultName string) string

GetResourceName returns the name of the resource

func GetRole

func GetRole(clientset *kubernetes.Clientset, namespace string, name string) (*rbacv1.Role, error)

GetRole get a role

func GetRoleBinding

func GetRoleBinding(clientset *kubernetes.Clientset, namespace string, name string) (*rbacv1.RoleBinding, error)

GetRoleBinding get a role binding

func GetRoute

func GetRoute(routeClient *routeclient.RouteV1Client, namespace string, name string) (*routev1.Route, error)

GetRoute gets an OpenShift routes

func GetRouteClient

func GetRouteClient(restConfig *rest.Config, clientset *kubernetes.Clientset, namespace string) *routeclient.RouteV1Client

GetRouteClient attempts to get a Route Client. It returns nil if it fails due to an error or due to being on kubernetes (doesn't support routes)

func GetRouteComponent

func GetRouteComponent(routeClient *routeclient.RouteV1Client, route *api.Route, labels map[string]string) *routev1.Route

GetRouteComponent returns the route component

func GetSecret

func GetSecret(clientset *kubernetes.Clientset, namespace string, name string) (*corev1.Secret, error)

GetSecret will create the secret

func GetService

func GetService(clientset *kubernetes.Clientset, namespace string, serviceName string) (*corev1.Service, error)

GetService will get the service information for the input service name inside the input namespace

func GetServiceAccount

func GetServiceAccount(clientset *kubernetes.Clientset, namespace string, name string) (*corev1.ServiceAccount, error)

GetServiceAccount get a service account

func GetServiceEndPoint

func GetServiceEndPoint(clientset *kubernetes.Clientset, namespace string, serviceName string) (*corev1.Endpoints, error)

GetServiceEndPoint will get the service endpoint information for the input service name inside the input namespace

func GetWithHelm3

func GetWithHelm3(releaseName, namespace, kubeConfig string) (*release.Release, error)

GetWithHelm3 uses the helm NewGet action to return a Release with information about a resource from the cluster

func HTTPGet

func HTTPGet(url string) (content []byte, err error)

HTTPGet returns the http response for the api

func InitAnnotations

func InitAnnotations(annotations map[string]string) map[string]string

InitAnnotations initialize the annotation

func InitLabels

func InitLabels(labels map[string]string) map[string]string

InitLabels initialize the label

func Int32ToInt

func Int32ToInt(i *int32) int

Int32ToInt will convert from int32 to int

func IntToInt32

func IntToInt32(i int) *int32

IntToInt32 will convert from int to int32

func IntToInt64

func IntToInt64(i int) *int64

IntToInt64 will convert from int to int64

func IntToPtr

func IntToPtr(i int) *int

IntToPtr will convert int to pointer

func IntToUInt32

func IntToUInt32(i int) uint32

IntToUInt32 will convert from int to uint32

func IsBlackDuckVersionSupportMultipleInstance

func IsBlackDuckVersionSupportMultipleInstance(version string) (bool, error)

IsBlackDuckVersionSupportMultipleInstance returns whether it supports multiple instance in a single namespace

func IsClusterRoleBindingSubjectNamespaceExist

func IsClusterRoleBindingSubjectNamespaceExist(subjects []rbacv1.Subject, namespace string) bool

IsClusterRoleBindingSubjectNamespaceExist checks whether the namespace is already exist in the subject of cluster role binding

func IsClusterRoleRefExistForOtherNamespace

func IsClusterRoleRefExistForOtherNamespace(roleRef rbacv1.RoleRef, roleName string, namespace string, subjects []rbacv1.Subject) bool

IsClusterRoleRefExistForOtherNamespace checks whether the cluster role exist for any cluster role bindings present in other namespace

func IsClusterRoleRuleExist

func IsClusterRoleRuleExist(oldRules []rbacv1.PolicyRule, newRule rbacv1.PolicyRule) bool

IsClusterRoleRuleExist checks whether the namespace is already exist in the rule of cluster role

func IsExistInStringSlice

func IsExistInStringSlice(slice []string, str string) bool

IsExistInStringSlice will check for the input string in the given slice

func IsExposeServiceValid

func IsExposeServiceValid(serviceType string) bool

IsExposeServiceValid validates the expose service type

func IsNotDefaultVersionGreaterThanOrEqualTo

func IsNotDefaultVersionGreaterThanOrEqualTo(version string, majorRelease int, minorRelease int, dotRelease int) (bool, error)

IsNotDefaultVersionGreaterThanOrEqualTo returns whether the given version is greater than or equal to the given inputs

func IsOpenshift

func IsOpenshift(clientset *kubernetes.Clientset) bool

IsOpenshift will whether it is an openshift cluster

func IsOperatorExist

func IsOperatorExist(clientset *kubernetes.Clientset, namespace string) bool

IsOperatorExist returns whether the operator exist or not

func IsOwnerLabelExistInNamespace

func IsOwnerLabelExistInNamespace(kubeClient *kubernetes.Clientset, namespace string) bool

IsOwnerLabelExistInNamespace check for owner label exist in the namespace

func IsSubjectExist

func IsSubjectExist(subjects []rbacv1.Subject, namespace string, name string) bool

IsSubjectExist checks whether the namespace is already exist in the subject of cluster role binding

func IsSubjectExistForOtherNamespace

func IsSubjectExistForOtherNamespace(subject rbacv1.Subject, namespace string) bool

IsSubjectExistForOtherNamespace checks whether anyother namespace is exist in the subject of cluster role binding

func IsVersionEqualTo

func IsVersionEqualTo(version string, year int, month time.Month, dotRelease int) (bool, error)

IsVersionEqualTo returns whether the given version is equal to the given year, month and dot release

func IsVersionGreaterThanOrEqualTo

func IsVersionGreaterThanOrEqualTo(version string, year int, month time.Month, dotRelease int) (bool, error)

IsVersionGreaterThanOrEqualTo returns whether the given version is greater than or equal to the given year, month and dot release

func ListAlerts

func ListAlerts(clientSet *alertclientset.Clientset, namespace string, opts metav1.ListOptions) (*alertapi.AlertList, error)

ListAlerts will list all alerts in the cluster

func ListBlackduck

func ListBlackduck(blackduckClientset *hubclientset.Clientset, namespace string, opts metav1.ListOptions) (*blackduckapi.BlackduckList, error)

ListBlackduck gets all blackducks

func ListClusterRoleBindings

func ListClusterRoleBindings(clientset *kubernetes.Clientset, labelSelector string) (*rbacv1.ClusterRoleBindingList, error)

ListClusterRoleBindings list a cluster role binding

func ListClusterRoles

func ListClusterRoles(clientset *kubernetes.Clientset, labelSelector string) (*rbacv1.ClusterRoleList, error)

ListClusterRoles list a cluster role

func ListConfigMaps

func ListConfigMaps(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*corev1.ConfigMapList, error)

ListConfigMaps will list the config map

func ListCustomResourceDefinitions

func ListCustomResourceDefinitions(apiExtensionClient *apiextensionsclient.Clientset, labelSelector string) (*apiextensions.CustomResourceDefinitionList, error)

ListCustomResourceDefinitions list the custom resource defintions

func ListDeployments

func ListDeployments(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*appsv1.DeploymentList, error)

ListDeployments will get all the deployments corresponding to a namespace

func ListHubPV

func ListHubPV(hubClientset *hubclientset.Clientset, namespace string) (map[string]string, error)

ListHubPV will list all the persistent volumes attached to each hub in the cluster

func ListNamespaces

func ListNamespaces(clientset *kubernetes.Clientset, labelSelector string) (*corev1.NamespaceList, error)

ListNamespaces will list the namespace

func ListOpsSights

func ListOpsSights(opssightClientset *opssightclientset.Clientset, namespace string, opts metav1.ListOptions) (*opssightapi.OpsSightList, error)

ListOpsSights will list all opssights in the cluster

func ListPVCs

func ListPVCs(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*corev1.PersistentVolumeClaimList, error)

ListPVCs will list the PVC for the given label selector

func ListPods

func ListPods(clientset *kubernetes.Clientset, namespace string) (*corev1.PodList, error)

ListPods will get all the pods corresponding to a namespace

func ListPodsWithLabels

func ListPodsWithLabels(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*corev1.PodList, error)

ListPodsWithLabels will get all the pods corresponding to a namespace and labels

func ListReplicationControllers

func ListReplicationControllers(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*corev1.ReplicationControllerList, error)

ListReplicationControllers will get the replication controllers corresponding to a namespace

func ListRoleBindings

func ListRoleBindings(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*rbacv1.RoleBindingList, error)

ListRoleBindings list a role binding

func ListRoles

func ListRoles(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*rbacv1.RoleList, error)

ListRoles list a role

func ListRoutes

func ListRoutes(routeClient *routeclient.RouteV1Client, namespace string, labelSelector string) (*routev1.RouteList, error)

ListRoutes list an OpenShift routes

func ListSecrets

func ListSecrets(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*corev1.SecretList, error)

ListSecrets will list the secret

func ListServiceAccounts

func ListServiceAccounts(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*corev1.ServiceAccountList, error)

ListServiceAccounts list a service account

func ListServices

func ListServices(clientset *kubernetes.Clientset, namespace string, labelSelector string) (*corev1.ServiceList, error)

ListServices will list the service information for the input service name inside the input namespace

func ListStorageClasses

func ListStorageClasses(clientset *kubernetes.Clientset) (*v1beta1.StorageClassList, error)

ListStorageClasses will list all the storageClass in the cluster

func LoadChart

func LoadChart(chartURL string, actionConfig *action.Configuration) (*chart.Chart, error)

LoadChart returns a chart from the specified chartURL Modified from https://github.com/openshift/console/blob/master/pkg/helm/actions/template_test.go

func MapKeyToStringArray

func MapKeyToStringArray(maps map[string]string) []string

MapKeyToStringArray will return map keys

func MapToStringArrayJoinBySeparator

func MapToStringArrayJoinBySeparator(maps map[string]string, separator string) []string

MapToStringArrayJoinBySeparator converts the map to string array and each key and value of the map will be joined by separator

func MergeEnvMaps

func MergeEnvMaps(source, destination map[string]string) map[string]string

MergeEnvMaps will merge the source and destination environs. If the same value exist in both, source environ will given more preference

func MergeEnvSlices

func MergeEnvSlices(source, destination []string) []string

MergeEnvSlices will merge the source and destination environs. If the same value exist in both, source environ will given more preference

func NewStringReader

func NewStringReader(ss []string) io.Reader

NewStringReader will convert string array to string reader object

func PatchDeployment

func PatchDeployment(clientset *kubernetes.Clientset, old appsv1.Deployment, new appsv1.Deployment) error

PatchDeployment patch a deployment

func PatchDeploymentForReplicas

func PatchDeploymentForReplicas(clientset *kubernetes.Clientset, old *appsv1.Deployment, replicas *int32) (*appsv1.Deployment, error)

PatchDeploymentForReplicas patch a deployment for replica update

func PatchReplicationController

func PatchReplicationController(clientset *kubernetes.Clientset, old corev1.ReplicationController, new corev1.ReplicationController, isUpdateReplica bool) error

PatchReplicationController patch a replication controller

func PatchReplicationControllerForReplicas

func PatchReplicationControllerForReplicas(clientset *kubernetes.Clientset, old *corev1.ReplicationController, replicas *int32) (*corev1.ReplicationController, error)

PatchReplicationControllerForReplicas patch a replication controller for replica update

func PrettyPrint

func PrettyPrint(v interface{}) (string, error)

PrettyPrint will print the interface in string format

func RandomString

func RandomString(n int) (string, error)

RandomString will generate the random string

func ReadFileData

func ReadFileData(filepath string) (string, error)

ReadFileData returns the information within a file as a string

func ReadFromFile

func ReadFromFile(filePath string) ([]byte, error)

ReadFromFile will read the file

func ReleaseExists

func ReleaseExists(releaseName, namespace, kubeConfig string) bool

ReleaseExists verifies that a resources is deployed in the cluster

func RemoveFromStringSlice

func RemoveFromStringSlice(slice []string, str string) []string

RemoveFromStringSlice will remove the string from the slice and it will maintain the order

func RenderManifests

func RenderManifests(releaseName, namespace string, chart *chart.Chart, vals map[string]interface{}, actionConfig *action.Configuration) (string, error)

RenderManifests converts a helm chart to a string of the kube manifest files Modified from https://github.com/openshift/console/blob/cdf6b189b71e488033ecaba7d90258d9f9453478/pkg/helm/actions/template_test.go

func SetHelmValueInMap

func SetHelmValueInMap(valueMapPointer map[string]interface{}, keyList []string, finalValue interface{})

SetHelmValueInMap adds the finalValue into the valueMapPointer at the location specified by the keyList valueMapPointer - a map for helm values (maps are pointers in Golang)

  • it is used to track the current map being updated

keyList - an ordered list of keys that lead to the location in the valueMapPointer to place the finalValue finalValue - the value to set in the map

func SetSecurityContextInPodConfig

func SetSecurityContextInPodConfig(podConfig *PodConfig, securityContext *SecurityContext, isOpenshift bool)

SetSecurityContextInPodConfig sets the Security Context fields in the PodConfig

func StringArrayToMapSplitBySeparator

func StringArrayToMapSplitBySeparator(strs []string, separator string) map[string]string

StringArrayToMapSplitBySeparator converts the string array to map based on separator for each string in the array

func StringToStringSlice

func StringToStringSlice(s string, sep string) []string

StringToStringSlice slices s into all substrings separated by sep

func TemplateWithHelm3

func TemplateWithHelm3(releaseName, namespace, chartURL string, vals map[string]interface{}) error

TemplateWithHelm3 prints the kube manifest files for a resource

func UniqueStringSlice

func UniqueStringSlice(input []string) []string

UniqueStringSlice returns a unique subset of the string slice provided.

func UniqueValues

func UniqueValues(input []string) []string

UniqueValues returns a unique subset of the string slice provided.

func UpdateAlert

func UpdateAlert(clientSet *alertclientset.Clientset, namespace string, alert *alertapi.Alert) (*alertapi.Alert, error)

UpdateAlert will update an Alert in the cluster

func UpdateAlerts

func UpdateAlerts(clientSet *alertclientset.Clientset, alertCRDs []alertapi.Alert) error

UpdateAlerts will update a set of Alerts in the cluster

func UpdateBlackduck

func UpdateBlackduck(blackduckClientset *hubclientset.Clientset, blackduck *blackduckapi.Blackduck) (*blackduckapi.Blackduck, error)

UpdateBlackduck will update Blackduck in the cluster

func UpdateBlackducks

func UpdateBlackducks(clientSet *hubclientset.Clientset, blackduckCRDs []blackduckapi.Blackduck) error

UpdateBlackducks will update a set of Blackducks in the cluster

func UpdateClusterRole

func UpdateClusterRole(clientset *kubernetes.Clientset, clusterRole *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error)

UpdateClusterRole updates the cluster role

func UpdateClusterRoleBinding

func UpdateClusterRoleBinding(clientset *kubernetes.Clientset, clusterRoleBinding *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error)

UpdateClusterRoleBinding updates the cluster role binding

func UpdateConfigMap

func UpdateConfigMap(clientset *kubernetes.Clientset, namespace string, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error)

UpdateConfigMap updates a config map

func UpdateCustomResourceDefinition

func UpdateCustomResourceDefinition(apiExtensionClient *apiextensionsclient.Clientset, crd *apiextensions.CustomResourceDefinition) (*apiextensions.CustomResourceDefinition, error)

UpdateCustomResourceDefinition updates the custom resource defintion

func UpdateDeployment

func UpdateDeployment(clientset *kubernetes.Clientset, namespace string, deployment *appsv1.Deployment) (*appsv1.Deployment, error)

UpdateDeployment updates the deployment

func UpdateNamespace

func UpdateNamespace(clientset *kubernetes.Clientset, namespace *corev1.Namespace) (*corev1.Namespace, error)

UpdateNamespace updates a namespace

func UpdateOpenShiftSecurityConstraint

func UpdateOpenShiftSecurityConstraint(osSecurityClient *securityclient.SecurityV1Client, serviceAccounts []string, name string) error

UpdateOpenShiftSecurityConstraint updates an OpenShift security constraints

func UpdateOpsSight

func UpdateOpsSight(opssightClientset *opssightclientset.Clientset, namespace string, opssight *opssightapi.OpsSight) (*opssightapi.OpsSight, error)

UpdateOpsSight will update OpsSight in the cluster

func UpdateOpsSights

func UpdateOpsSights(clientSet *opssightclientset.Clientset, opsSightCRDs []opssightapi.OpsSight) error

UpdateOpsSights will update a set of OpsSights in the cluster

func UpdatePVC

func UpdatePVC(clientset *kubernetes.Clientset, namespace string, pvc *corev1.PersistentVolumeClaim) (*corev1.PersistentVolumeClaim, error)

UpdatePVC will update the pvc information for the input pvc name inside the input namespace

func UpdateRegistry

func UpdateRegistry(obj map[string]runtime.Object, registry string) (map[string]runtime.Object, error)

UpdateRegistry updates the registry for all runtime objects containers

func UpdateReplicationController

func UpdateReplicationController(clientset *kubernetes.Clientset, namespace string, rc *corev1.ReplicationController) (*corev1.ReplicationController, error)

UpdateReplicationController updates the replication controller

func UpdateRole

func UpdateRole(clientset *kubernetes.Clientset, namespace string, role *rbacv1.Role) (*rbacv1.Role, error)

UpdateRole updates the role

func UpdateRoleBinding

func UpdateRoleBinding(clientset *kubernetes.Clientset, namespace string, role *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)

UpdateRoleBinding updates the role binding

func UpdateRoute

func UpdateRoute(routeClient *routeclient.RouteV1Client, namespace string, route *routev1.Route) (*routev1.Route, error)

UpdateRoute updates an OpenShift routes

func UpdateSecret

func UpdateSecret(clientset *kubernetes.Clientset, namespace string, secret *corev1.Secret) (*corev1.Secret, error)

UpdateSecret updates a secret

func UpdateService

func UpdateService(clientset *kubernetes.Clientset, namespace string, service *corev1.Service) (*corev1.Service, error)

UpdateService will update the service information for the input service name inside the input namespace

func UpdateServiceAccount

func UpdateServiceAccount(clientset *kubernetes.Clientset, namespace string, serviceAccount *corev1.ServiceAccount) (*corev1.ServiceAccount, error)

UpdateServiceAccount updates a service account

func UpdateWithHelm3

func UpdateWithHelm3(releaseName, namespace, chartURL string, vals map[string]interface{}, kubeConfig string) error

UpdateWithHelm3 uses the helm NewUpgrade action to update a resource in the cluster

func ValidateImageString

func ValidateImageString(image string) ([]string, error)

ValidateImageString takes a docker image string and returns substring submatch if it's valid, and an error if it is not; Example: image := "docker.io/blackducksoftware/synopsys-operator:latest" tagMatch = [blackducksoftware/synopsys-operator:latest blackducksoftware synopsys-operator latest]

func ValidateImageVersion

func ValidateImageVersion(version string) ([]string, error)

ValidateImageVersion takes a docker image version string and returns substring submatch version if it's valid, and an error if it is not; Example: version := "2019.4.2" versionMatch = [2019.4.2 2019 4 2]

func ValidateServiceEndpoint

func ValidateServiceEndpoint(clientset *kubernetes.Clientset, namespace string, name string) (*corev1.Endpoints, error)

ValidateServiceEndpoint will validate whether the service endpoint is ready to serve

func WaitForServiceEndpointReady

func WaitForServiceEndpointReady(clientset *kubernetes.Clientset, namespace string, name string) error

WaitForServiceEndpointReady will wait for the service endpoint to start the service

func WaitUntilPodsAreReady

func WaitUntilPodsAreReady(clientset *kubernetes.Clientset, namespace string, labelSelector string, timeoutInSeconds int64) error

WaitUntilPodsAreReady will wait for the pods to be ready

Types

type Container

type Container struct {
	ContainerConfig       *horizonapi.ContainerConfig
	EnvConfigs            []*horizonapi.EnvConfig
	VolumeMounts          []*horizonapi.VolumeMountConfig
	PortConfig            []*horizonapi.PortConfig
	ActionConfig          *horizonapi.ActionConfig
	ReadinessProbeConfigs []*horizonapi.ProbeConfig
	LivenessProbeConfigs  []*horizonapi.ProbeConfig
	PreStopConfig         *horizonapi.ActionConfig
}

Container defines the configuration for a container

type DeployerHelper

type DeployerHelper struct {
	Deployer *deployer.Deployer
}

DeployerHelper will contain the deployer specification, it has wrapper methods for adding stuff to a horizon deployer object. TODO this shoudl go into jayunit100/horizon probably (or horizon core if we're allowed to).

func NewDeployer

func NewDeployer(config *rest.Config) (*DeployerHelper, error)

NewDeployer will create the horizon deployer

func (*DeployerHelper) AddController

func (i *DeployerHelper) AddController(name string, c horizonapi.DeployerControllerInterface)

AddController will add the controller to the deployer

func (*DeployerHelper) PreDeploy

func (i *DeployerHelper) PreDeploy(components *api.ComponentList, namespace string)

PreDeploy will provide the deploy objects

func (*DeployerHelper) Run

func (i *DeployerHelper) Run() error

Run will run the deployer

func (*DeployerHelper) StartControllers

func (i *DeployerHelper) StartControllers()

StartControllers will start the controllers

type MapErrors

type MapErrors interface {
	error
	Errors() map[string]error
}

MapErrors defines an object that contains errors across one or more components

func NewMapErrors

func NewMapErrors(errMap map[string]error) MapErrors

NewMapErrors converts a map of string:error to a MapErrors interface

type PodConfig

type PodConfig struct {
	Name                   string
	Labels                 map[string]string
	ServiceAccount         string
	Containers             []*Container
	Volumes                []*components.Volume
	InitContainers         []*Container
	PodAffinityConfigs     map[horizonapi.AffinityType][]*horizonapi.PodAffinityConfig
	PodAntiAffinityConfigs map[horizonapi.AffinityType][]*horizonapi.PodAffinityConfig
	NodeAffinityConfigs    map[horizonapi.AffinityType][]*horizonapi.NodeAffinityConfig
	ImagePullSecrets       []string
	FSGID                  *int64
	RunAsUser              *int64
	RunAsGroup             *int64
}

PodConfig used for configuring the pod

type PodListController

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

PodListController defines a controller that will list pods

func NewPodListController

func NewPodListController(ns string) *PodListController

NewPodListController will create a new ListPodController

func (*PodListController) Run

func (l *PodListController) Run(resources horizonapi.DeployerResources, stopCh chan struct{}) error

Run will print to debug output the status of the pods that were started

type SecurityContext

type SecurityContext struct {
	FsGroup    *int64 `json:"fsGroup"`
	RunAsUser  *int64 `json:"runAsUser"`
	RunAsGroup *int64 `json:"runAsGroup"`
}

SecurityContext will contain the specifications of a security context

Jump to

Keyboard shortcuts

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