framework

package
v0.0.0-...-fc144cc Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 72 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BicepDeploymentScopeResourceGroup deploys into a specific resource group.
	BicepDeploymentScopeResourceGroup bicepDeploymentScope = iota
	// BicepDeploymentScopeSubscription deploys at subscription scope.
	BicepDeploymentScopeSubscription
)
View Source
const (
	UsePooledIdentitiesEnvvar = "POOLED_IDENTITIES"
	LeasedMSIContainersEnvvar = "LEASED_MSI_CONTAINERS"
)
View Source
const (
	ClusterApiAzureMiName        = "cluster-api-azure"
	ControlPlaneMiName           = "control-plane"
	CloudControllerManagerMiName = "cloud-controller-manager"
	IngressMiName                = "ingress"
	DiskCsiDriverMiName          = "disk-csi-driver"
	FileCsiDriverMiName          = "file-csi-driver"
	ImageRegistryMiName          = "image-registry"
	CloudNetworkConfigMiName     = "cloud-network-config"
	KmsMiName                    = "kms"
	DpDiskCsiDriverMiName        = "dp-disk-csi-driver"
	DpFileCsiDriverMiName        = "dp-file-csi-driver"
	DpImageRegistryMiName        = "dp-image-registry"
	ServiceManagedIdentityName   = "service"
)

well-known MSI role names

View Source
const (
	StandardPollInterval            = 10 * time.Second
	StandardResourceGroupExpiration = 4 * time.Hour
)

Variables

View Source
var ErrNotEnoughFreeIdentityContainers = errors.New("not enough free identity containers")

ErrNotEnoughFreeIdentityContainers is returned when a reservation request asks for more identity containers than are currently free in the pool.

Functions

func AnnotatedLocation

func AnnotatedLocation(annotation string) types.CodeLocation

AnnotatedLocation can be used to provide more informative source code locations by passing the result as additional parameter to a BeforeEach/AfterEach/DeferCleanup/It/etc.

func AnnotatedLocationWithOffset

func AnnotatedLocationWithOffset(annotation string, offset int) types.CodeLocation

AnnotatedLocationWithOffset skips additional call stack levels. With 0 as offset it is identical to AnnotatedLocation.

func BeginCreateHCPCluster

func BeginCreateHCPCluster(
	ctx context.Context,
	logger logr.Logger,
	hcpClient *hcpsdk20240610preview.HcpOpenShiftClustersClient,
	resourceGroupName string,
	hcpClusterName string,
	clusterParams ClusterParams,
	location string,
) (*runtime.Poller[hcpsdk20240610preview.HcpOpenShiftClustersClientCreateOrUpdateResponse], error)

func BuildHCPClusterFromParams

func BuildHCPClusterFromParams(
	parameters ClusterParams,
	location string,
) hcpsdk20240610preview.HcpOpenShiftCluster

func BuildNodePoolFromParams

func BuildNodePoolFromParams(
	parameters NodePoolParams,
	location string,
) hcpsdk20240610preview.NodePool

func CleanupAppRegistrations

func CleanupAppRegistrations(ctx context.Context, graphClient *graphutil.Client, appRegistrationIDs []string) error

func ConvertToManagedServiceIdentity

func ConvertToManagedServiceIdentity(value interface{}) (*hcpsdk20240610preview.ManagedServiceIdentity, error)

func ConvertToUserAssignedIdentitiesProfile

func ConvertToUserAssignedIdentitiesProfile(value interface{}) (*hcpsdk20240610preview.UserAssignedIdentitiesProfile, error)

func CreateClusterRoleBinding

func CreateClusterRoleBinding(ctx context.Context, subject string, adminRESTConfig *rest.Config) error

func CreateHCPClusterAndWait

func CreateHCPClusterAndWait(
	ctx context.Context,
	logger logr.Logger,
	hcpClient *hcpsdk20240610preview.HcpOpenShiftClustersClient,
	resourceGroupName string,
	hcpClusterName string,
	cluster hcpsdk20240610preview.HcpOpenShiftCluster,
	timeout time.Duration,
) (*hcpsdk20240610preview.HcpOpenShiftCluster, error)

CreateHCPClusterAndWait Note that the timeout parameter will only take effect if its value is greater than 0. Otherwise, the function won't wait for the deployment to be ready.

func CreateNodePoolAndWait

func CreateNodePoolAndWait(
	ctx context.Context,
	nodePoolsClient *hcpsdk20240610preview.NodePoolsClient,
	resourceGroupName string,
	hcpClusterName string,
	nodePoolName string,
	nodePool hcpsdk20240610preview.NodePool,
	timeout time.Duration,
) (*hcpsdk20240610preview.NodePool, error)

func CreateOrUpdateExternalAuthAndWait

func CreateOrUpdateExternalAuthAndWait(
	ctx context.Context,
	externalAuthClient *hcpsdk20240610preview.ExternalAuthsClient,
	resourceGroupName string,
	hcpClusterName string,
	externalAuthName string,
	externalAuth hcpsdk20240610preview.ExternalAuth,
	timeout time.Duration,
) (*hcpsdk20240610preview.ExternalAuth, error)

CreateOrUpdateExternalAuthAndWait creates or updates an external auth on an HCP cluster and waits

func CreateResourceGroup

func CreateResourceGroup(
	ctx context.Context,
	resourceGroupsClient *armresources.ResourceGroupsClient,
	resourceGroupName string,
	location string,
	resourceGroupTTL time.Duration,
	timeout time.Duration,
) (*armresources.ResourceGroup, error)

CreateResourceGroup creates a resource group

func CreateTestDockerConfigSecret

func CreateTestDockerConfigSecret(host, username, password, email, secretName, namespace string) (*corev1.Secret, error)

CreateTestDockerConfigSecret creates a Docker config secret for testing pull secret functionality

func DefaultOpenshiftChannelGroup

func DefaultOpenshiftChannelGroup() string

func DefaultOpenshiftControlPlaneVersionId

func DefaultOpenshiftControlPlaneVersionId() string

func DefaultOpenshiftNodePoolChannelGroup

func DefaultOpenshiftNodePoolChannelGroup() string

func DefaultOpenshiftNodePoolVersionId

func DefaultOpenshiftNodePoolVersionId() string

func DeleteAllHCPClusters

func DeleteAllHCPClusters(
	ctx context.Context,
	hcpClient *hcpsdk20240610preview.HcpOpenShiftClustersClient,
	resourceGroupName string,
	timeout time.Duration,
) error

DeleteAllHCPClusters deletes all Clusters within a resource group and waits

func DeleteExternalAuthAndWait

func DeleteExternalAuthAndWait(
	ctx context.Context,
	externalAuthClient *hcpsdk20240610preview.ExternalAuthsClient,
	resourceGroupName string,
	hcpClusterName string,
	externalAuthName string,
	timeout time.Duration,
) error

DeleteExternalAuthAndWait deletes a an external auth on an HCP cluster and waits

func DeleteHCPCluster

func DeleteHCPCluster(
	ctx context.Context,
	hcpClient *hcpsdk20240610preview.HcpOpenShiftClustersClient,
	resourceGroupName string,
	hcpClusterName string,
	timeout time.Duration,
) error

DeleteHCPCluster deletes an hcp cluster and waits for the operation to complete

func DeleteNodePool

func DeleteNodePool(
	ctx context.Context,
	nodePoolsClient *hcpsdk20240610preview.NodePoolsClient,
	resourceGroupName string,
	hcpClusterName string,
	nodePoolName string,
	timeout time.Duration,
) error

DeleteNodePool deletes a nodepool and waits for the operation to complete

func DeleteResourceGroup

func DeleteResourceGroup(
	ctx context.Context,
	resourceGroupsClient *armresources.ResourceGroupsClient,
	networkClientFactory *armnetwork.ClientFactory,
	resourceGroupName string,
	force bool,
	timeout time.Duration,
) error

DeleteResourceGroup deletes a resource group and waits for the operation to complete

func GenerateKubeconfig

func GenerateKubeconfig(restConfig *rest.Config) (string, error)

Helper to generate kubeconfig

func GenerateSSHKeyPair

func GenerateSSHKeyPair() (publicKey string, privateKey string, err error)

Helper to generate SSH key pair

func GetExternalAuth

func GetExternalAuth(
	ctx context.Context,
	externalAuthClient *hcpsdk20240610preview.ExternalAuthsClient,
	resourceGroupName string,
	hcpClusterName string,
	externalAuthName string,
) (hcpsdk20240610preview.ExternalAuthsClientGetResponse, error)

CreateExternalAuthAndWait creates a an external auth on an HCP cluster and waits

func GetHCPCluster

GetHCPCluster fetches an HCP cluster

func GetNodePool

func GetNodePool(
	ctx context.Context,
	nodePoolsClient *hcpsdk20240610preview.NodePoolsClient,
	resourceGroupName string,
	hcpClusterName string,
	nodePoolName string,
) (hcpsdk20240610preview.NodePoolsClientGetResponse, error)

GetNodePool fetches a nodepool resource

func GetOutputValue

func GetOutputValue(deploymentInfo *armresources.DeploymentExtended, outputName string) (interface{}, error)

func GetOutputValueBytes

func GetOutputValueBytes(deploymentInfo *armresources.DeploymentExtended, outputName string) ([]byte, error)

func GetOutputValueString

func GetOutputValueString(deploymentInfo *armresources.DeploymentExtended, outputName string) (string, error)

func GetSubscriptionID

func GetSubscriptionID(ctx context.Context, subscriptionClient *armsubscriptions.Client, subscriptionName string) (string, error)

func IsDevelopmentEnvironment

func IsDevelopmentEnvironment() bool

IsDevelopmentEnvironment indicates when this environment is development. This controls client endpoints and disables security when set to development.

func ListAllDeployments

func ListAllDeployments(
	ctx context.Context,
	deploymentsClient *armresources.DeploymentsClient,
	resourceGroupName string,
	timeout time.Duration,
) ([]*armresources.DeploymentExtended, error)

func ListAllExpiredResourceGroups

func ListAllExpiredResourceGroups(
	ctx context.Context,
	resourceGroupsClient *armresources.ResourceGroupsClient,
	now time.Time,
) ([]*armresources.ResourceGroup, error)

ListAllExpiredResourceGroups returns all expired e2e resource groups

func ListAllOperations

func ListAllOperations(
	ctx context.Context,
	deploymentOperationsClient *armresources.DeploymentOperationsClient,
	resourceGroupName string,
	deploymentName string,
	timeout time.Duration,
) ([]*armresources.DeploymentOperation, error)

func Must

func Must[T any](v T, err error) T

Must is a generic function that takes a value of type T and an error. If the error is not nil, it panics with the error. Otherwise, it returns the value of type T.

func NewLROPollerRetryDeploymentNotFoundPolicy

func NewLROPollerRetryDeploymentNotFoundPolicy() *lroPollerRetryDeploymentNotFoundPolicy

func NewTestContext

func NewTestContext() *perItOrDescribeTestContext

func RunVMCommand

func RunVMCommand(ctx context.Context, tc interface {
	SubscriptionID(ctx context.Context) (string, error)
	AzureCredential() (azcore.TokenCredential, error)
}, resourceGroup, vmName, command string, pollTimeout time.Duration) (string, error)

Helper to run command on VM

func SharedDir

func SharedDir() string

SharedDir is SHARED_DIR. It is a spot to store *files only* that can be shared between ci-operator steps. We can use this for anything, but currently we have a backup cleanup and collection scripts that use files here to cleanup and debug testing resources.

func SuffixName

func SuffixName(base, suffix string, maxLen int) string

SuffixName returns a name given a base ("deployment-5") and a suffix ("deploy") It will first attempt to join them with a dash. If the resulting name is longer than a valid pod name, it will truncate the base name and add an 8-character hash of the [base]-[suffix] string.

func UpdateHCPCluster

UpdateHCPCluster sends a PATCH (BeginUpdate) request for an HCP cluster and waits for completion within the provided timeout. It returns the final update response or an error.

func UpdateNodePoolAndWait

func UpdateNodePoolAndWait(
	ctx context.Context,
	nodePoolsClient *hcpsdk20240610preview.NodePoolsClient,
	resourceGroupName string,
	hcpClusterName string,
	nodePoolName string,
	update hcpsdk20240610preview.NodePoolUpdate,
	timeout time.Duration,
) (*hcpsdk20240610preview.NodePool, error)

UpdateNodePoolAndWait sends a PATCH (BeginUpdate) request for a nodepool and waits for completion within the provided timeout. It returns the final update response or an error.

func ValidateNodePoolDiskStorageAccountType

func ValidateNodePoolDiskStorageAccountType(
	ctx context.Context,
	nodePoolsClient *hcpsdk20240610preview.NodePoolsClient,
	resourceGroupName string,
	hcpClusterName string,
	nodePoolName string,
) error

Verifies that a nodepool created using framework has DiskStorageAccountType set to the framework default "StandardSSD_LRS"

Types

type AzureIdentityDetails

type AzureIdentityDetails struct {
	PrincipalName string
	PrincipalType PrincipalType
}

type BicepDeploymentOption

type BicepDeploymentOption func(*bicepDeploymentConfig)

func WithClusterResourceGroup

func WithClusterResourceGroup(resourceGroupName string) BicepDeploymentOption

func WithDebugDetailLevel

func WithDebugDetailLevel(level string) BicepDeploymentOption

func WithDeploymentName

func WithDeploymentName(name string) BicepDeploymentOption

func WithLocation

func WithLocation(location string) BicepDeploymentOption

func WithParameters

func WithParameters(parameters map[string]interface{}) BicepDeploymentOption

func WithScope

func WithScope(scope bicepDeploymentScope) BicepDeploymentOption

func WithTemplateFromBytes

func WithTemplateFromBytes(template []byte) BicepDeploymentOption

func WithTemplateFromFS

func WithTemplateFromFS(fs embed.FS, path string) BicepDeploymentOption

func WithTimeout

func WithTimeout(timeout time.Duration) BicepDeploymentOption

type CleanupFunc

type CleanupFunc func(ctx context.Context) error

type CleanupResourceGroupsOptions

type CleanupResourceGroupsOptions struct {
	ResourceGroupNames []string
	Timeout            time.Duration
	CleanupWorkflow    CleanupWorkflow
}

type CleanupWorkflow

type CleanupWorkflow string
const (
	CleanupWorkflowStandard CleanupWorkflow = "standard"
	CleanupWorkflowNoRP     CleanupWorkflow = "no-rp"
)

type ClusterParams

type ClusterParams struct {
	OpenshiftVersionId            string
	ClusterName                   string
	ManagedResourceGroupName      string
	NsgResourceID                 string
	NsgName                       string
	SubnetResourceID              string
	SubnetName                    string
	VnetName                      string
	UserAssignedIdentitiesProfile *hcpsdk20240610preview.UserAssignedIdentitiesProfile
	Identity                      *hcpsdk20240610preview.ManagedServiceIdentity
	KeyVaultName                  string
	EtcdEncryptionKeyName         string
	EtcdEncryptionKeyVersion      string
	EncryptionKeyManagementMode   string
	EncryptionType                string
	Network                       NetworkConfig
	APIVisibility                 string
	ImageRegistryState            string
	ChannelGroup                  string
	AuthorizedCIDRs               []*string
	Autoscaling                   *hcpsdk20240610preview.ClusterAutoscalingProfile
	Tags                          map[string]*string
}

func NewDefaultClusterParams

func NewDefaultClusterParams() ClusterParams

func PopulateClusterParamsFromCustomerInfraDeployment

func PopulateClusterParamsFromCustomerInfraDeployment(
	params ClusterParams,
	customerInfraDeploymentResult *armresources.DeploymentExtended,
) (ClusterParams, error)

func PopulateClusterParamsFromManagedIdentitiesDeployment

func PopulateClusterParamsFromManagedIdentitiesDeployment(
	params ClusterParams,
	managedIdentitiesDeploymentResult *armresources.DeploymentExtended,
) (ClusterParams, error)

type DockerConfigJSON

type DockerConfigJSON struct {
	Auths map[string]RegistryAuth `json:"auths"`
}

DockerConfigJSON is the root structure for dockerconfigjson secret data. See: https://kubernetes.io/docs/concepts/configuration/secret/#docker-config-secrets

type Identities

type Identities struct {
	ClusterApiAzureMiName        string `json:"clusterApiAzureMiName"`
	ControlPlaneMiName           string `json:"controlPlaneMiName"`
	CloudControllerManagerMiName string `json:"cloudControllerManagerMiName"`
	IngressMiName                string `json:"ingressMiName"`
	DiskCsiDriverMiName          string `json:"diskCsiDriverMiName"`
	FileCsiDriverMiName          string `json:"fileCsiDriverMiName"`
	ImageRegistryMiName          string `json:"imageRegistryMiName"`
	CloudNetworkConfigMiName     string `json:"cloudNetworkConfigMiName"`
	KmsMiName                    string `json:"kmsMiName"`
	DpDiskCsiDriverMiName        string `json:"dpDiskCsiDriverMiName"`
	DpFileCsiDriverMiName        string `json:"dpFileCsiDriverMiName"`
	DpImageRegistryMiName        string `json:"dpImageRegistryMiName"`
	ServiceManagedIdentityName   string `json:"serviceManagedIdentityName"`
}

func NewDefaultIdentities

func NewDefaultIdentities() Identities

func NewDefaultIdentitiesWithSuffix

func NewDefaultIdentitiesWithSuffix(suffix string) Identities

func (Identities) ToSlice

func (i Identities) ToSlice() []string

type LeasedIdentityPool

type LeasedIdentityPool struct {
	ResourceGroupName string     `json:"resourceGroup"`
	Identities        Identities `json:"identities"`
}

type NetworkConfig

type NetworkConfig struct {
	NetworkType string
	PodCIDR     string
	ServiceCIDR string
	MachineCIDR string
	HostPrefix  int32
}

type NodePoolAutoScalingParams

type NodePoolAutoScalingParams struct {
	Min int32
	Max int32
}

NodePoolAutoScalingParams contains min/max node counts for nodepool autoscaling

type NodePoolParams

type NodePoolParams struct {
	OpenshiftVersionId     string
	ClusterName            string
	NodePoolName           string
	Replicas               int32
	VMSize                 string
	OSDiskSizeGiB          int32
	DiskStorageAccountType string
	ChannelGroup           string
	// AutoScaling enables nodepool autoscaling. When set, Replicas is ignored.
	AutoScaling *NodePoolAutoScalingParams
}

func NewDefaultNodePoolParams

func NewDefaultNodePoolParams() NodePoolParams

type PrincipalType

type PrincipalType string

PrincipalType represents the type of Azure AD principal.

const (
	PrincipalTypeDSTSUser            PrincipalType = "dstsUser"
	PrincipalTypeAADServicePrincipal PrincipalType = "aadServicePrincipal"
)

type RBACScope

type RBACScope string
const (
	RBACScopeResourceGroup RBACScope = "resourceGroup"
	RBACScopeResource      RBACScope = "resource"
)

type RegistryAuth

type RegistryAuth struct {
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
	Auth     string `json:"auth"`
}

RegistryAuth represents authentication credentials for a single registry. This type models the structure of dockerconfigjson registry auth entries.

Jump to

Keyboard shortcuts

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