-
Notifications
You must be signed in to change notification settings - Fork 38
Conversation
5ac7d61
to
a45e5b4
Compare
c1d43db
to
8163825
Compare
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
aaf9a7f
to
9e116bb
Compare
Signed-off-by: Hasan Turken <[email protected]>
9e116bb
to
ea668c0
Compare
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
4f2b6f6
to
6be7f62
Compare
Signed-off-by: Hasan Turken <[email protected]>
a21b87b
to
e920c43
Compare
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.
Awesome to see the whole sensitive information issue including user input getting resolved!
return nil | ||
} | ||
|
||
func expandedTFPath(expandedXP string, mapping map[string]string) (string, error) { |
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.
If I understood correctly, this function takes an expanded JSON path and returns a TF path that you can use to set a value on a TF file. I wonder if we can get away with some string manipulation here to replace the field names. Do you think something like this worth 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.
Thanks for the suggestion and for preparing the code snippet.
I'll try if I can simplify following an approach you suggested, however, one caveat here is, fieldpath.Paved does not print keys of maps inside [ ]
if the key contains dots. See this as an example. So, initially, I attempted some regex replace kind of solution but I ended up parsing them using the same parsing not to miss something or build a complex method to handle edge cases like I mentioned.
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 had another look. Actual complexity came from identifying expandedJSON is for which wildcarded fieldpath due to the inconsistent printing behaviour I mentioned above (see possible values for expandedJSON), which is currently handled by expandedFor
function.
I think it wouldn't worth to use replacer solution given we already have to parse fieldpath to segments.
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.
Hmm I didn't think of the case where there is a string as index actually. We'd have to make it not consider strings between [
and ]
during replace, which could be more complex as you said. Thanks for testing it!
pkg/types/builder.go
Outdated
fieldNameCamel := fieldName.Camel | ||
if e, ix := containsAt(cfg.Sensitive.CustomFieldPaths, tfFieldPath); e || sch.Sensitive { | ||
if e { | ||
cfg.Sensitive.CustomFieldPaths = remove(cfg.Sensitive.CustomFieldPaths, ix) |
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.
Would it make sense to use map[string]string
instead of []string
as type of CustomFieldPaths
, then merge it into fieldPaths
directly? It could be easier to work with if there was a single map that we need to use here. I didn't try to see whether it works, just an idea you might want to consider.
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 was something I considered but I didn't like that users would need to provide a map in that case and the value part of the map (xp/json path) is even unknown before the code generation. We could expect them to set some placeholder (or empty?) values but that sounded hacky.
But anyway, as we discussed today, I will need to revisit getting custom configuration since we would need the distinction of include into connection details but not sensitive
type of fields.
Signed-off-by: Hasan Turken <[email protected]>
Thanks for the review @muvaf! Resolved/responded to all your comments. The two open items I need to add to PR is:
|
// Data will be stored in connection details secret | ||
continue | ||
} | ||
sfx := "SecretRef" |
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.
nit:
Just for consideration: If the field name already ends with secret
, we will have something like xyzSecretSecretRef
.
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.
Yeah, but not sure xyzSecretRef
would be better in such a case or are there any better alternative
Signed-off-by: Hasan Turken <[email protected]>
3316591
to
6ada1c3
Compare
Signed-off-by: Hasan Turken <[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.
LGTM! Thanks @turkenh !
pkg/resource/sensitive.go
Outdated
return err | ||
} | ||
xpParams := map[string]interface{}{} | ||
if err = pv.GetValueInto("spec.forProvider", &xpParams); err != 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.
Right now it looks like the following:
map[string]string{"master_password": "masterPasswordSecretRef"}
In TFState, master_password
is at the top level in HCL of the resource definition, whereas spec.forProvider.masterPasswordSecretRef
would have been the fully qualified path for the Crossplane definition. Both work but the latter is correct in the sense that it's ready to be used in all possible contexts whereas if we have only masterPasswordSecretRef
, we'd need to know the prefix that's needed to use to actually access the data.
return nil | ||
} | ||
|
||
func expandedTFPath(expandedXP string, mapping map[string]string) (string, error) { |
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.
Hmm I didn't think of the case where there is a string as index actually. We'd have to make it not consider strings between [
and ]
during replace, which could be more complex as you said. Thanks for testing it!
Signed-off-by: Hasan Turken <[email protected]>
Signed-off-by: Hasan Turken <[email protected]>
Description of your changes
This PR resolves handling sensitive fields in resource definition by generating appropriate schema (i.e. a
secretRef
for sensitive inputs and dropping fields from status), building connection details secret content, and constructing terraform attributes by gathering data from input/connection secrets.Task list:
Fixes #35
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
Tested with the following provider-tf-aws PR: crossplane-contrib/provider-jet-aws#24