mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-07-09 19:22:21 +02:00
When an ObjectStore's credentials change (e.g., secret rename), the RBAC Role granting the Cluster's ServiceAccount access to those secrets was not updated because nothing triggered a Cluster reconciliation. Implement the ObjectStore controller's Reconcile to detect referencing Clusters and update their Roles directly. Extract ensureRole into a shared rbac.EnsureRole function used by both the Pre hook and the ObjectStore controller. The shared EnsureRole accepts optional beforeCreate callbacks so the Pre hook can set owner references on Role creation, while the ObjectStore controller path skips ownership (it only updates existing Roles). Handle deleted ObjectStores gracefully by skipping NotFound errors during Role reconciliation, and filter status-only changes with GenerationChangedPredicate. Add RBAC permission for the plugin to list/watch Clusters so the ObjectStore controller can find affected Clusters. Regenerate config/rbac/role.yaml. Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
33 lines
860 B
Go
33 lines
860 B
Go
/*
|
|
Copyright © contributors to CloudNativePG, established as
|
|
CloudNativePG a Series of LF Projects, LLC.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
package rbac_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
func TestRBAC(t *testing.T) {
|
|
RegisterFailHandler(Fail)
|
|
RunSpecs(t, "RBAC Suite")
|
|
}
|