Skip to content
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

Code generator change for member of type list #452

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nnbu
Copy link
Contributor

@nnbu nnbu commented Jun 6, 2023

Currently code generator assumes the type of 'member' as scalar. But if the member is a list, the generated code needs to be as per that type.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Currently code generator assumes the type of 'member' as scalar.
But if the member is a list, the generated code needs to be as
per that type.
@ack-prow
Copy link

ack-prow bot commented Jun 6, 2023

Hi @nnbu. Thanks for your PR.

I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@ack-prow ack-prow bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 6, 2023
@nnbu
Copy link
Contributor Author

nnbu commented Jun 6, 2023

This change was needed to generate correct code for PR: aws-controllers-k8s/ec2-controller#138

This PR is for adding flowlog feature in ec2 controller.
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateFlowLogs.html

CreateFlowLogs api returns a list of flowlogIDs.

So, the generated code in file pkg/resource/flow_log/sdk.go needs to looks like following (notice '...' in generated code 'r.ko.Status.FlowLogIDs...' ):
func (rm *resourceManager) newListRequestPayload(
r *resource,
) (*svcsdk.DescribeFlowLogsInput, error) {
res := &svcsdk.DescribeFlowLogsInput{}

if r.ko.Status.FlowLogIDs != nil {
	f2 := []*string{}
	f2 = append(f2, r.ko.Status.FlowLogIDs...)
	res.SetFlowLogIds(f2)
}

return res, nil

}

But currently without my change in code-generator, the generated code does not add '...' and so compilation in the generated code fails.
Hence, this change is needed.

cleanFieldNames := names.New(fieldName)
pathFieldName := cleanFieldNames.Camel

if _, ok := r.Fields[pathFieldName]; ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but note that this will not handle nested fields, since the path isn't being built up and only contains the member name. We can cross that bridge when we get to it, though... :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nnbu can you add a comment to IsMemberList stating what is can currently do and it's limitations? maybe a //TODO stating what needs to be added.

@ack-prow
Copy link

ack-prow bot commented Jun 13, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jaypipes, nnbu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot added the approved label Jun 13, 2023
@jaypipes
Copy link
Collaborator

/ok-to-test

@ack-prow ack-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 13, 2023
@a-hilaly
Copy link
Member

/retest

1 similar comment
@a-hilaly
Copy link
Member

/retest

@a-hilaly
Copy link
Member

a-hilaly commented Sep 8, 2023

/test all

@a-hilaly
Copy link
Member

@nnbu could you please address this #452 (comment) - i would like to merge this soon

@a-hilaly
Copy link
Member

/test all

@a-hilaly a-hilaly removed the request for review from RedbackThomson June 14, 2024 17:25
Copy link

ack-prow bot commented Aug 30, 2024

@nnbu: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
dynamodb-controller-test 6df26e3 link true /test dynamodb-controller-test
documentdb-controller-test 6df26e3 link true /test documentdb-controller-test
verify-attribution 6df26e3 link true /test verify-attribution

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants