fix issues with Get/SetAttributes Go code generation #312
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch adds to the code generator for the SDK linkage for APIs that
use the SetAttributes-flavor of updating a resource. Previously, the
sdk.go
files for these APIs had emptysdkUpdate
operations with abig TODO that ended up breaking the service controller (quite
predictably).
While implementing this patch, I stumbled upon yet another unexplainable
inconsistency between two SetAttributes operations within the SNS
service API. The SNS
SetPlatformApplicationAttributes
API call accepts afield in its Input shape called
Attributes
that is a map of key/valuepairs for attributes to set on the platform application. Unfortunately,
the similarly-named SNS
SetTopicAttributes
API call apparently doesNOT work the same way. Instead, there is a single
AttributeName
andAttributeValue
field in the Input shape and you need to call theSetTopicAttributes
API call once for each modified attribute. :(In fact, the [official documentation][0] for the SNS SetTopicAttributes
API call says that the
AttributeName
field in the Input shape isactually a "map of attributes with their corresponding values". But
that isn't actually the case...
So, the code in this patch for now just contains a TODO in the
CRD.GoCodeSetAttributesSetInput()
method for SetAttributes APIs thatcan only operate on a single attribute at a time. We will use the
CustomOperation functionality as a temporary workaround for these APIs
while we come up with a more permanent code-generated solution.
There were a series of problems that I uncovered when investigating the
cause of Issue #296:
Status.ACKResourceMetadata.ARN
andStatus.ACKResourceMetadata.OwnerAccountID
when the attribute fieldscorresponded to the primary resource ARN or the owner ID. This was the
direct cause of Issue sns: GENERATION FAILURE! there's a required field PlatformApplicationArn in Shape GetPlatformApplicationAttributesInput that isn't in either the CR's Spec or Status structs #296
templates/pkg/crd_sdk.go.tpl
that ran at the end of thesdkCreate()
call was inadvertently overwriting any setters ofStatus.ACKResourceMetadata
that had previously executedreturning a nil-guard and constructor for the ACKResourceMetadata
struct, even when no attribute fields actually set either ARN or
OwnerAccountID. When I removed the check in the template for Status
fields being required for the
resp
variable to be defined, this wascausing
"resp" variable unused
compilation failuresIssue #296
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.