Skip to content

rough controller generation for cp #1

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

Draft
wants to merge 5 commits into
base: crossplane
Choose a base branch
from

Conversation

muvaf
Copy link

@muvaf muvaf commented Oct 20, 2020

Signed-off-by: Muvaffak Onus [email protected]

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

jaypipes and others added 4 commits October 7, 2020 13:22
DO NOT MERGE

Adds a new `ack-generate crossplane` CLI command, set of templates and
generated crossplane API types.
Signed-off-by: Muvaffak Onus <[email protected]>
if found {
sourceAdaptedVarName += ".Spec"
sourceAdaptedVarName += ".Spec.ForProvider"
Copy link
Author

Choose a reason for hiding this comment

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

In Crossplane, we always keep cloud provider related things under either spec.forProvider and status.atProvider. So, it'd be awesome if we can configure the this string.

cr.SetConditions(runtimev1alpha1.Available())
{{- if .CRD.Ops.ReadMany }}
input := Generate{{ .CRD.Ops.ReadMany.InputRef.Shape.ShapeName }}(cr)
// TODO(muvaf): Generated conversion code has logic about the input, like if(len...)
Copy link
Author

Choose a reason for hiding this comment

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

Here is what it looks like. The code won't compile because the first return value is not a pointer and we're not able to configure that.

}
observed, err := rm.sdkFind(ctx, r)
cfg, err := awsclient.GetConfig(ctx, c.kube, mg, cr.Spec.ForProvider.Region)
Copy link
Author

Choose a reason for hiding this comment

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

In AWS Provider, we actually treat region as one of the spec fields and it doesn't really appear in any *Input queries but in *aws.config object. It'd be great to have support for additional fields in the generation code. Another option could be a CustomFields struct that's inlined and filled in custom.go file that's manually written.

// and has a return statement we can't control here in an arbitrary function.
// TODO(muvaf): Generated code has an assumption about the module name of the type (svcapitypes)
// but that doesn't always hold true.
{{ $setCode := GoCodeSetReadManyOutput .CRD "resp" "cr" 1 }}
Copy link
Author

Choose a reason for hiding this comment

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

ACKResourceMetadata field is not generated for Crossplane but we can certainly add something similar to show that all status fields have ARN embedded, which should already be the case for most of the AWS resources.

Signed-off-by: Muvaffak Onus <[email protected]>
jaypipes pushed a commit that referenced this pull request Nov 12, 2020
@jaypipes jaypipes force-pushed the crossplane branch 2 times, most recently from f74d52f to b5aab6a Compare December 18, 2020 17:11
@jaypipes jaypipes force-pushed the crossplane branch 2 times, most recently from b1d4fe8 to d4015d0 Compare January 8, 2021 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants