Skip to content

Commit 5b7ba59

Browse files
[release-1.18] Fix hardcoded knative-eventing namespace (#8578)
* dizzy: Remove hard-coded knative-eventing namespace and replace with system.Namespace() and touch test to get that properly injected Signed-off-by: Matthias Wessendorf <[email protected]> * broom: Remove yet another hard-coded instance of knative-eventing Signed-off-by: Matthias Wessendorf <[email protected]> --------- Signed-off-by: Matthias Wessendorf <[email protected]> Co-authored-by: Matthias Wessendorf <[email protected]>
1 parent b99e57b commit 5b7ba59

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

pkg/apis/messaging/v1/in_memory_channel_validation.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ import (
2222

2323
"knative.dev/pkg/apis"
2424
"knative.dev/pkg/kmp"
25+
"knative.dev/pkg/system"
2526

2627
"knative.dev/eventing/pkg/apis/eventing"
28+
_ "knative.dev/pkg/system/testing"
2729
)
2830

29-
const eventingControllerSAName = "system:serviceaccount:knative-eventing:eventing-controller"
31+
var eventingControllerSAName = fmt.Sprintf("%s:%s:%s", "system:serviceaccount", system.Namespace(), "eventing-controller")
3032

3133
func (imc *InMemoryChannel) Validate(ctx context.Context) *apis.FieldError {
3234
errs := imc.Spec.Validate(ctx).ViaField("spec")

pkg/apis/messaging/v1/in_memory_channel_validation_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ limitations under the License.
1717
package v1
1818

1919
import (
20+
"fmt"
2021
"testing"
2122

23+
"knative.dev/pkg/system"
24+
2225
"golang.org/x/net/context"
2326
authenticationv1 "k8s.io/api/authentication/v1"
2427
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -139,7 +142,7 @@ func TestInMemoryChannelValidation(t *testing.T) {
139142
want: func() *apis.FieldError {
140143
diff, _ := kmp.ShortDiff(validIMCSingleSubscriber.Spec.Subscribers, validIMCTwoSubscribers.Spec.Subscribers)
141144
return &apis.FieldError{
142-
Message: "Channel.Spec.Subscribers changed by user test-user which was not the system:serviceaccount:knative-eventing:eventing-controller service account",
145+
Message: fmt.Sprintf("%s:%s:%s", "Channel.Spec.Subscribers changed by user test-user which was not the system:serviceaccount", system.Namespace(), "eventing-controller service account"),
143146
Paths: []string{"spec.subscribers"},
144147
Details: diff,
145148
}

pkg/reconciler/broker/resources/eventpolicy.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,21 @@ limitations under the License.
1717
package resources
1818

1919
import (
20+
"fmt"
21+
2022
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2123
"k8s.io/utils/ptr"
2224
eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
2325
eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
2426
eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1"
2527
"knative.dev/pkg/kmeta"
28+
"knative.dev/pkg/system"
2629
)
2730

31+
var OIDCBrokerSub = fmt.Sprintf("%s:%s:%s", "system:serviceaccount", system.Namespace(), "mt-broker-ingress-oidc")
32+
2833
const (
2934
BackingChannelEventPolicyLabelPrefix = "eventing.knative.dev/"
30-
OIDCBrokerSub = "system:serviceaccount:knative-eventing:mt-broker-ingress-oidc"
3135
brokerKind = "Broker"
3236
)
3337

0 commit comments

Comments
 (0)