-
Notifications
You must be signed in to change notification settings - Fork 85
Include Logging as part of Create and Update flow
#25
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
Conversation
|
/hold Please don't make me write out manual diffing methods for every one of the 24 |
| latest := &resource{ko} | ||
| synced, err := rm.syncPutFields(ctx, latest) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| ko = synced.ko No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the lines 2-6 have extra space in beginning?
pkg/resource/bucket/hook.go
Outdated
| return nil, err | ||
| } | ||
|
|
||
| ko := r.ko.DeepCopy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this DeepCopy needed? I noticed no changes being made in ko object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vijtrip2 Nick is simply copy/pasting from the normal sdk_update template... nothing really wrong with that... though techincally he should be doing if below the call to rm.sdkapi.PutBucketLogging
pkg/resource/bucket/hook.go
Outdated
| input := &svcsdk.GetBucketLoggingInput{ | ||
| Bucket: r.ko.Spec.Name, | ||
| } | ||
| latest, err := rm.sdkapi.GetBucketLoggingWithContext(ctx, input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest and desired here will be of different types, correct?
It would not cause trouble to compare their primitive fields but shouldn't they both be ko.Spec.Logging? Currently latest is type from aws-sdk-go and not ACK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. @RedbackThomson we typically use the variable name resp for the response object from the SDK call. Recommend using resp here.
jaypipes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RedbackThomson please rebase this to remove the unrelated 0.7.1 runtime update changes...
jaypipes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nick, I think you can use the delta_pre_compare hook point to simplify your code a bit and remove the need for (re-)creating delta objects.
| // all log object keys for a bucket. For more information, see PUT Bucket logging | ||
| // (https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTlogging.html) | ||
| // in the Amazon Simple Storage Service API Reference. | ||
| LoggingEnabled *LoggingEnabled `json:"loggingEnabled,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh. a field called "Enabled" that isn't a boolean and is a struct? :(
pkg/resource/bucket/hook.go
Outdated
| input := &svcsdk.GetBucketLoggingInput{ | ||
| Bucket: r.ko.Spec.Name, | ||
| } | ||
| latest, err := rm.sdkapi.GetBucketLoggingWithContext(ctx, input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. @RedbackThomson we typically use the variable name resp for the response object from the SDK call. Recommend using resp here.
pkg/resource/bucket/hook.go
Outdated
| return nil, err | ||
| } | ||
|
|
||
| ko := r.ko.DeepCopy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vijtrip2 Nick is simply copy/pasting from the normal sdk_update template... nothing really wrong with that... though techincally he should be doing if below the call to rm.sdkapi.PutBucketLogging
7c5e02e to
1574d14
Compare
|
Thank you @vijtrip2 and @jaypipes for your reviews. I have updated the code-generator to remove a lot of the heavy-lifting for this - namely creating the |
Logging as part of Create flowLogging as part of Create and Update flow
|
Oops, I added update as well because it wasn't that much extra code. Sorry :) |
jaypipes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking very good... couple teeny nits inline.
|
/hold I think this is ready to go, but want to wait for aws-controllers-k8s/code-generator#140 before merging. |
jaypipes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
/unhold |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jaypipes, RedbackThomson 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 |
Adds custom hooks to detect changes to the
Loggingspec field and optionally calls thePutBucketLoggingSDK method. Currently errors are not populated into terminal conditions, and updates are not supported.Uses aws-controllers-k8s/code-generator#139 and aws-controllers-k8s/code-generator#140