Skip to content

Commit

Permalink
fixed wrong marshall in apiserversouece which will fix the missing ce…
Browse files Browse the repository at this point in the history
…Overrides extension (knative#4477) (knative#4479)

* fixed wrong marshall

* fixed UT
  • Loading branch information
capri-xiyue authored and matzew committed Nov 6, 2020
1 parent b8c4e1b commit a44d0a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/reconciler/apiserversource/resources/receive_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a44d0a3

Please sign in to comment.