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
keymanager v1: fix payload retrieve for binary data #1505
keymanager v1: fix payload retrieve for binary data #1505
Conversation
That's wired. My local tests:
differ from CI tests:
with extra debug added: func resourceSecretV1PayloadBase64CustomizeDiff(diff *schema.ResourceDiff) error {
encoding := diff.Get("payload_content_encoding").(string)
if diff.Id() != "" && diff.HasChange("payload") && encoding == "base64" {
o, n := diff.GetChange("payload")
oldPayload := o.(string)
newPayload := n.(string)
v, err := base64.StdEncoding.DecodeString(newPayload)
if err != nil {
return fmt.Errorf("The Payload is not in the defined base64 format: %s", err)
}
newPayloadDecoded := string(v)
log.Printf("[DEBUG] checking payload: %q vs %q decoded(%q)", oldPayload, newPayload, newPayloadDecoded)
if oldPayload == newPayloadDecoded {
log.Printf("[DEBUG] payload has not changed. clearing diff")
return diff.Clear("payload")
}
}
return nil
} |
I decided to store binary data in base64 to avoid these issues. |
@ozerovandrei @nikParasyr please review |
This works! Thanks a million for fixing this so quickly. LGTM |
398714f
to
6afb29d
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.
LGTM. is it ready from your side @kayrus? Cause i saw some conversation going on on the related issue
yes, it's ready. |
Fixes #1492
Now payload state is stored in base64 format in case when it's not the text. In these cases it's responsibility of end user to detect the encoding/content-type and call https://developer.hashicorp.com/terraform/language/functions/base64decode
Payloads with whitespaces and newlines are also supported now, e.g. passwords that have whitespace at the end.