-
Notifications
You must be signed in to change notification settings - Fork 399
Implement AWS SES Template #755
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
Signed-off-by: Karl Dasan <[email protected]>
Signed-off-by: Karl Dasan <[email protected]>
Signed-off-by: Karl Dasan <[email protected]>
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.
Nice work! I'm not a maintainer and I haven't used code gen, but I think I found two small issues you should look at, hope this helps.
examples/ses/template.yaml
Outdated
| name: example | ||
| spec: | ||
| forProvider: | ||
| region: us-east-2 |
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.
indent this section under forProvider, and check that it works
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.
Indented the section under forProvider .
Checked for Create, Update and Delete operations - Works successfully.
pkg/controller/ses/template/setup.go
Outdated
|
|
||
| func preObserve(_ context.Context, cr *svcapitypes.Template, obj *svcsdk.GetTemplateInput) error { | ||
| obj.TemplateName = aws.String(meta.GetExternalName(cr)) | ||
| cr.Spec.ForProvider.Template.TemplateName = obj.TemplateName |
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 think you should add this field to ignore in code gen. Look at lambda for example, the field FunctionName is ignored, so it's only part of external-name and not from the cr.
https://github.com/crossplane/provider-aws/blob/36e425acdcb52a670f78ab5e37b8f81864d3f393/pkg/controller/lambda/function/setup.go#L87-L90
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.
The CreateTemplateInput struct contains a *Template which contains the TemplateName.
Do you suggest adding TemplateName to ignore field_paths like this?
ignore:
field_paths:
- CreateTemplateInput.Template.TemplateName
I tried adding the same. The resultant code generated after re running make generate does not have the Template Parameters in the ForProvider i.e the CRD does not accept the Template_SDK struct that contains HTMLPart, SubjectPart, TemplateName, TextPart
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 think there is a need to update the code-generator, it does not support three levels like Foo.Bar.Baz.
I made a (draft) PR here: aws-controllers-k8s/code-generator#119
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.
@muvaf points out that this can be achieved already using
ignore:
field_paths:
- Template.TemplateNameAgain I would like to point out that I'm not 100% sure this is the correct approach as I've not used code gen. :)
examples/ses/template.yaml
Outdated
| subjectPart: "sample subject part" | ||
| textPart: "sample text part" | ||
| providerConfigRef: | ||
| name: example 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.
nitpick: if all other files have a final newline, it would be nice to add it to this file and generator-config.yaml too.
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.
Added newline to the example.
Signed-off-by: Karl Dasan <[email protected]>
Signed-off-by: Karl Dasan <[email protected]>
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.
Works well to create, delete.
Update works for changes to SubjectPart, TextPart, and HtmlPart.
I've included some thoughts on how to handle an update to TemplateName.
| apiVersion: ses.aws.crossplane.io/v1alpha1 | ||
| kind: Template | ||
| metadata: | ||
| name: example |
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.
Tiny nitpick:
Our other examples are using 2-space indents. Can we reformat this to match?
| } | ||
|
|
||
| func isUpToDate(cr *svcapitypes.Template, obj *svcsdk.GetTemplateOutput) (bool, error) { | ||
| if !cmp.Equal(cr.Spec.ForProvider.Template.TemplateName, obj.Template.TemplateName) { |
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.
Since we cannot update the templateName once the Template is created, we may want to...
- Ignore
Template.TemplateNamein code generation and use PreObserve, PreCreate, PreUpdate, and PreDelete to always set it tocr.Name. - Return an informative error (eg, "Cannot update field TemplateName, ignoring.") and return
true - Delete the Template and allow re-create with the new name.
| forProvider: | ||
| region: us-east-2 | ||
| template: | ||
| templateName: example |
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 tested updating spec.forProvider.template.templateName on an existing Template resource and received the following error:
2021-07-23T15:24:19.702-0400 DEBUG provider-aws Cannot update external resource {"controller": "managed/template.ses.aws.crossplane.io", "request": "/example", "uid": "b15f8ce9-c765-4543-bf1c-435caaaa8bc6", "version": "50082", "external-name": "example"}
2021-07-23T15:24:19.702-0400 DEBUG controller-runtime.manager.events Warning {"object": {"kind":"Template","name":"example","uid":"b15f8ce9-c765-4543-bf1c-435caaaa8bc6","apiVersion":"ses.aws.crossplane.io/v1alpha1","resourceVersion":"50082"}, "reason": "CannotUpdateExternalResource", "message": "cannot update Template in AWS: TemplateDoesNotExist: Template example2 does not exist."}
|
@ikarldasan are you still working on this PR? |
|
@ikarldasan any chance to see this finalized ? |
|
Closing as this was implemented in #791. Feel free to reopen if that is not the case. |
Description of your changes
"Fixes a part of #414 "
I have:
make reviewable testto ensure this PR is ready for review.How has this code been tested
Manually tested the creation, updation and deletion of Template