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

add output_sha256 attribute #74

Closed
wants to merge 1 commit into from

Conversation

bdchauvette
Copy link

Hello!

I'm using this provider to create some archives for AWS SSM Distributor. AWS requires each package to have a manifest with hex SHA256 sums. As far as I can tell, there's no simple way to convert the base64 sum to a hex sum using Terraform functions, which I think makes it a good candidate for being done on the provider level.

@bdchauvette bdchauvette force-pushed the output_sha256 branch 3 times, most recently from bd7c15e to a05a276 Compare June 26, 2020 18:16
@hashicorp-cla
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

Base automatically changed from master to main February 1, 2021 17:31
@stephengroat-dd
Copy link

stephengroat-dd commented Sep 13, 2021

thanks @bdchauvette for the great work!

is there any way this could be rebased and merged? I'm currently having issues with this blocking me as well

@jyidiego
Copy link

jyidiego commented Apr 20, 2022

When will this be merged? Blocking me as well on AWS SSM.

sha256base64 := base64.StdEncoding.EncodeToString(shaSum[:])

md5 := md5.New()
md5.Write([]byte(data))
md5Sum := hex.EncodeToString(md5.Sum(nil))

return sha1, sha256base64, md5Sum, nil
return sha1, sha256hex, sha256base64, md5Sum, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might I suggest adding all the missing hash algorithms, per hashicorp/terraform-provider-local#137

E.g.

func genFileShas(filename string) (sha1Hex, sha256Hex, sha256Base64, sha512Hex, sha512Base64, md5Hex string, err error) {
    data, err := ioutil.ReadFile(filename)
    if err != nil {
        err = fmt.Errorf("could not compute file '%s' checksum: %s", filename, err)
        return
    }

    sha1Sum := sha1.Sum(data)
    sha1Hex = hex.EncodeToString(sha1Sum[:])

    sha256Sum := sha256.Sum256(data)
    sha256Hex = hex.EncodeToString(sha256Sum[:])
    sha256Base64 = base64.StdEncoding.EncodeToString(sha256Sum[:])

    sha512Sum := sha512.Sum512(data)
    sha512Hex = hex.EncodeToString(sha512Sum[:])
    sha512Base64 = base64.StdEncoding.EncodeToString(sha512Sum[:])

    md5Sum := md5.Sum(data)
    md5Hex = hex.EncodeToString(md5Sum[:])

    return
}

Copy link
Contributor

@zachwhaley zachwhaley Sep 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to open a new PR for my suggested changes #165

Don't know how much more successful my PR will be than this one 😐

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually using this provider anymore so I'm happy to close this PR in favor of yours 👍

@bdchauvette
Copy link
Author

Closing in favor of #165

See #74 (comment)

@bdchauvette bdchauvette deleted the output_sha256 branch September 14, 2022 13:49
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants