-
Notifications
You must be signed in to change notification settings - Fork 90
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 config.Resource.RemoveSingletonListConversion #411
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ulucinar
requested review from
sergenyalcin,
erhancagirici and
mergenci
as code owners
May 30, 2024 07:43
9 tasks
already configured singleton list conversions. - The main use case is to prevent singleton list conversions for configuration arguments with single nested blocks. Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
ulucinar
force-pushed
the
fix-embedded-conversion
branch
from
May 30, 2024 07:54
fc6948e
to
72ab08c
Compare
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
…as of all the resources of a Provider. Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
ulucinar
force-pushed
the
fix-embedded-conversion
branch
from
May 30, 2024 15:35
572cadd
to
5318cd9
Compare
constraints between the JSON & Go schemas. - We've observed that some MaxItems constraints in the JSON schemas are not set where the corresponding MaxItems constraints in the Go schemas are set to 1. - This inconsistency results in some singleton lists not being properly converted in the MR API. - This traverser can mitigate such inconsistencies. Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
ulucinar
force-pushed
the
fix-embedded-conversion
branch
from
May 31, 2024 07:29
ad820b3
to
f4f87ba
Compare
This was referenced Jun 4, 2024
sergenyalcin
approved these changes
Jun 6, 2024
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.
Thanks @ulucinar LGTM!
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
ulucinar
force-pushed
the
fix-embedded-conversion
branch
from
June 12, 2024 12:36
3aeb964
to
361331e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of your changes
For Terraform resources with single nested configuration blocks, we had previously introduced the
config.Resource.SetEmbeddedObject
that configures the field at a specified path as an embedded object rather than a singleton list. Such resources (an example isSecurityConfig.opensearchserverless
'ssamlOptions
field incrossplane-contrrib/provider-upjet-aws
) already embedded nested blocks as objects despite their schemas are declared as singleton lists. Unfortunatelly, this nesting information is not immediately available in the JSON schema and this is also the reason we haveResource.SetEmbeddedObject
in the very first place.For such fields, we need to prevent the singleton list to embedded object conversion at the Crossplane level because that singleton list must have already been generated as an embedded object. This is because Terraform also expects a single nested block as opposed to a list for such configuration arguments.
Currently, the schema traverser responsible for converting singleton lists to embedded objects treats them as regular singleton lists as what it processes is the JSON schema and we don't have the nested block information in that schema. This PR adds
config.Resource.RemoveSingletonListConversion
so that it becomes possible to override the decisions made by the singleton list conversion schema traverser.An example usage is as follows:
This effectively prevents a new API version for the
SecurityConfig.opensearchserverless
, which would be identical (apart from the version number) to the current version and the invalid API converters installed between these two identical versions.This PR also introduces
traverser.TFResourceSchema.Traverse
, which can be used to traverse the Terraform schemas of all the resources of aconfig.Provider
. Another traverser,traverser.maxItemsSync
can be used to sync theMaxItems
constraints from a source schema to a target schema. An example usage is as follows:In this example, we would like to sync the
MaxItems
constraints from the Go schemas represented withsdkProvider.ResourcesMap
into the JSON schemas represented withp.ResourcesMap
. For more details, please refer to crossplane-contrib/provider-upjet-gcp#537.I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
Has been validated in the context of crossplane-contrib/provider-upjet-aws#1332.