|
| 1 | +//go:build e2e |
| 2 | + |
| 3 | +// Copyright 2024 Nutanix. All rights reserved. |
| 4 | +// SPDX-License-Identifier: Apache-2.0 |
| 5 | + |
| 6 | +package e2e |
| 7 | + |
| 8 | +import ( |
| 9 | + "context" |
| 10 | + |
| 11 | + appsv1 "k8s.io/api/apps/v1" |
| 12 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 13 | + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" |
| 14 | + "sigs.k8s.io/cluster-api/test/framework" |
| 15 | + |
| 16 | + "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" |
| 17 | +) |
| 18 | + |
| 19 | +type WaitForRegistryMirrorToBeReadyInWorkloadClusterInput struct { |
| 20 | + RegistryMirror *v1alpha1.RegistryMirror |
| 21 | + WorkloadCluster *clusterv1.Cluster |
| 22 | + ClusterProxy framework.ClusterProxy |
| 23 | + StatefulSetIntervals []interface{} |
| 24 | + HelmReleaseIntervals []interface{} |
| 25 | +} |
| 26 | + |
| 27 | +func WaitForRegistryMirrorToBeReadyInWorkloadCluster( |
| 28 | + ctx context.Context, |
| 29 | + input WaitForRegistryMirrorToBeReadyInWorkloadClusterInput, //nolint:gocritic // This hugeParam is OK in tests. |
| 30 | +) { |
| 31 | + if input.RegistryMirror == nil { |
| 32 | + return |
| 33 | + } |
| 34 | + |
| 35 | + WaitForHelmReleaseProxyReadyForCluster( |
| 36 | + ctx, |
| 37 | + WaitForHelmReleaseProxyReadyForClusterInput{ |
| 38 | + GetLister: input.ClusterProxy.GetClient(), |
| 39 | + Cluster: input.WorkloadCluster, |
| 40 | + HelmReleaseName: "docker-registry", |
| 41 | + }, |
| 42 | + input.HelmReleaseIntervals..., |
| 43 | + ) |
| 44 | + |
| 45 | + workloadClusterClient := input.ClusterProxy.GetWorkloadCluster( |
| 46 | + ctx, input.WorkloadCluster.Namespace, input.WorkloadCluster.Name, |
| 47 | + ).GetClient() |
| 48 | + |
| 49 | + WaitForStatefulSetsAvailable(ctx, WaitForStatefulSetAvailableInput{ |
| 50 | + Getter: workloadClusterClient, |
| 51 | + StatefulSet: &appsv1.StatefulSet{ |
| 52 | + ObjectMeta: metav1.ObjectMeta{ |
| 53 | + Name: "registry-mirror-docker-registry", |
| 54 | + Namespace: "registry-mirror-system", |
| 55 | + }, |
| 56 | + }, |
| 57 | + }, input.StatefulSetIntervals...) |
| 58 | +} |
0 commit comments