mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-07-09 19:22:21 +02:00
Compare commits
2 Commits
395891c5aa
...
fca31a984c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fca31a984c | ||
|
|
064864ba72 |
@ -25,11 +25,13 @@ import (
|
|||||||
|
|
||||||
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
|
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
|
||||||
"github.com/cloudnative-pg/machinery/pkg/log"
|
"github.com/cloudnative-pg/machinery/pkg/log"
|
||||||
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
apierrs "k8s.io/apimachinery/pkg/api/errors"
|
apierrs "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
ctrl "sigs.k8s.io/controller-runtime"
|
ctrl "sigs.k8s.io/controller-runtime"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/builder"
|
"sigs.k8s.io/controller-runtime/pkg/builder"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/predicate"
|
"sigs.k8s.io/controller-runtime/pkg/predicate"
|
||||||
|
|
||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
@ -115,7 +117,9 @@ func (r *ObjectStoreReconciler) reconcileRBACForCluster(
|
|||||||
barmanObjects = append(barmanObjects, barmanObject)
|
barmanObjects = append(barmanObjects, barmanObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
return rbac.EnsureRole(ctx, r.Client, cluster, barmanObjects)
|
return rbac.EnsureRole(ctx, r.Client, cluster, barmanObjects, func(role *rbacv1.Role) error {
|
||||||
|
return controllerutil.SetControllerReference(cluster, role, r.Scheme)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// referencesObjectStore checks if the given ObjectStore is in the list
|
// referencesObjectStore checks if the given ObjectStore is in the list
|
||||||
|
|||||||
@ -172,6 +172,11 @@ var _ = Describe("ObjectStoreReconciler", func() {
|
|||||||
// Verify the secrets rule contains the expected secret
|
// Verify the secrets rule contains the expected secret
|
||||||
secretsRule := role.Rules[2]
|
secretsRule := role.Rules[2]
|
||||||
Expect(secretsRule.ResourceNames).To(ContainElement("aws-creds"))
|
Expect(secretsRule.ResourceNames).To(ContainElement("aws-creds"))
|
||||||
|
|
||||||
|
// Verify owner reference is set to the Cluster
|
||||||
|
Expect(role.OwnerReferences).To(HaveLen(1))
|
||||||
|
Expect(role.OwnerReferences[0].Name).To(Equal("my-cluster"))
|
||||||
|
Expect(role.OwnerReferences[0].Kind).To(Equal("Cluster"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should skip Clusters that don't reference the ObjectStore", func() {
|
It("should skip Clusters that don't reference the ObjectStore", func() {
|
||||||
@ -263,6 +268,10 @@ var _ = Describe("ObjectStoreReconciler", func() {
|
|||||||
objectStoreRule := role.Rules[0]
|
objectStoreRule := role.Rules[0]
|
||||||
Expect(objectStoreRule.ResourceNames).To(ContainElement("store-a"))
|
Expect(objectStoreRule.ResourceNames).To(ContainElement("store-a"))
|
||||||
Expect(objectStoreRule.ResourceNames).NotTo(ContainElement("store-b"))
|
Expect(objectStoreRule.ResourceNames).NotTo(ContainElement("store-b"))
|
||||||
|
|
||||||
|
// Verify owner reference is set
|
||||||
|
Expect(role.OwnerReferences).To(HaveLen(1))
|
||||||
|
Expect(role.OwnerReferences[0].Name).To(Equal("my-cluster"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should update Role when ObjectStore credentials change", func() {
|
It("should update Role when ObjectStore credentials change", func() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user