Skip to content

SetResource does not handle String Pointers properly in GenerateCrawler #1078

@AaronME

Description

@AaronME

Describe the bug
aws-controllers-k8s/code-generator#232 introduced the ability to support different goTypes for input/output shapes with the same name. This code is not working for all fields on all resources.

The Crawler Resource on the Glue API exposes a field "Schedule."

In CreateCrawlerInput, "Schedule" is a string.
In GetCrawlerOutput's Crawler, "Schedule" is a type Schedule.

When running this through the latest code-generator, we get the following on the GenerateCrawler method:

	if resp.Crawler.Schedule != nil {
		var f13 string
		cr.Spec.ForProvider.Schedule = f13
	} else {
		cr.Spec.ForProvider.Schedule = nil
	}

Because Schedule is a *string and not a string, this code does not compile.

Steps to reproduce
See generated code in https://github.com/crossplane/provider-aws/blob/2212c0919ed36e8d10f7829ef939d69322766b7e/pkg/controller/glue/crawler/zz_conversions.go#L92

Expected outcome
I would expect the generator to initialize this value as nil for a pointer:

	if resp.Crawler.Schedule != nil {
		cr.Spec.ForProvider.Schedule = resp.Crawler.Schedule
	} else {
		cr.Spec.ForProvider.Schedule = nil
	}

Environment

  • Kubernetes version N/A
  • Using EKS (yes/no), if so version? N/A
  • AWS service targeted (S3, RDS, etc.) glue

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.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.priority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions