Skip to content

Commit

Permalink
foo
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Feb 27, 2024
1 parent 951d87a commit 51f36e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/framework/clusterctl/clusterctl_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func UpgradeManagementClusterAndWait(ctx context.Context, input UpgradeManagemen
}

log.Logf("Waiting for cert-manager to inject the new certificates to webhook relevant objects")
framework.WaitForProviderCAInjection(ctx, client)
framework.WaitForProviderCAInjection(ctx, client, filepath.Join(input.LogFolder, "foo", "crds"))

}

Expand Down
12 changes: 10 additions & 2 deletions test/framework/management_cluster_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ package framework

import (
"context"
"os"
"time"

. "github.com/onsi/gomega"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework/internal/log"
Expand All @@ -33,20 +35,26 @@ import (
// WaitForProviderCAInjection tries to query a list of all CRD objects for a provider
// to ensure the webhooks are correctly setup, especially that cert-manager did inject
// the up-to-date CAs into the relevant objects.
func WaitForProviderCAInjection(ctx context.Context, lister Lister) {
func WaitForProviderCAInjection(ctx context.Context, lister Lister, outpath string) {
crdList := &apiextensionsv1.CustomResourceDefinitionList{}
Eventually(func() error {
return lister.List(ctx, crdList, client.HasLabels{clusterv1.ProviderNameLabel})
}, retryableOperationTimeout, retryableOperationInterval).Should(Succeed(), "Failed to get crds of providers")

for i := range crdList.Items {
crd := crdList.Items[i]
data, err := yaml.Marshal(crd)
Expect(err).ToNot(HaveOccurred())
os.WriteFile(outpath, data, 0600)
// Use all versions so we also test conversion webhooks
for _, version := range crd.Spec.Versions {
if !version.Served {
continue
}
gvk := schema.GroupVersionKind{
Group: crd.Spec.Group,
Version: version.Name,
Kind: crd.Spec.Names.ListKind,
Kind: crd.Spec.Names.Kind,
}
log.Logf("Checking crd %s - %s", gvk, time.Now())
list := &unstructured.UnstructuredList{}
Expand Down

0 comments on commit 51f36e2

Please sign in to comment.