Skip to content
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

Do not prefix JSON fieldpaths starting with status.atProvider in resource.GetSensitiveParameters #417

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/resource/sensitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,25 @@ func GetSensitiveParameters(ctx context.Context, client SecretClient, from runti
return err
}
pavedTF := fieldpath.Pave(into)
prefixes := []string{"spec.initProvider.", "spec.forProvider."}

for tfPath, jsonPath := range mapping {
jp := jsonPath
groups := reFieldPathSpec.FindStringSubmatch(jsonPath)
if len(groups) == 3 {
jp = groups[2]
} else if strings.HasPrefix(jsonPath, "status.atProvider.") {
// we will not be prefixing the JSON fieldpath expression if it starts
// with "status.atProvider" in case there is a spec.forProvider.status
// field. If there exists a spec.forProvider.status field, then the
// fieldpath.ExpandWildcards will complain instead of expanding the
// fieldpath expression as an empty slice.
prefixes = []string{""}
}

// spec.forProvider secret references override the spec.initProvider
// references.
for _, p := range []string{"spec.initProvider.", "spec.forProvider."} {
for _, p := range prefixes {
if err := storeSensitiveData(ctx, client, tfPath, p+jp, pavedTF, pavedJSON, mapping); err != nil {
return err
}
Expand Down
Loading