diff --git a/cmd/broker/ingress/main.go b/cmd/broker/ingress/main.go index e03f792c65..49a28baca5 100644 --- a/cmd/broker/ingress/main.go +++ b/cmd/broker/ingress/main.go @@ -34,7 +34,7 @@ type envConfig struct { } const ( - component = "broker-ingress" + component = "broker-ingress" metricNamespace = "broker" ) diff --git a/pkg/apis/duck/v1alpha1/pubsub_defaults.go b/pkg/apis/duck/v1alpha1/pubsub_defaults.go index 73d5571065..5c8682b2a6 100644 --- a/pkg/apis/duck/v1alpha1/pubsub_defaults.go +++ b/pkg/apis/duck/v1alpha1/pubsub_defaults.go @@ -33,10 +33,9 @@ func (s *PubSubSpec) SetPubSubDefaults(ctx context.Context) { logging.FromContext(ctx).Error("Failed to get the GCPAuthDefaults") return } - if s.ServiceAccountName == "" { + if s.ServiceAccountName == "" && + (s.Secret == nil || equality.Semantic.DeepEqual(s.Secret, &corev1.SecretKeySelector{})) { s.ServiceAccountName = ad.KSA(apis.ParentMeta(ctx).Namespace) - } - if s.Secret == nil || equality.Semantic.DeepEqual(s.Secret, &corev1.SecretKeySelector{}) { s.Secret = ad.Secret(apis.ParentMeta(ctx).Namespace) } } diff --git a/pkg/apis/duck/v1alpha1/pubsub_defaults_test.go b/pkg/apis/duck/v1alpha1/pubsub_defaults_test.go index 3804c11e8d..072a011ab7 100644 --- a/pkg/apis/duck/v1alpha1/pubsub_defaults_test.go +++ b/pkg/apis/duck/v1alpha1/pubsub_defaults_test.go @@ -17,6 +17,7 @@ limitations under the License. package v1alpha1 import ( + "context" "testing" gcpauthtesthelper "github.com/google/knative-gcp/pkg/apis/configs/gcpauth/testhelper" @@ -29,6 +30,7 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { testCases := map[string]struct { orig *PubSubSpec expected *PubSubSpec + ctx context.Context }{ "missing defaults": { orig: &PubSubSpec{}, @@ -40,6 +42,12 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), + }, + "missing default GCP Auth ctx": { + orig: &PubSubSpec{}, + expected: &PubSubSpec{}, + ctx: context.Background(), }, "empty defaults": { orig: &PubSubSpec{ @@ -53,6 +61,7 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), }, "secret exists same key": { orig: &PubSubSpec{ @@ -71,6 +80,7 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), }, "secret exists same name": { orig: &PubSubSpec{ @@ -89,6 +99,7 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "different-key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), }, "secret exists all different": { orig: &PubSubSpec{ @@ -107,11 +118,12 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "different-key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), }, } for n, tc := range testCases { t.Run(n, func(t *testing.T) { - tc.orig.SetPubSubDefaults(gcpauthtesthelper.ContextWithDefaults()) + tc.orig.SetPubSubDefaults(tc.ctx) if diff := cmp.Diff(tc.expected, tc.orig); diff != "" { t.Errorf("Unexpected differences (-want +got): %v", diff) } diff --git a/pkg/apis/duck/v1beta1/pubsub_defaults.go b/pkg/apis/duck/v1beta1/pubsub_defaults.go index 116e7159b8..65ac166eb7 100644 --- a/pkg/apis/duck/v1beta1/pubsub_defaults.go +++ b/pkg/apis/duck/v1beta1/pubsub_defaults.go @@ -33,10 +33,9 @@ func (s *PubSubSpec) SetPubSubDefaults(ctx context.Context) { logging.FromContext(ctx).Error("Failed to get the GCPAuthDefaults") return } - if s.ServiceAccountName == "" { + if s.ServiceAccountName == "" && + (s.Secret == nil || equality.Semantic.DeepEqual(s.Secret, &corev1.SecretKeySelector{})) { s.ServiceAccountName = ad.KSA(apis.ParentMeta(ctx).Namespace) - } - if s.Secret == nil || equality.Semantic.DeepEqual(s.Secret, &corev1.SecretKeySelector{}) { s.Secret = ad.Secret(apis.ParentMeta(ctx).Namespace) } } diff --git a/pkg/apis/duck/v1beta1/pubsub_defaults_test.go b/pkg/apis/duck/v1beta1/pubsub_defaults_test.go index f4ad3013dd..2f2e04da6a 100644 --- a/pkg/apis/duck/v1beta1/pubsub_defaults_test.go +++ b/pkg/apis/duck/v1beta1/pubsub_defaults_test.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1 import ( + "context" "testing" gcpauthtesthelper "github.com/google/knative-gcp/pkg/apis/configs/gcpauth/testhelper" @@ -29,6 +30,7 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { testCases := map[string]struct { orig *PubSubSpec expected *PubSubSpec + ctx context.Context }{ "missing defaults": { orig: &PubSubSpec{}, @@ -40,6 +42,12 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), + }, + "missing default GCP Auth ctx": { + orig: &PubSubSpec{}, + expected: &PubSubSpec{}, + ctx: context.Background(), }, "empty defaults": { orig: &PubSubSpec{ @@ -53,6 +61,7 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), }, "secret exists same key": { orig: &PubSubSpec{ @@ -71,6 +80,7 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), }, "secret exists same name": { orig: &PubSubSpec{ @@ -89,6 +99,7 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "different-key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), }, "secret exists all different": { orig: &PubSubSpec{ @@ -107,11 +118,12 @@ func TestPubSubSpec_SetPubSubDefaults(t *testing.T) { Key: "different-key.json", }, }, + ctx: gcpauthtesthelper.ContextWithDefaults(), }, } for n, tc := range testCases { t.Run(n, func(t *testing.T) { - tc.orig.SetPubSubDefaults(gcpauthtesthelper.ContextWithDefaults()) + tc.orig.SetPubSubDefaults(tc.ctx) if diff := cmp.Diff(tc.expected, tc.orig); diff != "" { t.Errorf("Unexpected differences (-want +got): %v", diff) } diff --git a/pkg/apis/intevents/v1alpha1/topic_defaults.go b/pkg/apis/intevents/v1alpha1/topic_defaults.go index 3b87a8cc65..a70b1b4903 100644 --- a/pkg/apis/intevents/v1alpha1/topic_defaults.go +++ b/pkg/apis/intevents/v1alpha1/topic_defaults.go @@ -53,10 +53,9 @@ func (ts *TopicSpec) SetDefaults(ctx context.Context) { logging.FromContext(ctx).Error("Failed to get the GCPAuthDefaults") return } - if ts.ServiceAccountName == "" { + if ts.ServiceAccountName == "" && + (ts.Secret == nil || equality.Semantic.DeepEqual(ts.Secret, &corev1.SecretKeySelector{})) { ts.ServiceAccountName = ad.KSA(apis.ParentMeta(ctx).Namespace) - } - if ts.Secret == nil || equality.Semantic.DeepEqual(ts.Secret, &corev1.SecretKeySelector{}) { ts.Secret = ad.Secret(apis.ParentMeta(ctx).Namespace) } diff --git a/pkg/apis/intevents/v1alpha1/topic_defaults_test.go b/pkg/apis/intevents/v1alpha1/topic_defaults_test.go index 805b658fa3..4d4bb0670f 100644 --- a/pkg/apis/intevents/v1alpha1/topic_defaults_test.go +++ b/pkg/apis/intevents/v1alpha1/topic_defaults_test.go @@ -17,6 +17,7 @@ limitations under the License. package v1alpha1 import ( + "context" "testing" gcpauthtesthelper "github.com/google/knative-gcp/pkg/apis/configs/gcpauth/testhelper" @@ -30,33 +31,63 @@ import ( ) func TestTopicDefaults(t *testing.T) { - want := &Topic{ - ObjectMeta: metav1.ObjectMeta{ - Annotations: map[string]string{ - duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, - }, + testCases := map[string]struct { + want *Topic + got *Topic + ctx context.Context + }{ + "with GCP Auth": { + want: &Topic{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, + }, + }, + Spec: TopicSpec{ + PropagationPolicy: TopicPolicyCreateNoDelete, + Secret: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "google-cloud-key", + }, + Key: "key.json", + }, + EnablePublisher: &trueVal, + }}, + got: &Topic{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, + }, + }, + Spec: TopicSpec{}}, + ctx: gcpauthtesthelper.ContextWithDefaults(), }, - Spec: TopicSpec{ - PropagationPolicy: TopicPolicyCreateNoDelete, - Secret: &corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "google-cloud-key", + "without GCP Auth": { + want: &Topic{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, + }, }, - Key: "key.json", + Spec: TopicSpec{ + PropagationPolicy: TopicPolicyCreateNoDelete}, }, - EnablePublisher: &trueVal, - }} - - got := &Topic{ - ObjectMeta: metav1.ObjectMeta{ - Annotations: map[string]string{ - duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, + got: &Topic{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, + }, + }, }, + ctx: context.Background(), }, - Spec: TopicSpec{}} - got.SetDefaults(gcpauthtesthelper.ContextWithDefaults()) - - if diff := cmp.Diff(want, got); diff != "" { - t.Errorf("failed to get expected (-want, +got) = %v", diff) + } + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + tc.got.SetDefaults(tc.ctx) + if diff := cmp.Diff(tc.want, tc.got); diff != "" { + t.Errorf("Unexpected differences (-want +got): %v", diff) + } + }) } } diff --git a/pkg/apis/intevents/v1beta1/topic_defaults.go b/pkg/apis/intevents/v1beta1/topic_defaults.go index 81db40dd1d..e4685183ed 100644 --- a/pkg/apis/intevents/v1beta1/topic_defaults.go +++ b/pkg/apis/intevents/v1beta1/topic_defaults.go @@ -46,10 +46,9 @@ func (ts *TopicSpec) SetDefaults(ctx context.Context) { logging.FromContext(ctx).Error("Failed to get the GCPAuthDefaults") return } - if ts.ServiceAccountName == "" { + if ts.ServiceAccountName == "" && + (ts.Secret == nil || equality.Semantic.DeepEqual(ts.Secret, &corev1.SecretKeySelector{})) { ts.ServiceAccountName = ad.KSA(apis.ParentMeta(ctx).Namespace) - } - if ts.Secret == nil || equality.Semantic.DeepEqual(ts.Secret, &corev1.SecretKeySelector{}) { ts.Secret = ad.Secret(apis.ParentMeta(ctx).Namespace) } diff --git a/pkg/apis/intevents/v1beta1/topic_defaults_test.go b/pkg/apis/intevents/v1beta1/topic_defaults_test.go index f40f6844da..52014ed6ef 100644 --- a/pkg/apis/intevents/v1beta1/topic_defaults_test.go +++ b/pkg/apis/intevents/v1beta1/topic_defaults_test.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1 import ( + "context" "testing" "github.com/google/go-cmp/cmp" @@ -25,21 +26,39 @@ import ( ) func TestTopicDefaults(t *testing.T) { - want := &Topic{Spec: TopicSpec{ - PropagationPolicy: TopicPolicyCreateNoDelete, - Secret: &corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "google-cloud-key", + testCases := map[string]struct { + want *Topic + got *Topic + ctx context.Context + }{ + "with GCP Auth": { + want: &Topic{Spec: TopicSpec{ + PropagationPolicy: TopicPolicyCreateNoDelete, + Secret: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "google-cloud-key", + }, + Key: "key.json", + }, + EnablePublisher: &trueVal, + }}, + got: &Topic{Spec: TopicSpec{}}, + ctx: gcpauthtesthelper.ContextWithDefaults(), + }, + "without GCP Auth": { + want: &Topic{Spec: TopicSpec{ + PropagationPolicy: TopicPolicyCreateNoDelete}, }, - Key: "key.json", + got: &Topic{}, + ctx: context.Background(), }, - EnablePublisher: &trueVal, - }} - - got := &Topic{Spec: TopicSpec{}} - got.SetDefaults(gcpauthtesthelper.ContextWithDefaults()) - - if diff := cmp.Diff(want, got); diff != "" { - t.Errorf("failed to get expected (-want, +got) = %v", diff) + } + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + tc.got.SetDefaults(tc.ctx) + if diff := cmp.Diff(tc.want, tc.got); diff != "" { + t.Errorf("Unexpected differences (-want +got): %v", diff) + } + }) } } diff --git a/pkg/reconciler/events/auditlogs/auditlogs_test.go b/pkg/reconciler/events/auditlogs/auditlogs_test.go index 9b9e23642a..ab7f520b7b 100644 --- a/pkg/reconciler/events/auditlogs/auditlogs_test.go +++ b/pkg/reconciler/events/auditlogs/auditlogs_test.go @@ -434,7 +434,7 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudAuditLogsSourceDefaultAuthorization(), + WithCloudAuditLogsSourceDefaultGCPAuth(), ), NewTopic(sourceName, testNS, WithTopicSpec(inteventsv1alpha1.TopicSpec{ @@ -445,7 +445,7 @@ func TestAllCases(t *testing.T) { WithTopicReady(testTopicID), WithTopicAddress(testTopicURI), WithTopicProjectID(testProject), - WithTopicDefaultAuthorization(), + WithTopicDefaultGCPAuth(), ), }, Key: testNS + "/" + sourceName, @@ -461,7 +461,7 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudAuditLogsSourceDefaultAuthorization(), + WithCloudAuditLogsSourceDefaultGCPAuth(), WithCloudAuditLogsSourcePullSubscriptionUnknown("PullSubscriptionNotConfigured", failedToReconcilePullSubscriptionMsg), ), }}, @@ -484,7 +484,7 @@ func TestAllCases(t *testing.T) { duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{sourceOwnerRef(sourceName, sourceUID)}), - WithPullSubscriptionDefaultAuthorization(), + WithPullSubscriptionDefaultGCPAuth(), ), }, WantPatches: []clientgotesting.PatchActionImpl{ diff --git a/pkg/reconciler/events/build/build_test.go b/pkg/reconciler/events/build/build_test.go index ab87a59f06..6cd9ff6a07 100644 --- a/pkg/reconciler/events/build/build_test.go +++ b/pkg/reconciler/events/build/build_test.go @@ -166,7 +166,7 @@ func TestAllCases(t *testing.T) { WithCloudBuildSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudBuildSourceDefaultAuthorization(), + WithCloudBuildSourceDefaultGCPAuth(), ), newSink(), }, @@ -182,7 +182,7 @@ func TestAllCases(t *testing.T) { WithCloudBuildSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudBuildSourceDefaultAuthorization(), + WithCloudBuildSourceDefaultGCPAuth(), WithCloudBuildSourcePullSubscriptionUnknown("PullSubscriptionNotConfigured", "PullSubscription has not yet been reconciled"), ), }}, @@ -207,7 +207,7 @@ func TestAllCases(t *testing.T) { duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), - WithPullSubscriptionDefaultAuthorization(), + WithPullSubscriptionDefaultGCPAuth(), ), }, WantPatches: []clientgotesting.PatchActionImpl{ diff --git a/pkg/reconciler/events/pubsub/pubsub_test.go b/pkg/reconciler/events/pubsub/pubsub_test.go index a8f78003a4..6374674b91 100644 --- a/pkg/reconciler/events/pubsub/pubsub_test.go +++ b/pkg/reconciler/events/pubsub/pubsub_test.go @@ -164,7 +164,7 @@ func TestAllCases(t *testing.T) { WithCloudPubSubSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudPubSubSourceDefaultAuthorization(), + WithCloudPubSubSourceDefaultGCPAuth(), ), newSink(), }, @@ -180,7 +180,7 @@ func TestAllCases(t *testing.T) { WithCloudPubSubSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudPubSubSourceDefaultAuthorization(), + WithCloudPubSubSourceDefaultGCPAuth(), WithCloudPubSubSourcePullSubscriptionUnknown("PullSubscriptionNotConfigured", "PullSubscription has not yet been reconciled"), ), }}, @@ -203,7 +203,7 @@ func TestAllCases(t *testing.T) { duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), - WithPullSubscriptionDefaultAuthorization(), + WithPullSubscriptionDefaultGCPAuth(), ), }, WantPatches: []clientgotesting.PatchActionImpl{ diff --git a/pkg/reconciler/events/scheduler/resources/names_test.go b/pkg/reconciler/events/scheduler/resources/names_test.go index b110177fad..9bfdac7ff8 100644 --- a/pkg/reconciler/events/scheduler/resources/names_test.go +++ b/pkg/reconciler/events/scheduler/resources/names_test.go @@ -29,7 +29,7 @@ func TestGenerateJobName(t *testing.T) { want := "projects/project/locations/location/" + JobPrefix + "-uid" got := GenerateJobName(&v1alpha1.CloudSchedulerSource{ ObjectMeta: metav1.ObjectMeta{ - UID: "uid", + UID: "uid", }, Spec: v1alpha1.CloudSchedulerSourceSpec{ Location: "location", diff --git a/pkg/reconciler/events/scheduler/scheduler_test.go b/pkg/reconciler/events/scheduler/scheduler_test.go index 2bf473c26e..c8af0756a2 100644 --- a/pkg/reconciler/events/scheduler/scheduler_test.go +++ b/pkg/reconciler/events/scheduler/scheduler_test.go @@ -462,7 +462,7 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudSchedulerSourceDefaultAuthorization(), + WithCloudSchedulerSourceDefaultGCPAuth(), ), NewTopic(schedulerName, testNS, WithTopicSpec(inteventsv1alpha1.TopicSpec{ @@ -473,7 +473,7 @@ func TestAllCases(t *testing.T) { WithTopicReady(testTopicID), WithTopicAddress(testTopicURI), WithTopicProjectID(testProject), - WithTopicDefaultAuthorization(), + WithTopicDefaultGCPAuth(), ), newSink(), }, @@ -489,7 +489,7 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudSchedulerSourceDefaultAuthorization(), + WithCloudSchedulerSourceDefaultGCPAuth(), WithCloudSchedulerSourcePullSubscriptionUnknown("PullSubscriptionNotConfigured", failedToReconcilePullSubscriptionMsg), ), }}, diff --git a/pkg/reconciler/events/storage/storage_test.go b/pkg/reconciler/events/storage/storage_test.go index c6c118c9a2..3e98e6daf1 100644 --- a/pkg/reconciler/events/storage/storage_test.go +++ b/pkg/reconciler/events/storage/storage_test.go @@ -453,7 +453,7 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudStorageSourceDefaultAuthorization(), + WithCloudStorageSourceDefaultGCPAuth(), ), NewTopic(storageName, testNS, WithTopicSpec(inteventsv1alpha1.TopicSpec{ @@ -464,7 +464,7 @@ func TestAllCases(t *testing.T) { WithTopicReady(testTopicID), WithTopicAddress(testTopicURI), WithTopicProjectID(testProject), - WithTopicDefaultAuthorization(), + WithTopicDefaultGCPAuth(), ), newSink(), }, @@ -481,7 +481,7 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceAnnotations(map[string]string{ duckv1alpha1.ClusterNameAnnotation: testingMetadataClient.FakeClusterName, }), - WithCloudStorageSourceDefaultAuthorization(), + WithCloudStorageSourceDefaultGCPAuth(), WithCloudStorageSourcePullSubscriptionUnknown("PullSubscriptionNotConfigured", failedToReconcilepullSubscriptionMsg), ), }}, diff --git a/pkg/reconciler/intevents/pullsubscription/keda/pullsubscription_test.go b/pkg/reconciler/intevents/pullsubscription/keda/pullsubscription_test.go index cead5e2f21..6d1bd28b80 100644 --- a/pkg/reconciler/intevents/pullsubscription/keda/pullsubscription_test.go +++ b/pkg/reconciler/intevents/pullsubscription/keda/pullsubscription_test.go @@ -70,9 +70,9 @@ const ( sourceUID = sourceName + "-abc-123" - testProject = "test-project-id" - testTopicID = sourceUID + "-TOPIC" - generation = 1 + testProject = "test-project-id" + testTopicID = sourceUID + "-TOPIC" + generation = 1 secretName = "testing-secret" diff --git a/pkg/reconciler/intevents/pullsubscription/resources/receive_adapter_test.go b/pkg/reconciler/intevents/pullsubscription/resources/receive_adapter_test.go index e446f861c8..8b855d4184 100644 --- a/pkg/reconciler/intevents/pullsubscription/resources/receive_adapter_test.go +++ b/pkg/reconciler/intevents/pullsubscription/resources/receive_adapter_test.go @@ -54,7 +54,7 @@ func TestMakeMinimumReceiveAdapter(t *testing.T) { } got := MakeReceiveAdapter(context.Background(), &ReceiveAdapterArgs{ - Image: "test-image", + Image: "test-image", PullSubscription: ps, Labels: map[string]string{ "test-key1": "test-value1", @@ -210,7 +210,7 @@ func TestMakeFullReceiveAdapter(t *testing.T) { } got := MakeReceiveAdapter(context.Background(), &ReceiveAdapterArgs{ - Image: "test-image", + Image: "test-image", PullSubscription: ps, Labels: map[string]string{ "test-key1": "test-value1", @@ -378,7 +378,7 @@ func TestMakeReceiveAdapterWithGCPServiceAccount(t *testing.T) { } got := MakeReceiveAdapter(context.Background(), &ReceiveAdapterArgs{ - Image: "test-image", + Image: "test-image", PullSubscription: ps, Labels: map[string]string{ "test-key1": "test-value1", diff --git a/pkg/reconciler/intevents/pullsubscription/static/pullsubscription_test.go b/pkg/reconciler/intevents/pullsubscription/static/pullsubscription_test.go index 65e6b13835..937d170dea 100644 --- a/pkg/reconciler/intevents/pullsubscription/static/pullsubscription_test.go +++ b/pkg/reconciler/intevents/pullsubscription/static/pullsubscription_test.go @@ -65,9 +65,9 @@ const ( sourceUID = sourceName + "-abc-123" - testProject = "test-project-id" - testTopicID = sourceUID + "-TOPIC" - generation = 1 + testProject = "test-project-id" + testTopicID = sourceUID + "-TOPIC" + generation = 1 secretName = "testing-secret" diff --git a/pkg/reconciler/intevents/reconciler_test.go b/pkg/reconciler/intevents/reconciler_test.go index 4074c1b2b3..7c6277a17a 100644 --- a/pkg/reconciler/intevents/reconciler_test.go +++ b/pkg/reconciler/intevents/reconciler_test.go @@ -87,7 +87,7 @@ var ( pubsubable = rectesting.NewCloudStorageSource(name, testNS, rectesting.WithCloudStorageSourceSinkDestination(sink), - rectesting.WithCloudStorageSourceDefaultAuthorization()) + rectesting.WithCloudStorageSourceDefaultGCPAuth()) ignoreLastTransitionTime = cmp.FilterPath(func(p cmp.Path) bool { return strings.HasSuffix(p.String(), "LastTransitionTime.Inner.Time") diff --git a/pkg/reconciler/testing/auditlogs.go b/pkg/reconciler/testing/auditlogs.go index bef52ad4a0..85ccd33a59 100644 --- a/pkg/reconciler/testing/auditlogs.go +++ b/pkg/reconciler/testing/auditlogs.go @@ -200,7 +200,7 @@ func WithCloudAuditLogsSourceAnnotations(Annotations map[string]string) CloudAud } } -func WithCloudAuditLogsSourceDefaultAuthorization() CloudAuditLogsSourceOption { +func WithCloudAuditLogsSourceDefaultGCPAuth() CloudAuditLogsSourceOption { return func(s *v1alpha1.CloudAuditLogsSource) { s.Spec.PubSubSpec.SetPubSubDefaults(gcpauthtesthelper.ContextWithDefaults()) } diff --git a/pkg/reconciler/testing/build.go b/pkg/reconciler/testing/build.go index 51052c505e..cddf636823 100644 --- a/pkg/reconciler/testing/build.go +++ b/pkg/reconciler/testing/build.go @@ -164,7 +164,7 @@ func WithCloudBuildSourceAnnotations(Annotations map[string]string) CloudBuildSo } } -func WithCloudBuildSourceDefaultAuthorization() CloudBuildSourceOption { +func WithCloudBuildSourceDefaultGCPAuth() CloudBuildSourceOption { return func(s *v1alpha1.CloudBuildSource) { s.Spec.PubSubSpec.SetPubSubDefaults(gcpauthtesthelper.ContextWithDefaults()) } diff --git a/pkg/reconciler/testing/pubsub.go b/pkg/reconciler/testing/pubsub.go index b3d2a36568..38666e62c2 100644 --- a/pkg/reconciler/testing/pubsub.go +++ b/pkg/reconciler/testing/pubsub.go @@ -162,7 +162,7 @@ func WithCloudPubSubSourceAnnotations(Annotations map[string]string) CloudPubSub } } -func WithCloudPubSubSourceDefaultAuthorization() CloudPubSubSourceOption { +func WithCloudPubSubSourceDefaultGCPAuth() CloudPubSubSourceOption { return func(s *v1alpha1.CloudPubSubSource) { s.Spec.PubSubSpec.SetPubSubDefaults(gcpauthtesthelper.ContextWithDefaults()) } diff --git a/pkg/reconciler/testing/pullsubscription.go b/pkg/reconciler/testing/pullsubscription.go index 3f078425c9..3169c89751 100644 --- a/pkg/reconciler/testing/pullsubscription.go +++ b/pkg/reconciler/testing/pullsubscription.go @@ -285,7 +285,7 @@ func WithPullSubscriptionMode(mode v1alpha1.ModeType) PullSubscriptionOption { } } -func WithPullSubscriptionDefaultAuthorization() PullSubscriptionOption { +func WithPullSubscriptionDefaultGCPAuth() PullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Spec.PubSubSpec.SetPubSubDefaults(gcpauthtesthelper.ContextWithDefaults()) } diff --git a/pkg/reconciler/testing/scheduler.go b/pkg/reconciler/testing/scheduler.go index 6a22fe031f..5063880de3 100644 --- a/pkg/reconciler/testing/scheduler.go +++ b/pkg/reconciler/testing/scheduler.go @@ -211,7 +211,7 @@ func WithCloudSchedulerSourceAnnotations(Annotations map[string]string) CloudSch } } -func WithCloudSchedulerSourceDefaultAuthorization() CloudSchedulerSourceOption { +func WithCloudSchedulerSourceDefaultGCPAuth() CloudSchedulerSourceOption { return func(s *v1alpha1.CloudSchedulerSource) { s.Spec.PubSubSpec.SetPubSubDefaults(gcpauthtesthelper.ContextWithDefaults()) } diff --git a/pkg/reconciler/testing/storage.go b/pkg/reconciler/testing/storage.go index 06b9725fdb..2a5da4b60e 100644 --- a/pkg/reconciler/testing/storage.go +++ b/pkg/reconciler/testing/storage.go @@ -236,7 +236,7 @@ func WithCloudStorageSourceAnnotations(Annotations map[string]string) CloudStora } } -func WithCloudStorageSourceDefaultAuthorization() CloudStorageSourceOption { +func WithCloudStorageSourceDefaultGCPAuth() CloudStorageSourceOption { return func(s *v1alpha1.CloudStorageSource) { s.Spec.PubSubSpec.SetPubSubDefaults(gcpauthtesthelper.ContextWithDefaults()) } diff --git a/pkg/reconciler/testing/topic.go b/pkg/reconciler/testing/topic.go index 0bae38e945..9818bda8fa 100644 --- a/pkg/reconciler/testing/topic.go +++ b/pkg/reconciler/testing/topic.go @@ -195,7 +195,7 @@ func WithTopicAnnotations(annotations map[string]string) TopicOption { } } -func WithTopicDefaultAuthorization() TopicOption { +func WithTopicDefaultGCPAuth() TopicOption { return func(t *v1alpha1.Topic) { t.Spec.SetDefaults(gcpauthtesthelper.ContextWithDefaults()) } diff --git a/pkg/utils/naming/names_test.go b/pkg/utils/naming/names_test.go index 07d77419b3..4c3f76cb4e 100644 --- a/pkg/utils/naming/names_test.go +++ b/pkg/utils/naming/names_test.go @@ -26,7 +26,7 @@ import ( ) const ( - testUID = "11186600-4003-4ad6-90e7-22780053debf" + testUID = "11186600-4003-4ad6-90e7-22780053debf" // truncatedPubSubNameMax is computed as follows: // pubsub resource name max length: 255 chars @@ -42,7 +42,7 @@ const ( // uid length: 36 chars // 100 max - 36 uid - 1 uid separator // These are the maximum available characters to use for prefix, ns, name and their separators. - truncatedSinkNamesMax = 63 + truncatedSinkNamesMax = 63 ) var (