-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support for conditionally enabling of alpha-level CRDs #462
Conversation
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Issues linked to changelog: |
Most changes here to support rendering of codegen/templates/manifests/crd.yamltmpl. A couple of small questions (maybe) to resolve: https://github.com/solo-io/skv2/pull/462/files#diff-0edd4bd3f13b4db965a1337273d05e142d5c93e63559722098c88c9873458997R148 |
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
…hered groups Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[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.
Looks really good, a few small nits but this is exactly what we needed. Nice work.
[[- if and (and (gt (len $crd.Spec.Versions) 1) (string_contains $version.Name "alpha")) (should_not_skip $crd.Spec.Group $version.Name $.ShouldSkip) ]] | ||
{{- end }} | ||
[[- end ]] | ||
[[- end ]] | ||
[[- if and (and (lt (len $crd.Spec.Versions) 2) (string_contains (index $crd.Spec.Versions 0).Name "alpha")) (should_not_skip $crd.Spec.Group (index $crd.Spec.Versions 0).Name $.ShouldSkip) ]] |
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.
Are these just to make sure new-lines are created when needed?
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.
Not sure what exactly you are referring to. If it's the conditional on the line above, it's to conditionally render {{- end }}
that corresponds to the conditional here: https://github.com/solo-io/skv2/pull/462/files/acf693e11fd37032d1e9813a85d5e6888a1c0a4d#diff-033b9d4512e2683aff9f19928ec94eaaa06e46cbfcede987461da2079459436dR3
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
codegen/cmd.go
Outdated
} | ||
|
||
manifests, err := render.RenderManifests(c.AppName, c.ManifestRoot, c.ProtoDir, protoOpts, groupOptions, grp) | ||
manifests, err := render.RenderManifests(c.AppName, c.ManifestRoot, c.ProtoDir, protoOpts, groupOptions, grps) |
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.
we sohuld just move RenderManifests out rather than changing the whole function signature for this one line
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.
Not exactly sure what you mean. RenderManifests needs all groups now, as it combines multiple versions of the same group into one manifest (and multiple versions of the same resource into a single crd).
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.
Overall LGTM, couple questions and nits.
resource, | ||
group.OpenApiSchemas, | ||
) | ||
groups []*model.Group, |
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.
Implementation looks fine to me, but this function is getting a little complex, we might want to break into a couple smaller simpler funcs?
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.
cleaned it up a little bit.
if err != nil { | ||
return OutFile{}, err | ||
} | ||
return files[0], nil |
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.
Files always len 1? Should we check?
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.
we only give defaultManifestRenderer.renderCoreTemplates
one template to render; if there's an error it will return before this line. So, yes, if it got here, there is one item in []OutFile. I'll add a comment.
labels: | ||
app: "" | ||
app.kubernetes.io/name: "" | ||
name: paints.things.test.io | ||
name: clusterresources.things.test.io |
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.
Did these changes result in the ordering of CRDs change?
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.
Yes. There are a few interim maps: for grouping of groups, which also affected ordering of versions in CRDs. To make those stable, I added sorting in both places:
renderer.left = "[[" | ||
renderer.right = "]]" |
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.
To confirm, this is because the template we are rendering will itself contain template syntax? (i.e. codegen/templates/manifests/crd.yamltmpl
)?
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.
yep. [[
and ]]
are for the template code that executes during code-generation pass, while {{
and }}
for when template is rendered by helm. We do the same in chart_renderer (which is where I got the idea): https://github.com/solo-io/skv2/blob/master/codegen/render/chart_renderer.go#L47
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
…bled alpha API Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
If CRD doesn't contain any alpha version of resources, produced CRD templates are almost identical to CRD manifests in crds/ directory.
A given alpha-version CRD can be enabled by adding its GVK to
experimental.api
helm chart variable.If there's a single alpha version resource in a CRD, the whole thing is rendered conditionally:
If a CRD contains multiple versions and one of them is alpha, then only that version can be rendered conditionally:
This partially resolves https://github.com/solo-io/gloo-mesh-enterprise/issues/9019
BOT NOTES:
resolves https://github.com/solo-io/gloo-mesh-enterprise/issues/9019