-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SetResource does not handle String Pointers properly in GenerateCrawler
#1078
Comments
Hi @AaronME , thanks for pointing this out. This issue of different go types for same named field was recently fixed. Please take a look at this fix You'll need to update generator.yaml to provide code-generator the instructions on how to handle this field. See the above mentioned fix's commit message for reference. |
@vijtrip2 Thank you for the fast reply. I had already tried running generation with the following: resources:
Crawler:
fields:
Schedule:
set:
- on: Create
from: ScheduleExpression
- on: Update
from: ScheduleExpression
- on: ReadOne
from: ScheduleExpression
- on: ReadMany
from: ScheduleExpression This did not change any generated code. I have two theories about this:
|
Hi @AaronME! It's this second one. I will try to push a fix for this ASAP. |
Actually, it turns out that Glue's GetCrawler (Singular form/ReadOne) is used and not the list form of GetCrawlers (ReadMany) so this must be some other problem. Looking further into it... |
Yeah, it's the lack of nested struct support (list item 1 above). I'm working on a fix now. |
@jaypipes I appreciate you taking a look at it. |
In attempting to implement the nested field path support for different source and target field Go types, I realized I needed a support package that made working with field paths easier, including taking a field path and finding a ShapeRef within an Output shape that matched the field path. This patch introduces a new `pkg/fieldpath` package with a simple `Path` struct containing a variety of utility methods, as shown in this example Go code snippet: ```go import ( "fmt" awssdkmodel "github.com/aws/aws-sdk-go/private/model/api" "github.com/aws-controllers-k8s/code-generator/pkg/fieldpath" "github.com/aws-controllers-k8s/code-generator/pkg/sdk" ) ... p := fieldpath.FromString("Crawler.Schedule.ScheduleExpression") // Will print "true" fmt.Println(p.HasPrefix("Crawler.Schedule")) // Will print "false" fmt.Println(p.HasPrefix("crawler.Schedule")) // Will print "true" fmt.Println(p.HasPrefixFold("crawler.Schedule")) // Will print "ScheduleExpression" fmt.Println(p.Back()) // Will print "Crawler" fmt.Println(p.Front()) // Find the shape within the GetCrawlerResponse shape that contains the // field referred to by the path... helper := sdk.NewHelper("/path/to/apis", genCfg) api := helper.API("glue") crawlerOutputShape := api.Shapes["GetCrawlerResponse"] schedExpressionShape := p.ShapeRef(crawlerOutputShape) // Will print "ScheduleExpression" fmt.Println(schedExpressionShape.ShapeName) ``` Note that we support list and map type field paths using a single-dot notation since we are only looking at field types and not **values** within the list or map. Signed-off-by: Jay Pipes <jaypipes@gmail.com> Related: aws-controllers-k8s/community#1078 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
We have similar situation in |
I am aware of this issue. For now our lambda controller is ignoring the Layers field. Will /cc you one the PR fixing that once it's open |
@AaronME Sorry for the long delay in addressing this. I have pushed up aws-controllers-k8s/code-generator#255 to address the issue. |
Issues go stale after 90d of inactivity. |
Stale issues rot after 30d of inactivity. |
Rotten issues close after 30d of inactivity. |
@ack-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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:Because
Schedule
is a*string
and not astring
, 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:Environment
The text was updated successfully, but these errors were encountered: