Skip to content

Adding functionality to assign one API to multiple resources #472

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

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

Vandita2020
Copy link
Member

@Vandita2020 Vandita2020 commented Oct 4, 2023

Fixes #1917

Description:
The PR adds functionality to use same API for an operation on multiple resources. This allows ResourceName to be a list so that same API for an OperationType can map to multiple resources. This is required in certain cases where the same API, for same operation is used for multiple resources.

The solution this PR applies is to pass multiple resources for same API.

This supports following cases cases:

  1. One API -> One Resource
PublishVersion:
    operation_type:
      - Create
    resource_name: 
      - Version
  1. One API -> Multiple Resource
DeleteFunction:
    operation_type:
      - Delete
    resource_name:
      - Function
      - Version

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

@ack-prow
Copy link

ack-prow bot commented Oct 4, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ack-prow ack-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 4, 2023
@ack-prow ack-prow bot requested review from jljaco and vijtrip2 October 4, 2023 21:20
@Vandita2020 Vandita2020 marked this pull request as ready for review October 4, 2023 21:26
@ack-prow ack-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 4, 2023
@ack-prow ack-prow bot requested a review from a-hilaly October 4, 2023 21:27
@Vandita2020
Copy link
Member Author

/test apigatewayv2-controller-test

@@ -98,16 +100,18 @@ func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *OperationMap {
//
// see: https://github.com/aws-controllers-k8s/community/issues/1555
for opID, opCfg := range cfg.Operations {
if opCfg.ResourceName == "" {
if opCfg.ResourceName == nil {
Copy link
Member

Choose a reason for hiding this comment

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

opCfg.Resource is of type string, you can't compare to a nil pointer

@a-hilaly
Copy link
Member

/retest

Co-authored-by: Vandita Patidar <[email protected]>
Signed-off-by: Amine Hilaly <[email protected]>
Copy link

ack-prow bot commented Jan 16, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Vandita2020
Once this PR has been reviewed and has the lgtm label, please assign jlbutler for approval by writing /assign @jlbutler in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

Comment on lines +371 to +376
// The existance of the operation in the config file is not enough to
// override the operation type and/or resource name. The operation type
// and/or resource name must be specified in the config file.
if !exists || len(opConfig.ResourceName) == 0 || len(opConfig.OperationType) == 0 {
return []OpType{opType}, []string{resName}
}
Copy link
Member

Choose a reason for hiding this comment

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

@Vandita2020 You approach is correct, we only missed this last bits of code ^. When a user provides an Operation configuration without ResourceName nor OperationType directives - this block doesn't get called. Causing the opTypes list to reset (L378)

@a-hilaly
Copy link
Member

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow ResourceName to be a list such that one API can map to multiple resources
2 participants