-
Notifications
You must be signed in to change notification settings - Fork 4
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
Implemented specialized conversion for helm_release
resources.
#198
Conversation
There is a useful collection of aws-specific helm terraform projects that might be useful for testing. |
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 would advocate for a different approach that would encapsulate the translation logic into the resource provider. Imagine that the converter used an alternative Args class and that the Helm resource constructor were polymorphic. The Check method could normalize the args at will.
This code looks fine though.
pkg/convert/tf.go
Outdated
blockPath = appendPathArray(blockPath) | ||
} | ||
|
||
if block.Type == "dynamic" { |
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.
This all seems like generic parsing logic, is it really resource-specific?
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.
This is not resource specific, dynamic
blocks are used to create list comprehensions for resource fields. That said, for this resource, I don't see this being used for the available fields. I can simplify and remove this logic from here.
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.
This approach strikes me as quite undesirable, it is simply too specialized.
I would advocate for a different design, where the converter produce a generic "TF args" to convey the inputs (without transformation) to the resource. The Check
operation could then handle conversion from TF input to checked state.
Description
This PR implements custom conversion handling for
helm_release
resources and maps them to resources of typekubernetes:helm.sh/v3:Release
.Addresses #58
Fixes pulumi/pulumi-kubernetes#2744 because the type mapping is also handled for state conversions.
Implemented using a specialized version of
convertBody
calledconvertHelmReleaseResource
which handles converting the supported fields, their required renames, nesting and rewrites (see examples below or full example added to the tests)It doesn't handle the
helm
provider blocks, haven't looked into these for this implementation, only thehelm_release
itself.Basic example
becomes:
Example with repository options
Repository options in the tf schema are top-level fields but in pulumi-kubernetes, these are subfields of an options object
repositoryOpts
:becomes:
Example with custom chart values
In tf, the
helm_release
resources uses blocksset_value
,set_list
andset_sensitive
that have attributesname
andvalue
. With this implementation, these blocks are converted to a singlevalues
map as follows:becomes:
TODOs for other fields:
The block
postrender { binaryPath = "bin", args = ["args"] }
and fieldvalues = ["key:value"]
are not converted yet. I need to think a bit more about these two becausepostrender
block should be combined into a single stringpostrender = "bin arg"
the
values
field need to map tovalueYamlFiles
where each element of the list should be wrapped instringAsset
: