talmhelper

package
v0.0.0-...-1f0e0a3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CguName                         string = "talm-cgu"
	Namespace                       string = "ztp-install"
	PlacementBindingName            string = "talm-placement-binding"
	PlacementRule                   string = "talm-placement-rule"
	PolicyName                      string = "talm-policy"
	PolicySetName                   string = "talm-policyset"
	CatalogSourceName               string = "talm-catsrc"
	Talm411TimeoutMessage           string = "The ClusterGroupUpgrade CR policies are taking too long to complete"
	Talm412TimeoutMessage           string = "Policy remediation took too long"
	TemporaryNamespaceName          string = Namespace + "-temp"
	ProgressingType                 string = "Progressing"
	ReadyType                       string = "Ready"
	SucceededType                   string = "Succeeded"
	ValidatedType                   string = "Validated"
	ConditionReasonCompleted        string = "Completed"
	ConditionReasonUpgradeCompleted string = "UpgradeCompleted"
)

talm consts.

Variables

View Source
var (
	// Spoke1Name name of the first spoke.
	Spoke1Name string
	// Spoke2APIClient api client of the second spoke.
	Spoke2APIClient *clients.Settings
	// Spoke2Name name of the second spoke.
	Spoke2Name string
	// TalmHubVersion talm hub version on hub.
	TalmHubVersion string
)

Functions

func ApplyPolicyAndCreateAllComponents

func ApplyPolicyAndCreateAllComponents(
	client *clients.Settings,
	policy ocm.PolicyBuilder,
	policySetName string,
	placementBindingName string,
	placementRuleName string,
	namespace string,
	clusters []string,
	clusterSelector metav1.LabelSelector,
) error

ApplyPolicyAndCreateAllComponents is used only apply already created policy and all the required components for applying that policy such as policyset, placementrule, placement binding, etc.

func BoolAddr

func BoolAddr(b bool) *bool

BoolAddr is used to convert a boolean to a boolean pointer.

func CleanupNamespace

func CleanupNamespace(clients []*clients.Settings, ns string) error

CleanupNamespace is used to cleanup a namespace on multiple clients.

func CleanupTestResourcesOnClient

func CleanupTestResourcesOnClient(
	client *clients.Settings,
	cguName string,
	policyName string,
	nsName string,
	placementBinding string,
	placementRule string,
	policySet string,
	catsrcName string,
	deleteNs bool,
) []error

CleanupTestResourcesOnClient is used to delete everything on a specific cluster.

func CleanupTestResourcesOnClients

func CleanupTestResourcesOnClients(
	clients []*clients.Settings,
	cguName string,
	policyName string,
	createdNamespace string,
	placementBinding string,
	placementRule string,
	policySet string,
	catsrcName string) []error

CleanupTestResourcesOnClients is used to delete all references to specified cgu, policy, and namespace on all clusters specified in the client list.

func CreateCguAndWait

func CreateCguAndWait(
	client *clients.Settings,
	clusterGroupUpgrade cgu.CguBuilder) error

CreateCguAndWait is used to create a CGU with the provided clusters list and managed policies. No policies, placements, bindings, policysets, etc will be created.

func CreatePolicyAndCgu

func CreatePolicyAndCgu(
	client *clients.Settings,
	object runtime.Object,
	complianceType configurationPolicyv1.ComplianceType,
	remediationAction configurationPolicyv1.RemediationAction,
	policyName string,
	policySetName string,
	placementBindingName string,
	placementRule string,
	namespace string,
	clusterSelector metav1.LabelSelector,
	clusterGroupUpgrade cgu.CguBuilder) error

CreatePolicyAndCgu is used to create a simplified CGU to cover the most common use case. This will automatically create a single policy enforcing the compliance type on the provided object. If you require multiple policies to be managed then consider CreateCgu() instead.

func CreatePolicyAndWait

func CreatePolicyAndWait(client *clients.Settings, policy ocm.PolicyBuilder) error

CreatePolicyAndWait is used to create a policy and wait for it to exist.

func CreatePolicyWithAllComponents

func CreatePolicyWithAllComponents(
	client *clients.Settings,
	object runtime.Object,
	complianceType configurationPolicyv1.ComplianceType,
	remediationAction configurationPolicyv1.RemediationAction,
	policyName string,
	policySetName string,
	placementBindingName string,
	placementRule string,
	namespace string,
	clusters []string,
	clusterSelector metav1.LabelSelector,
) error

CreatePolicyWithAllComponents is used to create a policy and all the requireed components for applying that policy such as policyset, placementrule, placement binding, etc.

func CreateTalmTestNamespace

func CreateTalmTestNamespace() error

CreateTalmTestNamespace deletes the TALM test namespace.

func DeleteTalmTestNamespace

func DeleteTalmTestNamespace(allowNotFound bool) error

DeleteTalmTestNamespace deletes the TALM test namespace.

func FilterMissingResourceErrors

func FilterMissingResourceErrors(err error) error

FilterMissingResourceErrors takes an input error and checks it for a few specific types of errors. If it matches any of the errors that are considered to be a resource not found, then it returns nil. Otherwise it returns the original error.

func GetAllTestClients

func GetAllTestClients() []*clients.Settings

GetAllTestClients is used to quickly obtain a list of all the test clients.

func GetCguDefinition

func GetCguDefinition(
	cguName string,
	clusterList []string,
	canaryList []string,
	managedPolicies []string,
	namespace string,
	maxConcurrency int,
	timeout int) cgu.CguBuilder

GetCguDefinition is used to get a CGU with simplified parameters.

func GetConfigurationPolicyDefinition

func GetConfigurationPolicyDefinition(
	policyName string,
	complianceType configurationPolicyv1.ComplianceType,
	remediationAction configurationPolicyv1.RemediationAction,
	object runtime.Object) configurationPolicyv1.ConfigurationPolicy

GetConfigurationPolicyDefinition is used to get a configuration policy that contains the provided object.

func GetPlacementBindingDefinition

func GetPlacementBindingDefinition(
	placementBindingName string,
	policySetName string,
	placementRuleName string,
	namespace string) ocm.PlacementBindingBuilder

GetPlacementBindingDefinition is used to get a placement binding to use with a cgu.

func GetPlacementFieldDefinition

func GetPlacementFieldDefinition(
	clusters []string,
	clusterSelector metav1.LabelSelector) placementrulev1.GenericPlacementFields

GetPlacementFieldDefinition is used to get a generic placement field for use with a placement rule.

func GetPlacementRuleDefinition

func GetPlacementRuleDefinition(
	placementRuleName string,
	namespace string,
	placementFields placementrulev1.GenericPlacementFields) ocm.PlacementRuleBuilder

GetPlacementRuleDefinition is used to get a placement rule to use with a cgu.

func GetPolicyDefinition

func GetPolicyDefinition(
	policyName string,
	namespace string,
	object runtime.Object,
	remediationAction configurationPolicyv1.RemediationAction) ocm.PolicyBuilder

GetPolicyDefinition is used to get a policy that can be used with a CGU.

func GetPolicySetDefinition

func GetPolicySetDefinition(
	policySetName string,
	policyList []policiesv1beta1.NonEmptyString,
	namespace string) ocm.PolicySetBuilder

GetPolicySetDefinition is used to get a policy set for the provided policies.

func IsCguExist

func IsCguExist(client *clients.Settings, cguName string, namespace string) (bool, error)

IsCguExist can be used to check if a specific cgu exists.

func IsClusterInProgressInCgu

func IsClusterInProgressInCgu(
	client *clients.Settings,
	cguName string,
	clusterName string,
	namespace string) (bool, error)

IsClusterInProgressInCgu can be used to check if a particular cluster is actively being remediated in the provided cgu and namespace.

func IsClusterStartedInCgu

func IsClusterStartedInCgu(
	client *clients.Settings,
	cguName string,
	clusterName string,
	namespace string) (bool, error)

IsClusterStartedInCgu can be used to check if a particular cluster has started being remediated in the provided cgu and namespace.

func IsPolicyExist

func IsPolicyExist(client *clients.Settings, policyName string, namespace string) (bool, error)

IsPolicyExist can be used to check if a specific policy exists.

func VerifyTalmIsInstalled

func VerifyTalmIsInstalled() error

VerifyTalmIsInstalled checks that talm pod+container is present and that CGUs can be fetched.

func WaitForCguInCondition

func WaitForCguInCondition(
	client *clients.Settings,
	cguName string,
	namespace string,
	conditionType string,
	expectedMessage string,
	expectedStatus metav1.ConditionStatus,
	expectedReason string,
	timeout time.Duration) error

WaitForCguInCondition waits until a specified condition type matches the provided message and/or status.

func WaitForCguToFinishSuccessfully

func WaitForCguToFinishSuccessfully(cguName string, namespace string, timeout time.Duration) error

WaitForCguToFinishSuccessfully waits until the provided CGU reaches the succeeded state and all clusters were successful message.

func WaitForClusterInProgressInCgu

func WaitForClusterInProgressInCgu(
	client *clients.Settings,
	cguName string,
	clusterName string,
	namespace string,
	timeout time.Duration) error

WaitForClusterInProgressInCgu can be used to wait until the provided cluster is actively being remediated in the provided cgu and namespace.

func WaitUntilObjectExists

func WaitUntilObjectExists(
	client *clients.Settings,
	objectName string,
	namespace string,
	getStatus func(client *clients.Settings, objectName string, namespace string) (bool, error)) error

WaitUntilObjectExists can be called to wait until a specified resource is present. This is called by all of the CreateXAndWait functions in this file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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