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

Functionality to provide hexadecimal hash of the object inside google cloud bucket #3888

Open
sourabhxyz opened this issue Jun 20, 2019 · 3 comments

Comments

@sourabhxyz
Copy link
Contributor

sourabhxyz commented Jun 20, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Google cloud has a facility to give md5 hash in hexadecimal format as well by using -h flag in gsutil, see here. But this provider only provides the md5 hash (see here)which is obtained by converting this hexadecimal hash to binary and then doing base 64 encoding to it which is unusual. It would be helpful if this provider could simply leverage this built in feature provided by GCP.

New or Affected Resource(s)

  • google_storage_bucket_object

Potential Terraform Configuration

output "uploaded_gcp_md5_hash_matched" {
  value = "${google_storage_bucket_object.gcp_controller_dir.md5hexhash == var.gcp_controller_md5 ? "Yes" : "No, please re-run the script as md5 hash didn't match"}"
}
@ghost ghost added the enhancement label Jun 20, 2019
@paddycarver paddycarver added this to the Backlog milestone Dec 10, 2019
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Aug 26, 2020
Co-authored-by: Edward Sun <[email protected]>
Signed-off-by: Modular Magician <[email protected]>
modular-magician added a commit that referenced this issue Aug 26, 2020
Co-authored-by: Edward Sun <[email protected]>
Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: Edward Sun <[email protected]>
@mitj04
Copy link

mitj04 commented Dec 15, 2022

b/262698141

@mitj04
Copy link

mitj04 commented Dec 15, 2022

  • Resource Name - google_storage_bucket_object

  • API Docs -

  • Notes -

    • The base64 md5 hash for the object that is computed by the server is represented by the field md5Hash in the resource representation. However, there isn't a field that can provide the md5 hash in hexadecimal form.
    • The probable fix would be to add a new output-only field called md5HexHash. Its value can be obtained from the md5Hash by converting base64 to hex.
  • Possible conversion from base64 to hex for md5Hash:

// decode first
p, err := base64.StdEncoding.DecodeString(response["md5Hash"])
if err != nil {
    // handle error
}
// encode
hmd5HexHash:= hex.EncodeToString(p)
fmt.Println(md5HexHash) // prints md5HexHash

@rileykarson
Copy link
Collaborator

Note: If there's a builtin Terraform function we should close this based on that rather than implement it directly in the resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants