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 sha256sum template function #90

Merged
merged 1 commit into from
Jan 22, 2024
Merged

Conversation

tianon
Copy link
Member

@tianon tianon commented Jan 20, 2024

This is intentionally named and implemented to match the one in Sprig: https://masterminds.github.io/sprig/crypto.html

I need this so that docker-library/meta-scripts#16 can calculate sourceIds in pure bashbrew formatting (and thus be really fast): 😅

...
	{{- $sum := $.ArchGitChecksum $a . -}}
	{{- $file := .ArchFile $a -}}
	{{- $builder := .ArchBuilder $a -}}
	{
		"sourceId": {{ join "\n" $sum $file $builder "" | sha256sum | json }},
		"reproducibleGitChecksum": {{ $sum | json }},
...

This is intentionally named and implemented to match the one in Sprig: https://masterminds.github.io/sprig/crypto.html
@@ -135,4 +137,10 @@ var FuncMap = template.FuncMap{
return unsetVal
}
}),

// {{- sha256sum "hello world" -}}
"sha256sum": func(input string) string {
Copy link
Member

Choose a reason for hiding this comment

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

A test for this?

@codecov-commenter
Copy link

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (0b38175) 75.21% compared to head (1a4c6e8) 74.89%.

Files Patch % Lines
pkg/templatelib/lib.go 0.00% 4 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #90      +/-   ##
==========================================
- Coverage   75.21%   74.89%   -0.33%     
==========================================
  Files           8        8              
  Lines         920      924       +4     
==========================================
  Hits          692      692              
- Misses        173      177       +4     
  Partials       55       55              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tianon tianon merged commit bc4c23b into docker-library:master Jan 22, 2024
6 checks passed
@tianon tianon deleted the sha256sum branch January 22, 2024 17:43
@tianon
Copy link
Member Author

tianon commented Jan 22, 2024

Gah, forgot to refresh.

Edit: #91

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

Successfully merging this pull request may close these issues.

3 participants