Skip to content

Missing merge logic in resource.sdkFind when CRD field is renamed #773

@a-hilaly

Description

@a-hilaly

Describe the bug

ack-generate doesn't generate a complete "merge" logic in sdkFind when one the CRD fields is renamed, and the related API call returns a list of objects (e.g ecr.DescribeRepositories)

Steps to reproduce
Regenerate ECR controller with the following configuration

resources:
  Repository:
    renames:
      operations:
        CreateRepository:
          input_fields:
            RepositoryName: Name
  

Note the following diff

$ git diff main

@@ -108,16 +109,6 @@ func (rm *resourceManager) sdkFind(
                        tmpARN := ackv1alpha1.AWSResourceName(*elem.RepositoryArn)
                        ko.Status.ACKResourceMetadata.ARN = &tmpARN
                }
-               if elem.RepositoryName != nil {
-                       if ko.Spec.RepositoryName != nil {
-                               if *elem.RepositoryName != *ko.Spec.RepositoryName {
-                                       continue
-                               }
-                       }
-                       ko.Spec.RepositoryName = elem.RepositoryName
-               } else {
-                       ko.Spec.RepositoryName = nil
-               }
                if elem.RepositoryUri != nil {
                        ko.Status.RepositoryURI = elem.RepositoryUri
                } else {

Expected outcome
The delete block of code should be changed to something like instead:

if elem.RepositoryName != nil {
	if ko.Spec.Name != nil {
		if *elem.RepositoryName != *ko.Spec.Name {
			continue
		}
	}
	ko.Spec.Name = elem.RepositoryName
} else {
	ko.Spec.Name = nil
}

Metadata

Metadata

Assignees

No one assigned

    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