utils

package
v0.0.0-...-ce1f43f Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerCACerts = "observability-server-ca-certs"
	ClientCACerts = "observability-client-ca-certs"
	ServerCerts   = "observability-server-certs"
	GrafanaCerts  = "observability-grafana-certs"
)
View Source
const (
	MCO_CR_NAME                   = "observability"
	MCO_COMPONENT_LABEL           = "observability.open-cluster-management.io/name=" + MCO_CR_NAME
	OBSERVATORIUM_COMPONENT_LABEL = "app.kubernetes.io/part-of=observatorium"
	MCO_NAMESPACE                 = "open-cluster-management-observability"
	MCO_ADDON_NAMESPACE           = "open-cluster-management-addon-observability"
	MCO_PULL_SECRET_NAME          = "multiclusterhub-operator-pull-secret"
	OBJ_SECRET_NAME               = "thanos-object-storage"
	MCO_GROUP                     = "observability.open-cluster-management.io"
	OCM_WORK_GROUP                = "work.open-cluster-management.io"
	OCM_CLUSTER_GROUP             = "cluster.open-cluster-management.io"
	OCM_ADDON_GROUP               = "addon.open-cluster-management.io"
)
View Source
const (
	RouterCertsSecretName = "router-certs-default"
)

Variables

This section is empty.

Functions

func Apply

func Apply(url string, kubeconfig string, context string, yamlB []byte) error

Apply a multi resources file to the cluster described by the url, kubeconfig and context. url of the cluster kubeconfig which contains the context context, the context to use yamlB, a byte array containing the resources file

func CheckAdvRetentionConfig

func CheckAdvRetentionConfig(opt TestOptions) (bool, error)

func CheckAllPodNodeSelector

func CheckAllPodNodeSelector(opt TestOptions, nodeSelector map[string]interface{}) error

func CheckAllPodsAffinity

func CheckAllPodsAffinity(opt TestOptions) error

func CheckDeploymentPodReady

func CheckDeploymentPodReady(opt TestOptions, deployName string) error

func CheckMCOAddon

func CheckMCOAddon(opt TestOptions) error

func CheckMCOAddonResources

func CheckMCOAddonResources(opt TestOptions) error

func CheckMCOComponents

func CheckMCOComponents(opt TestOptions) error

func CheckMCOConversion

func CheckMCOConversion(opt TestOptions, v1beta1tov1beta2GoldenPath string) error

func CheckOBAComponents

func CheckOBAComponents(opt TestOptions) error

func CheckStatefulSetPodReady

func CheckStatefulSetPodReady(opt TestOptions, stsName string) error

func CheckStorageResize

func CheckStorageResize(opt TestOptions, stsName string, expectedCapacity string) error

func ContainDashboard

func ContainDashboard(opt TestOptions, title string) (error, bool)

func ContainManagedClusterMetric

func ContainManagedClusterMetric(opt TestOptions, query string, matchedLabels []string) (error, bool)

func CreateCRB

func CreateCRB(opt TestOptions, isHub bool,
	crb *rbacv1.ClusterRoleBinding) error

func CreateConfigMap

func CreateConfigMap(opt TestOptions, isHub bool, cm *corev1.ConfigMap) error

func CreateCustomAlertConfigYaml

func CreateCustomAlertConfigYaml(baseDomain string) []byte

func CreateMCONamespace

func CreateMCONamespace(opt TestOptions) error

func CreateMCOTestingRBAC

func CreateMCOTestingRBAC(opt TestOptions) error

func CreateObjSecret

func CreateObjSecret(opt TestOptions) error

func CreatePullSecret

func CreatePullSecret(opt TestOptions, mcoNs string) error

func CreateSA

func CreateSA(opt TestOptions, isHub bool, namespace string,
	sa *v1.ServiceAccount) error

func DeleteCRB

func DeleteCRB(opt TestOptions, isHub bool, name string) error

func DeleteCertSecret

func DeleteCertSecret(opt TestOptions) error

func DeleteConfigMap

func DeleteConfigMap(opt TestOptions, isHub bool, name string, namespace string) error

func DeleteDeployment

func DeleteDeployment(opt TestOptions, isHub bool, name string, namespace string) error

func DeleteMCOInstance

func DeleteMCOInstance(opt TestOptions) error

func DeleteMCOTestingRBAC

func DeleteMCOTestingRBAC(opt TestOptions) error

func DeletePod

func DeletePod(opt TestOptions, isHub bool, namespace, name string) error

func DeleteSA

func DeleteSA(opt TestOptions, isHub bool, namespace string,
	name string) error

func FetchBearerToken

func FetchBearerToken(opt TestOptions) (string, error)

func GetAllMCOPods

func GetAllMCOPods(opt TestOptions) ([]corev1.Pod, error)

func GetAllOBAPods

func GetAllOBAPods(opt TestOptions) ([]corev1.Pod, error)

func GetCRB

func GetCRB(opt TestOptions, isHub bool, name string) (error, *rbacv1.ClusterRoleBinding)

func GetConfigMap

func GetConfigMap(opt TestOptions, isHub bool, name string,
	namespace string) (error, *corev1.ConfigMap)

func GetDeployment

func GetDeployment(opt TestOptions, isHub bool, name string,
	namespace string) (*appv1.Deployment, error)

func GetDeploymentWithLabel

func GetDeploymentWithLabel(opt TestOptions, isHub bool, label string,
	namespace string) (*appv1.DeploymentList, error)

func GetGrafanaURL

func GetGrafanaURL(opt TestOptions) string

func GetKubeClientDynamic

func GetKubeClientDynamic(opt TestOptions, isHub bool) dynamic.Interface

func GetKubeVersion

func GetKubeVersion(client *rest.RESTClient) version.Info

func GetMCOAddonSpecMetrics

func GetMCOAddonSpecMetrics(opt TestOptions) (bool, error)

func GetMCOAddonSpecResources

func GetMCOAddonSpecResources(opt TestOptions) (map[string]interface{}, error)

func GetManagedClusterName

func GetManagedClusterName(opt TestOptions) string

func GetPodList

func GetPodList(opt TestOptions, isHub bool, namespace string, labelSelector string) (error, *v1.PodList)

func GetPodLogs

func GetPodLogs(opt TestOptions, isHub bool, namespace, podName, containerName string, previous bool, tailLines int64) (string, error)

func GetPullSecret

func GetPullSecret(opt TestOptions) (string, error)

GetPullSecret checks the secret from MCH CR and return the secret name

func GetRouterCA

func GetRouterCA(cli kubernetes.Interface) ([]byte, error)

func GetStatefulSet

func GetStatefulSet(opt TestOptions, isHub bool, name string,
	namespace string) (*appv1.StatefulSet, error)

func GetStatefulSetWithLabel

func GetStatefulSetWithLabel(opt TestOptions, isHub bool, label string,
	namespace string) (*appv1.StatefulSetList, error)

func HaveCRDs

func HaveCRDs(c Cluster, kubeconfig string, expectedCRDs []string) error

func HaveDeploymentsInNamespace

func HaveDeploymentsInNamespace(c Cluster, kubeconfig string, namespace string, expectedDeploymentNames []string) error

func HaveServerResources

func HaveServerResources(c Cluster, kubeconfig string, expectedAPIGroups []string) error

func IntegrityChecking

func IntegrityChecking(opt TestOptions) error

IntegrityChecking checks to ensure all required conditions are met when completing the specs

func IsOpenshift

func IsOpenshift(client *rest.RESTClient) bool

func ListOCPManagedClusterIDs

func ListOCPManagedClusterIDs(opt TestOptions, minVersionStr string) ([]string, error)

func LoadConfig

func LoadConfig(url, kubeconfig, context string) (*rest.Config, error)

func ModifyMCOAddonSpecInterval

func ModifyMCOAddonSpecInterval(opt TestOptions, interval int64) error

func ModifyMCOAddonSpecMetrics

func ModifyMCOAddonSpecMetrics(opt TestOptions, enable bool) error

func ModifyMCOAvailabilityConfig

func ModifyMCOAvailabilityConfig(opt TestOptions, availabilityConfig string) error

func ModifyMCOCR

func ModifyMCOCR(opt TestOptions) error

ModifyMCOCR modifies the MCO CR for reconciling. modify multiple parameter to save running time

func ModifyMCORetentionResolutionRaw

func ModifyMCORetentionResolutionRaw(opt TestOptions) error

func NewKubeClient

func NewKubeClient(url, kubeconfig, context string) kubernetes.Interface

func NewKubeClientAPIExtension

func NewKubeClientAPIExtension(url, kubeconfig, context string) apiextensionsclientset.Interface

func NewKubeClientDynamic

func NewKubeClientDynamic(url, kubeconfig, context string) dynamic.Interface

func NewMCOAddonGVR

func NewMCOAddonGVR() schema.GroupVersionResource

func NewMCOClusterManagementAddonsGVR

func NewMCOClusterManagementAddonsGVR() schema.GroupVersionResource

func NewMCOGVRV1BETA1

func NewMCOGVRV1BETA1() schema.GroupVersionResource

func NewMCOGVRV1BETA2

func NewMCOGVRV1BETA2() schema.GroupVersionResource

func NewMCOMObservatoriumGVR

func NewMCOMObservatoriumGVR() schema.GroupVersionResource

func NewMCOManagedClusterAddonsGVR

func NewMCOManagedClusterAddonsGVR() schema.GroupVersionResource

func NewOCMManagedClustersGVR

func NewOCMManagedClustersGVR() schema.GroupVersionResource

func NewOCMManifestworksGVR

func NewOCMManifestworksGVR() schema.GroupVersionResource

func NewOCMMultiClusterHubGVR

func NewOCMMultiClusterHubGVR() schema.GroupVersionResource

func NewOCMPlacementRuleGVR

func NewOCMPlacementRuleGVR() schema.GroupVersionResource

func NewUnversionedRestClient

func NewUnversionedRestClient(url, kubeconfig, context string) *rest.RESTClient

func PatchPlacementRule

func PatchPlacementRule(opt TestOptions, token string) error

PatchPlacementRule patch the status of the placementrule created by MCO TODO(morvencao): remove this function after placement is implemented by server foundation

func PrintAllMCOPodsStatus

func PrintAllMCOPodsStatus(opt TestOptions)

func PrintAllOBAPodsStatus

func PrintAllOBAPodsStatus(opt TestOptions)

func PrintMCOObject

func PrintMCOObject(opt TestOptions)

func PrintManagedClusterOBAObject

func PrintManagedClusterOBAObject(opt TestOptions)

func RevertMCOCRModification

func RevertMCOCRModification(opt TestOptions) error

RevertMCOCRModification revert the previous changes

func StatusContainsTypeEqualTo

func StatusContainsTypeEqualTo(u *unstructured.Unstructured, typeString string) bool

StatusContainsTypeEqualTo check if u contains a condition type with value typeString

func UninstallMCO

func UninstallMCO(opt TestOptions) error

func UpdateCRB

func UpdateCRB(opt TestOptions, isHub bool, name string,
	crb *rbacv1.ClusterRoleBinding) (error, *rbacv1.ClusterRoleBinding)

func UpdateDeployment

func UpdateDeployment(opt TestOptions, isHub bool, name string, namespace string,
	dep *appv1.Deployment) (*appv1.Deployment, error)

func UpdateDeploymentReplicas

func UpdateDeploymentReplicas(opt TestOptions, deployName, crProperty string, desiredReplicas, expectedReplicas int32) error

func UpdateObservabilityFromManagedCluster

func UpdateObservabilityFromManagedCluster(opt TestOptions, enableObservability bool) error

func UpdateSA

func UpdateSA(opt TestOptions, isHub bool, namespace string,
	sa *v1.ServiceAccount) (error, *v1.ServiceAccount)

Types

type APIKeys

type APIKeys struct {
	AWS   AWSAPIKey   `yaml:"aws,omitempty"`
	GCP   GCPAPIKey   `yaml:"gcp,omitempty"`
	Azure AzureAPIKey `yaml:"azure,omitempty"`
}

type AWSAPIKey

type AWSAPIKey struct {
	AWSAccessID     string `yaml:"awsAccessKeyID"`
	AWSAccessSecret string `yaml:"awsSecretAccessKeyID"`
	BaseDnsDomain   string `yaml:"baseDnsDomain"`
	Region          string `yaml:"region"`
}

type AzureAPIKey

type AzureAPIKey struct {
	BaseDnsDomain  string `yaml:"baseDnsDomain"`
	BaseDomainRGN  string `yaml:"azureBaseDomainRGN"`
	Region         string `yaml:"region"`
	SubscriptionID string `yaml:"subscriptionID"`
	TenantID       string `yaml:"tenantID"`
	ClientID       string `yaml:"clientID"`
	ClientSecret   string `yaml:"clientSecret"`
}

type Baremetal

type Baremetal struct {
	ExternalBridge               string `yaml:"externalBridge,omitempty"`
	ProvisioningBridge           string `yaml:"provisioningBridge,omitempty"`
	LibvirtURI                   string `yaml:"libvirtURI,omitempty"`
	ProvisioningNetworkInterface string `yaml:"provisioningNetworkInterface,omitempty"`
	ProvisioningNetworkCIDR      string `yaml:"provisioningNetworkCIDR,omitempty"`
	APIVIP                       string `yaml:"apiVIP,omitempty"`
	DNSVIP                       string `yaml:"dnsVIP,omitempty"`
	IngressVIP                   string `yaml:"ingressVIP,omitempty"`
	Hosts                        []Host `yaml:"hosts,omitempty"`
	SSHKnownHosts                string `yaml:"sshKnownHosts,omitempty"`
}

Baremetal specs for target baremetal provisioning

type Bmc

type Bmc struct {
	Address  string `yaml:"address"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

Bmc definition

type CloudConnection

type CloudConnection struct {
	PullSecret    string  `yaml:"pullSecret"`
	SSHPrivateKey string  `yaml:"sshPrivatekey"`
	SSHPublicKey  string  `yaml:"sshPublickey"`
	Keys          APIKeys `yaml:"apiKeys,omitempty"`
	OCPRelease    string  `yaml:"ocpRelease,omitempty"`
}

CloudConnection struct for bits having to do with Connections

type Cluster

type Cluster struct {
	Name        string          `yaml:"name,omitempty"`
	Namespace   string          `yaml:"namespace,omitempty"`
	Tags        map[string]bool `yaml:"tags,omitempty"`
	BaseDomain  string          `yaml:"baseDomain"`
	User        string          `yaml:"user,omitempty"`
	Password    string          `yaml:"password,omitempty"`
	KubeContext string          `yaml:"kubecontext,omitempty"`
	MasterURL   string          `yaml:"masterURL,omitempty"`
	GrafanaURL  string          `yaml:"grafanaURL,omitempty"`
	GrafanaHost string          `yaml:"grafanaHost,omitempty"`
	KubeConfig  string          `yaml:"kubeconfig,omitempty"`
}

Define the shape of clusters that may be added under management

func GetCluster

func GetCluster(tag string, clusters []Cluster) *Cluster

GetCluster returns the first cluster with a given tag

func GetClusters

func GetClusters(tag string, clusters []Cluster) []*Cluster

GetClusters returns all clusters with a given tag

type ClusterDeploy

type ClusterDeploy struct {
	Kind       string  `yaml:"kind"`
	APIVersion string  `yaml:"apiVersion"`
	Items      []Items `yaml:"items"`
}

ClusterDeploy defines the data passed to Hive

type GCPAPIKey

type GCPAPIKey struct {
	ProjectID             string `yaml:"gcpProjectID"`
	ServiceAccountJsonKey string `yaml:"gcpServiceAccountJsonKey"`
	BaseDnsDomain         string `yaml:"baseDnsDomain"`
	Region                string `yaml:"region"`
}

type Host

type Host struct {
	Name            string `yaml:"name"`
	Role            string `yaml:"role"`
	Bmc             Bmc    `yaml:"bmc"`
	BootMACAddress  string `yaml:"bootMACAddress"`
	HardwareProfile string `yaml:"hardwareProfile"`
}

Host is an array of baremetal assets

type InstallConfig

type InstallConfig struct {
	BaseDomain string     `yaml:"baseDomain,omitempty"`
	Networking Networking `yaml:"networking,omitempty"`
	Metadata   Metadata   `yaml:"metadata"`
	Platform   Platform   `yaml:"platform,omitempty"`
	PullSecret string     `yaml:"pullSecret,omitempty"`
	SSHKey     string     `yaml:"sshKey,omitempty"`
}

InstallConfig definition for install config structure from install-config.yaml

type Items

type Items struct {
	Kind       string     `yaml:"kind"`
	Metadata   Metadata   `yaml:"metadata"`
	StringData StringData `yaml:"stringData,omitempty"`
	Spec       Spec       `yaml:"spec,omitempty"`
}

Items defines the list of items in the cluster deploy yaml

type Metadata

type Metadata struct {
	Name string `yaml:"name,omitempty"`
}

Metadata defines the name

type Networking

type Networking struct {
	NetworkType string `yaml:"networkType"`
	MachineCIDR string `yaml:"machineCIDR"`
}

Networking definition

type Platform

type Platform struct {
	Baremetal Baremetal `yaml:"baremetal,omitempty"`
}

Platform definition

type Provisioning

type Provisioning struct {
	ReleaseImage  string   `yaml:"releaseImage,omitempty"`
	SSHKnownHosts []string `yaml:"sshKnownHosts,omitempty"`
}

Provisioning defines the data related to cluster creation

type Registry

type Registry struct {
	// example: quay.io/stolostron
	Server   string `yaml:"server"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
}

Define the image registry

type Spec

type Spec struct {
	BaseDomain   string       `yaml:"baseDomain,omitempty"`
	ClusterName  string       `yaml:"clusterName,omitempty"`
	Provisioning Provisioning `yaml:"provisioning,omitempty"`
}

Spec defines the kube specifications

type StringData

type StringData struct {
	Dockerconfigjson string `yaml:".dockerconfigjson,omitempty"`
	SSHPrivateKey    string `yaml:"ssh-privatekey,omitempty"`
}

StringData defiines the ssh values

type TestOptions

type TestOptions struct {
	HubCluster      Cluster         `yaml:"hub"`
	ManagedClusters []Cluster       `yaml:"clusters"`
	ImageRegistry   Registry        `yaml:"imageRegistry,omitempty"`
	KubeConfig      string          `yaml:"kubeconfig,omitempty"`
	Connection      CloudConnection `yaml:"cloudConnection,omitempty"`
	Headless        string          `yaml:"headless,omitempty"`
	OwnerPrefix     string          `yaml:"ownerPrefix,omitempty"`
}

Define options available for Tests to consume

type TestOptionsContainer

type TestOptionsContainer struct {
	Options TestOptions `yaml:"options"`
}

Jump to

Keyboard shortcuts

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