util

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 78 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KMS_KEY_ALIAS = "alias/hypershift-ci"
)
View Source
const OAuthServerConfigKey = "config.yaml"

Variables

View Source
var (
	// Metrics
	// TODO (jparrill): We need to separate the metrics.go from the main pkg in the hypershift-operator.
	//     Delete these references when it's done and import it from there
	HypershiftOperatorInfoName = "hypershift_operator_info"
)

Functions

func CleanupOIDCBucketObjects added in v0.1.4

func CleanupOIDCBucketObjects(log logr.Logger, s3Client *s3.S3, bucketName, issuerURL string)

func CorrelateDaemonSet

func CorrelateDaemonSet(ds *appsv1.DaemonSet, nodePool *hyperv1.NodePool, dsName string)

func CreateCluster

func CreateCluster(t *testing.T, ctx context.Context, client crclient.Client, opts *core.CreateOptions, platform hyperv1.PlatformType, artifactDir string, serviceAccountSigningKey []byte) *hyperv1.HostedCluster

CreateCluster creates a new namespace and a HostedCluster in that namespace using the provided options.

CreateCluster will install a teardown handler into the provided test T by calling T.Cleanup() with a function that destroys the cluster. This function will block until teardown completes. No explicit cluster cleanup logic is expected of the caller. Note that the teardown function explicitly ignores interruption and tries forever to do its work, the rationale being that we should do everything with can to release external resources with whatever time we have before being forcibly terminated.

This function is intended (for now) to be the preferred default way of creating a hosted cluster during a test.

func DeleteNamespace

func DeleteNamespace(t *testing.T, ctx context.Context, client crclient.Client, namespace string) error

DeleteNamespace deletes and finalizes the given namespace, logging any failures along the way.

func DestroyOIDCProvider added in v0.1.4

func DestroyOIDCProvider(log logr.Logger, iamClient iamiface.IAMAPI, issuerURL string)

func EnsureAPIBudget

func EnsureAPIBudget(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureAllContainersHavePullPolicyIfNotPresent

func EnsureAllContainersHavePullPolicyIfNotPresent(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureAllRoutesUseHCPRouter

func EnsureAllRoutesUseHCPRouter(t *testing.T, ctx context.Context, hostClient crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureHCPContainersHaveResourceRequests

func EnsureHCPContainersHaveResourceRequests(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureMachineDeploymentGeneration

func EnsureMachineDeploymentGeneration(t *testing.T, ctx context.Context, hostClient crclient.Client, hostedCluster *hyperv1.HostedCluster, expectedGeneration int64)

func EnsureNoCrashingPods

func EnsureNoCrashingPods(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureNoPodsWithTooHighPriority

func EnsureNoPodsWithTooHighPriority(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureNodeCommunication

func EnsureNodeCommunication(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureNodeCountMatchesNodePoolReplicas

func EnsureNodeCountMatchesNodePoolReplicas(t *testing.T, ctx context.Context, hostClient, guestClient crclient.Client, nodePoolNamespace string)

func EnsureOAuthWithIdentityProvider added in v0.1.2

func EnsureOAuthWithIdentityProvider(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureSecretEncryptedUsingKMS

func EnsureSecretEncryptedUsingKMS(t *testing.T, ctx context.Context, hostedCluster *hyperv1.HostedCluster, guestClient crclient.Client)

func GetClient

func GetClient() (crclient.Client, error)

GetClient creates a controller-runtime client for Kubernetes

func GetConfig

func GetConfig() (*rest.Config, error)

GetConfig creates a REST config from current context

func GetIAMClient added in v0.1.4

func GetIAMClient(awsCreds, awsRegion string) iamiface.IAMAPI

func GetKMSKeyArn

func GetKMSKeyArn(awsCreds, awsRegion string) (*string, error)

func GetS3Client added in v0.1.4

func GetS3Client(awsCreds, awsRegion string) *s3.S3

func GetUserForToken added in v0.1.2

func GetUserForToken(config *restclient.Config, token string) (*userv1.User, error)

func NewLogr

func NewLogr(t *testing.T) logr.Logger

func NewPrometheusClient added in v0.1.6

func NewPrometheusClient(ctx context.Context) (prometheusv1.API, error)

func NoticePreemptionOrFailedScheduling

func NoticePreemptionOrFailedScheduling(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func UpdateObject added in v0.1.6

func UpdateObject[T crclient.Object](t *testing.T, ctx context.Context, client crclient.Client, original T, mutate func(obj T)) error

func WaitForConditionsOnHostedControlPlane

func WaitForConditionsOnHostedControlPlane(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, image string)

func WaitForGuestClient

func WaitForGuestClient(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster) crclient.Client

func WaitForGuestKubeConfig

func WaitForGuestKubeConfig(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster) ([]byte, error)

func WaitForImageRollout

func WaitForImageRollout(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, image string)

func WaitForNReadyNodes

func WaitForNReadyNodes(t *testing.T, ctx context.Context, client crclient.Client, n int32, platform hyperv1.PlatformType) []corev1.Node

func WaitForNReadyNodesByNodePool

func WaitForNReadyNodesByNodePool(t *testing.T, ctx context.Context, client crclient.Client, n int32, platform hyperv1.PlatformType, nodePoolName string) []corev1.Node

func WaitForNodePoolConditionsNotToBePresent

func WaitForNodePoolConditionsNotToBePresent(t *testing.T, ctx context.Context, client crclient.Client, nodePool *hyperv1.NodePool, conditions ...string)

WaitForNodePoolConditionsNotToBePresent blocks until the given conditions are not present in the NodePool.

func WaitForNodePoolDesiredNodes added in v0.1.6

func WaitForNodePoolDesiredNodes(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func WaitForNodePoolVersion

func WaitForNodePoolVersion(t *testing.T, ctx context.Context, client crclient.Client, nodePool *hyperv1.NodePool, version string)

WaitForNodePoolVersion blocks until the NodePool status indicates the given version. If the context is closed before the version is observed, the given test will get an error.

func WaitForOAuthRouteReady added in v0.1.2

func WaitForOAuthRouteReady(t *testing.T, ctx context.Context, client crclient.Client, restConfig *restclient.Config, hostedCluster *hyperv1.HostedCluster) *routev1.Route

func WaitForOAuthToken added in v0.1.2

func WaitForOAuthToken(t *testing.T, ctx context.Context, oauthRoute *routev1.Route, restConfig *restclient.Config, username, password string) string

func WaitForOauthConfig added in v0.1.6

func WaitForOauthConfig(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

Types

type DefaultRemoteExecutor

type DefaultRemoteExecutor struct{}

DefaultRemoteExecutor is the standard implementation of remote command execution

func (*DefaultRemoteExecutor) Execute

func (*DefaultRemoteExecutor) Execute(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool) error

type NameGenerator

type NameGenerator interface {
	// GenerateName generates a valid name from the base name, adding a random suffix to the
	// the base. If base is valid, the returned name must also be valid. The generator is
	// responsible for knowing the maximum valid name length.
	GenerateName(base string) string
}

NameGenerator generates names for objects. Some backends may have more information available to guide selection of new names and this interface hides those details.

var SimpleNameGenerator NameGenerator = simpleNameGenerator{}

SimpleNameGenerator is a generator that returns the name plus a random suffix of five alphanumerics when a name is requested. The string is guaranteed to not exceed the length of a standard Kubernetes name (63 characters)

type PodExecOptions

type PodExecOptions struct {
	StreamOptions

	Command []string

	PodName       string
	Namespace     string
	ContainerName string

	Executor RemoteExecutor
	Config   *restclient.Config
}

PodExecOptions declare the arguments accepted by the Exec command

func (*PodExecOptions) Run

func (p *PodExecOptions) Run() error

Run executes a validated remote execution against a pod.

func (*PodExecOptions) Validate

func (p *PodExecOptions) Validate() error

Validate checks that the provided exec options are specified.

type PrometheusResponse added in v0.1.6

type PrometheusResponse struct {
	Data prometheusResponseData `json:"data"`
}

PrometheusResponse is used to contain prometheus query results

func RunQueryAtTime added in v0.1.6

func RunQueryAtTime(ctx context.Context, log logr.Logger, prometheusClient prometheusv1.API, query string, evaluationTime time.Time) (*PrometheusResponse, error)

type RemoteExecutor

type RemoteExecutor interface {
	Execute(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool) error
}

RemoteExecutor defines the interface accepted by the Exec command - provided for test stubbing

type StreamOptions

type StreamOptions struct {
	Stdin bool
	TTY   bool

	genericclioptions.IOStreams
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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