From a44d0a32e86847c265d86f9c9b312eab990405d2 Mon Sep 17 00:00:00 2001 From: capri-xiyue <52932582+capri-xiyue@users.noreply.github.com> Date: Thu, 5 Nov 2020 20:57:07 -0800 Subject: [PATCH] fixed wrong marshall in apiserversouece which will fix the missing ceOverrides extension (#4477) (#4479) * fixed wrong marshall * fixed UT --- pkg/reconciler/apiserversource/resources/receive_adapter.go | 6 +++--- .../apiserversource/resources/receive_adapter_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/reconciler/apiserversource/resources/receive_adapter.go b/pkg/reconciler/apiserversource/resources/receive_adapter.go index bb90469380a..446e6027898 100644 --- a/pkg/reconciler/apiserversource/resources/receive_adapter.go +++ b/pkg/reconciler/apiserversource/resources/receive_adapter.go @@ -151,10 +151,10 @@ func makeEnv(args *ReceiveAdapterArgs) ([]corev1.EnvVar, error) { envs = append(envs, args.Configs.ToEnvVars()...) - if args.Source.Spec.CloudEventOverrides != nil && args.Source.Spec.CloudEventOverrides.Extensions != nil { - ceJson, err := json.Marshal(args.Source.Spec.CloudEventOverrides.Extensions) + if args.Source.Spec.CloudEventOverrides != nil { + ceJson, err := json.Marshal(args.Source.Spec.CloudEventOverrides) if err != nil { - return nil, fmt.Errorf("Failure to marshal cloud event overrides %v: %v", args.Source.Spec.CloudEventOverrides.Extensions, err) + return nil, fmt.Errorf("Failure to marshal cloud event overrides %v: %v", args.Source.Spec.CloudEventOverrides, err) } envs = append(envs, corev1.EnvVar{Name: adapter.EnvConfigCEOverrides, Value: string(ceJson)}) } diff --git a/pkg/reconciler/apiserversource/resources/receive_adapter_test.go b/pkg/reconciler/apiserversource/resources/receive_adapter_test.go index d5f7778f9e2..cbefd7b11fe 100644 --- a/pkg/reconciler/apiserversource/resources/receive_adapter_test.go +++ b/pkg/reconciler/apiserversource/resources/receive_adapter_test.go @@ -162,7 +162,7 @@ func TestMakeReceiveAdapters(t *testing.T) { ceWant := want.DeepCopy() ceWant.Spec.Template.Spec.Containers[0].Env = append(ceWant.Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{ Name: "K_CE_OVERRIDES", - Value: `{"1":"one"}`, + Value: `{"extensions":{"1":"one"}}`, }) testCases := map[string]struct {