Skip to content

GoCodeSetResourceIdentifiers does not account for renamed fields #852

@jaypipes

Description

@jaypipes

When regenerating the RDS controller with the latest code-gen, I get the following error:

[jaypipes@thelio code-generator]$ make build-controller SERVICE=rds
building ack-generate ... ok.
Copying common custom resource definitions into rds
Building Kubernetes API objects for rds
Generating deepcopy code for rds
Generating custom resource definitions for rds
Building service controller for rds
Error: template: /home/jaypipes/go/src/github.com/aws-controllers-k8s/code-generator/templates/pkg/resource/resource.go.tpl:77:4: executing "/home/jaypipes/go/src/github.com/aws-controllers-k8s/code-generator/templates/pkg/resource/resource.go.tpl" at <GoCodeSetResourceIdentifiers .CRD "identifier" "r.ko" 1>: error calling GoCodeSetResourceIdentifiers: Primary identifier field 'DBSecurityGroupName' cannot be found in either spec or status.
make: *** [Makefile:32: build-controller] Error 1

The reason for the error is that the DBSecurityGroupName field of the DBSecurityGroup resource has been renamed to just Name and the code that is looking for the primary identifier name is finding the correct field in the Input shape for CreateDBSecurityGroup, however the code that looks for the same field in the Spec or Status does not find that field because the field is actually renamed, so hits this panic:

https://github.com/aws-controllers-k8s/code-generator/blob/a73e0a1736e1f2e206b1b9f602e76d19d7590914/pkg/generate/code/set_resource.go#L939

The solution for this is to look up the memberName in the CRD's Config.Renames block to see if the field has been renamed...

Metadata

Metadata

Assignees

Labels

area/code-generationIssues or PRs as related to controllers or docs code generationkind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions