Skip to content

Commit ab0c9e8

Browse files
committed
feat(repo-server): Unify certificates version to use beta
Signed-off-by: Oliver Gondža <ogondza@gmail.com>
1 parent 269f06c commit ab0c9e8

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

controllers/argocd/repo_server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"time"
2424

2525
appsv1 "k8s.io/api/apps/v1"
26-
"k8s.io/api/certificates/v1beta1"
26+
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
2727
corev1 "k8s.io/api/core/v1"
2828
"k8s.io/apimachinery/pkg/api/errors"
2929
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -988,7 +988,7 @@ func (r *ReconcileArgoCD) systemCATrustMapper(ctx context.Context, o client.Obje
988988
break
989989
}
990990
}
991-
case *v1beta1.ClusterTrustBundle:
991+
case *certificatesv1beta1.ClusterTrustBundle:
992992
for _, trustSource := range argocd.Spec.Repo.SystemCATrust.ClusterTrustBundles {
993993
if isRelevantCtb(trustSource, obj) {
994994
rolloutBecause[&argocd] = fmt.Sprintf("ClusterTrustBundle %s", obj.Name)
@@ -1028,7 +1028,7 @@ func (r *ReconcileArgoCD) systemCATrustMapper(ctx context.Context, o client.Obje
10281028
return []reconcile.Request{}
10291029
}
10301030

1031-
func isRelevantCtb(proj corev1.ClusterTrustBundleProjection, actual *v1beta1.ClusterTrustBundle) bool {
1031+
func isRelevantCtb(proj corev1.ClusterTrustBundleProjection, actual *certificatesv1beta1.ClusterTrustBundle) bool {
10321032
// ClusterTrustBundle uses either .Name or .SignerName plus eventual .LabelSelector to identify the source
10331033
if proj.Name != nil && *proj.Name == actual.Name {
10341034
return true

tests/ginkgo/sequential/1-120_repo_server_system_ca_trust.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242

4343
. "github.com/onsi/ginkgo/v2"
4444
. "github.com/onsi/gomega"
45-
certificatesv1alpha1 "k8s.io/api/certificates/v1beta1"
45+
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
4646
corev1 "k8s.io/api/core/v1"
4747
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4848
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -369,8 +369,8 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
369369
Eventually(actualTrust, "30s", "5s").Should(trustCerts(Equal(2), Not(BeEmpty())), actualTrust.diagnose())
370370

371371
By("updating ClusterTrustBundle with 1 cert")
372-
ctbUpdate(combinedCtb, func(bundle *certificatesv1alpha1.ClusterTrustBundle) {
373-
bundle.Spec = certificatesv1alpha1.ClusterTrustBundleSpec{
372+
ctbUpdate(combinedCtb, func(bundle *certificatesv1beta1.ClusterTrustBundle) {
373+
bundle.Spec = certificatesv1beta1.ClusterTrustBundleSpec{
374374
SignerName: bundle.Spec.SignerName,
375375
TrustBundle: getCACert("github.com"),
376376
}
@@ -459,7 +459,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
459459
})
460460
})
461461

462-
func ctbUpdate(obj *certificatesv1alpha1.ClusterTrustBundle, modify func(*certificatesv1alpha1.ClusterTrustBundle)) {
462+
func ctbUpdate(obj *certificatesv1beta1.ClusterTrustBundle, modify func(*certificatesv1beta1.ClusterTrustBundle)) {
463463
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
464464
// Retrieve the latest version of the object
465465
err := k8sClient.Get(context.Background(), client.ObjectKeyFromObject(obj), obj)
@@ -487,7 +487,7 @@ func argoCDSpec(ns *corev1.Namespace, repoSpec argov1beta1api.ArgoCDRepoSpec) *a
487487
}
488488

489489
func detectClusterTrustBundleSupport(k8sClient client.Client, ctx context.Context) bool {
490-
err := k8sClient.List(ctx, &certificatesv1alpha1.ClusterTrustBundleList{})
490+
err := k8sClient.List(ctx, &certificatesv1beta1.ClusterTrustBundleList{})
491491
if _, ok := err.(*apiutil.ErrResourceDiscoveryFailed); ok {
492492
return false
493493
}
@@ -626,19 +626,19 @@ func createPluginApp(ns *corev1.Namespace, url string) *appv1alpha1.Application
626626
}
627627
}
628628

629-
func createCtbFromCerts(bundle ...string) *certificatesv1alpha1.ClusterTrustBundle {
630-
return &certificatesv1alpha1.ClusterTrustBundle{
629+
func createCtbFromCerts(bundle ...string) *certificatesv1beta1.ClusterTrustBundle {
630+
return &certificatesv1beta1.ClusterTrustBundle{
631631
TypeMeta: metav1.TypeMeta{
632632
Kind: "ClusterTrustBundle",
633-
APIVersion: "certificates.k8s.io/v1alpha1",
633+
APIVersion: "certificates.k8s.io/v1beta1",
634634
},
635635
ObjectMeta: metav1.ObjectMeta{
636636
Name: "repo-server-system-ca-trust",
637637
Labels: map[string]string{
638638
"argocd-operator-test": "repo_server_system_ca_trust",
639639
},
640640
},
641-
Spec: certificatesv1alpha1.ClusterTrustBundleSpec{
641+
Spec: certificatesv1beta1.ClusterTrustBundleSpec{
642642
TrustBundle: strings.Join(bundle, "\n"),
643643
},
644644
}
@@ -855,6 +855,6 @@ func verifyCorrectlyConfiguredTrust(ns *corev1.Namespace) {
855855
func purgeCtbs() {
856856
if clusterSupportsClusterTrustBundles {
857857
expr := client.MatchingLabels{"argocd-operator-test": "repo_server_system_ca_trust"}
858-
Expect(k8sClient.DeleteAllOf(ctx, &certificatesv1alpha1.ClusterTrustBundle{}, expr)).To(Succeed())
858+
Expect(k8sClient.DeleteAllOf(ctx, &certificatesv1beta1.ClusterTrustBundle{}, expr)).To(Succeed())
859859
}
860860
}

0 commit comments

Comments
 (0)