-
Notifications
You must be signed in to change notification settings - Fork 226
Add additional keys as identifiers #62
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
Add additional keys as identifiers #62
Conversation
|
||
ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" | ||
acktypes "github.com/aws-controllers-k8s/runtime/pkg/types" | ||
{{- if $idField := .CRD.SpecIdentifierField }} |
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.
you can remove this now that #61 is merged.
if ok { | ||
// Set the corresponding field with the value from the mapping | ||
specRef.FieldByName(specType.Field(i).Name).Set(reflect.ValueOf(val)) | ||
} |
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.
what if the jsonTag isn't found in the identifier.AdditionalKeys
? should we error out?
// Iterate over spec fields and associate corresponding json tags | ||
for i := 0; i < specRef.NumField(); i++ { | ||
// Get only the first field in the json tag (the field name) | ||
jsonTag := strings.Split(specType.Field(i).Tag.Get("json"), ",")[0] |
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.
I'm OK with using the reflect
package (even though it's incredibly ugly to work with, IMHO) here.
In the future, we may want to take an approach similar to how we handle TerminalConditions and simply generate a switch
case lookup here...
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 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 |
@RedbackThomson is gonna rework this PR, sometime next week /hold |
Issue #, if available: aws-controllers-k8s/community#766 Some resources require more than an ARN/Name/ID to describe a single resource. This PR adds an `additionalKeys` field to the `AWSIdentifiers` to allow for arbitrary identifiers as needed by any resources. Generator code to support this change: aws-controllers-k8s/code-generator#62
Issue #, if available: aws-controllers-k8s/community#766
Description of changes:
When setting identifiers on a given resource, dynamically add all additional keys according to their json tag names.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.