From 8d843f48df4504e3d19712c0e27dbb388ff40cc0 Mon Sep 17 00:00:00 2001 From: Amine Date: Mon, 19 Dec 2022 16:44:40 +0100 Subject: [PATCH] Fix panic in code generator when generating lambda controller (#384) The recent patch ([PR 383](https://github.com/aws-controllers-k8s/code-generator/pull/383)) introduced a regression that caused the code generator to panic when generating the lambda controller. This commit addresses the issue by adding a check to ensure that the shapeRef reference is not nil before accessing the Documentation field. This prevents the panic from occurring and allows the code generator to function correctly. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --- templates/apis/crd.go.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/apis/crd.go.tpl b/templates/apis/crd.go.tpl index 5b8d9791..29b69d21 100644 --- a/templates/apis/crd.go.tpl +++ b/templates/apis/crd.go.tpl @@ -16,7 +16,7 @@ import ( {{ .CRD.Documentation }} type {{ .CRD.Kind }}Spec struct { {{ range $fieldName, $field := .CRD.SpecFields }} -{{ if $field.ShapeRef.Documentation -}} +{{ if $field.ShapeRef -}} {{ $field.ShapeRef.Documentation }} {{ end -}} {{- if and ($field.IsRequired) (not $field.HasReference) -}}