Generate CRD for postgresteam resource #3004
Draft
+238
−71
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 introduces CRD (yaml) generation based on the Go structs by using
controler-genIt's only done for the Postgresteam type for now, with the intention to add more, the problem with the existing CRD manifests is that they have been managed "manually" so to get the generation correct/similar takes a bit of iteration.
Main value of this is that changes to the CRD only have to happen in one place (go) and then the CRD with schema is automatically updated.
The
NamespacedNametype was explicitly copied and adjusted from upstream because it gave the following error:It was anyway defined as a local type so the interface doesn't change.
There are some changes to the go structs to make it possible to generate a proper CRD:
Users,Teams,SuperUserTeamswhich are all just[]stringunder the hood. This is needed to be able to have map value level descriptions (and future validation). This also requires some type conversion dance inpkg/teams/postgres_team.gobut most of the interface is left the same.nullable: trueat the map value level like it's set today in the CRD. I would also argue the API is clearer if you can't set a null value instead of an array. Will check compatibility with existing resources.TODO
This was validated by running the script:
check_pgteam.sh
Against all clusters: