Skip to content

Commit dfc8448

Browse files
lmicciniclaude
andcommitted
Remove consumer-facing transport secret helpers superseded by lib-common
ManageTransportSecretFinalizer and RemoveTransportSecretConsumerFinalizer are now available as generic object.ManageSecretConsumerFinalizer and object.RemoveSecretConsumerFinalizer in lib-common. Consumer operators should migrate to the lib-common versions. Keep HasTransportConsumerFinalizer and HasSpecificTransportConsumerFinalizer which are provider-side helpers used by the TransportURL controller. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 262820c commit dfc8448

1 file changed

Lines changed: 0 additions & 57 deletions

File tree

apis/rabbitmq/v1beta1/transporturl_helpers.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,69 +15,12 @@ limitations under the License.
1515
package v1beta1
1616

1717
import (
18-
"context"
19-
"fmt"
2018
"strings"
2119

22-
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
23-
"github.com/openstack-k8s-operators/lib-common/modules/common/object"
2420
corev1 "k8s.io/api/core/v1"
25-
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
26-
"k8s.io/apimachinery/pkg/types"
2721
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2822
)
2923

30-
// ManageTransportSecretFinalizer ensures consumerFinalizer is present on the
31-
// transport secret identified by secretName. It never removes the finalizer
32-
// from a previous secret — that is the consumer's responsibility after it has
33-
// confirmed its deployment is running with the new credentials (typically via
34-
// RemoveTransportSecretConsumerFinalizer). This ensures the TransportURL
35-
// controller waits for all consumers before releasing the old RabbitMQ user.
36-
func ManageTransportSecretFinalizer(
37-
ctx context.Context,
38-
h *helper.Helper,
39-
namespace string,
40-
secretName string,
41-
consumerFinalizer string,
42-
) error {
43-
if secretName == "" {
44-
return nil
45-
}
46-
47-
secret := &corev1.Secret{}
48-
key := types.NamespacedName{Name: secretName, Namespace: namespace}
49-
if err := h.GetClient().Get(ctx, key, secret); err != nil {
50-
return fmt.Errorf("failed to get transport secret %s: %w", secretName, err)
51-
}
52-
53-
return object.AddConsumerFinalizer(ctx, h, secret, consumerFinalizer)
54-
}
55-
56-
// RemoveTransportSecretConsumerFinalizer removes consumerFinalizer from the
57-
// transport secret identified by secretName. It is a no-op when secretName
58-
// is empty or the secret no longer exists.
59-
func RemoveTransportSecretConsumerFinalizer(
60-
ctx context.Context,
61-
h *helper.Helper,
62-
namespace string,
63-
secretName string,
64-
consumerFinalizer string,
65-
) error {
66-
if secretName == "" {
67-
return nil
68-
}
69-
70-
secret := &corev1.Secret{}
71-
key := types.NamespacedName{Name: secretName, Namespace: namespace}
72-
if err := h.GetClient().Get(ctx, key, secret); err != nil {
73-
if k8s_errors.IsNotFound(err) {
74-
return nil
75-
}
76-
return err
77-
}
78-
return object.RemoveConsumerFinalizer(ctx, h, secret, consumerFinalizer)
79-
}
80-
8124
// HasTransportConsumerFinalizer returns true if the secret has any finalizer
8225
// matching the transport consumer pattern (openstack.org/*-transport-consumer).
8326
func HasTransportConsumerFinalizer(secret *corev1.Secret) bool {

0 commit comments

Comments
 (0)