Skip to content

Support Table tags updates #22

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
Dec 22, 2021
Merged

Conversation

a-hilaly
Copy link
Member

Issue: aws-controllers-k8s/community#1029

This patch adds hooks and delta helpers to properly update Table tags.

Description of changes:

  • Drop the generate updateTable function and use a custom one
  • Add hooks to properly compute the tags delta and make necessary API
    calls to update them
  • Add e2e tests for table tag updates

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

Issue: aws-controllers-k8s/community#1029

This patch adds hooks and delta helpers to properly update Table tags.

Description of changes:
- Drop the generate updateTable function and use a custom one
- Add hooks to properly compute the tags delta and make necessary API
calls to update them
- Add e2e tests for table tag updates
@a-hilaly
Copy link
Member Author

Note that the existing generated updateTable method was not properly working - I will add update support for each field in separate PRs

@a-hilaly a-hilaly removed the request for review from jaypipes December 22, 2021 19:43
@vijtrip2
Copy link
Contributor

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 22, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented Dec 22, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, vijtrip2

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-bot ack-bot merged commit 098f153 into aws-controllers-k8s:main Dec 22, 2021
Tags: sdkTagsFromResourceTags(added),
},
)
rm.metrics.RecordAPICall("GET", "UntagResource", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be UPDATE not GET

Copy link
Collaborator

Choose a reason for hiding this comment

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

also, the operation ID should be "TagResource" not "UntagResource"

TagKeys: removed,
},
)
rm.metrics.RecordAPICall("GET", "UntagResource", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be UPDATE not GET

Comment on lines +297 to +326
func (rm *resourceManager) getResourceTagsPagesWithContext(ctx context.Context, resourceARN string) ([]*v1alpha1.Tag, error) {
var err error
rlog := ackrtlog.FromContext(ctx)
exit := rlog.Trace("rm.getResourceTagsPagesWithContext")
defer exit(err)

tags := []*v1alpha1.Tag{}

var token *string = nil
for {
var listTagsOfResourceOutput *svcsdk.ListTagsOfResourceOutput
listTagsOfResourceOutput, err = rm.sdkapi.ListTagsOfResourceWithContext(
ctx,
&svcsdk.ListTagsOfResourceInput{
NextToken: token,
ResourceArn: &resourceARN,
},
)
rm.metrics.RecordAPICall("GET", "ListTagsOfResource", err)
if err != nil {
return nil, err
}
tags = append(tags, resourceTagsFromSDKTags(listTagsOfResourceOutput.Tags)...)
if listTagsOfResourceOutput.NextToken == nil {
break
}
token = listTagsOfResourceOutput.NextToken
}
return tags, nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

gotta love that ListTagsForResource has no ListTagsForResourcePages corresponding aws-sdk-go construct, like every other List operation does.... :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants