-
Notifications
You must be signed in to change notification settings - Fork 271
Description
Describe the bug
While generating the code for references for the Lambda function, specifically more for the S3 bucket field, we observe that there is like use of array keywords with a non-array field which is like len(S3.Bucket) which is incorrect. While doing some debugging we found that there was some missing if-else conditions, a specific case where this should be handled.
Trying to run this code in lambda-controller/generator.yaml
resources:
Function:
fields:
Code.S3Bucket:
references:
resource: Bucket
path: Spec.Name
service_name: s3
This configuration instruct the code generator generate this line of code:
// This doesn't work because s3BucketRef is not an array
len(ko.Spec.Code.S3BucketRef) > 0This most likely happening because of a missing/non discussed condition {{ else if not $isList -}} in https://github.com/aws-controllers-k8s/code-generator/blob/main/templates/pkg/resource/references.go.tpl#L146
Steps to reproduce
Use the configuration above to generate code for code.s3Bucket references
Expected outcome
Generate code that properly resolves references for nested non array types
Environment
- Kubernetes version
- Using EKS (yes/no), if so version?
- AWS service targeted (S3, RDS, etc.)