Skip to content

Conversation

RedbackThomson
Copy link
Contributor

@RedbackThomson RedbackThomson commented Jul 27, 2021

Adds custom hooks to detect changes to the Logging spec field and optionally calls the PutBucketLogging SDK 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

@ack-bot ack-bot requested review from jaypipes and vijtrip2 July 27, 2021 23:05
@RedbackThomson
Copy link
Contributor Author

/hold Please don't make me write out manual diffing methods for every one of the 24 Put* operations.

@ack-bot ack-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 27, 2021
Comment on lines 1 to 6
latest := &resource{ko}
synced, err := rm.syncPutFields(ctx, latest)
if err != nil {
return nil, err
}
ko = synced.ko No newline at end of file
Copy link
Contributor

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?

return nil, err
}

ko := r.ko.DeepCopy()
Copy link
Contributor

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.

Copy link
Contributor

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

input := &svcsdk.GetBucketLoggingInput{
Bucket: r.ko.Spec.Name,
}
latest, err := rm.sdkapi.GetBucketLoggingWithContext(ctx, input)
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

@jaypipes jaypipes left a 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...

Copy link
Contributor

@jaypipes jaypipes left a 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"`
Copy link
Contributor

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? :(

input := &svcsdk.GetBucketLoggingInput{
Bucket: r.ko.Spec.Name,
}
latest, err := rm.sdkapi.GetBucketLoggingWithContext(ctx, input)
Copy link
Contributor

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.

return nil, err
}

ko := r.ko.DeepCopy()
Copy link
Contributor

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

@RedbackThomson
Copy link
Contributor Author

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 Put* payload objects from spec. I have removed the diff method, as well, because I would instead prefer to update the fields of a resource type and then use the (already generated) diffResource code. However, that will be another pull request for supporting update operations.

@RedbackThomson RedbackThomson changed the title Include Logging as part of Create flow Include Logging as part of Create and Update flow Jul 30, 2021
@RedbackThomson
Copy link
Contributor Author

Oops, I added update as well because it wasn't that much extra code. Sorry :)

Copy link
Contributor

@jaypipes jaypipes left a 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.

@RedbackThomson
Copy link
Contributor Author

/hold

I think this is ready to go, but want to wait for aws-controllers-k8s/code-generator#140 before merging.

Copy link
Contributor

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

👍

@jaypipes
Copy link
Contributor

jaypipes commented Aug 2, 2021

/unhold
/lgtm

@ack-bot ack-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 2, 2021
@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 2, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented Aug 2, 2021

[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:
  • OWNERS [RedbackThomson,jaypipes]

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 a544e43 into aws-controllers-k8s:main Aug 2, 2021
@RedbackThomson RedbackThomson deleted the put-fields branch August 2, 2021 20:10
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