-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ArchGitChecksum
template command in bashbrew cat
This also finally adds `bashbrew context` as an explicit subcommand so that issues with this code are easier to test/debug (so we can generate the actual tarball and compare it to previous versions of it, versions generated by `git archive`, etc). As-is, this currently generates verbatim identical checksums to https://github.com/docker-library/meta-scripts/blob/0cde8de57dfe411ed5578feffe1b10f811e11dc2/sources.sh#L90-L96 (by design). We'll wait to do any cache bust there until we implement `Dockerfile`/context filtering: ```console $ bashbrew cat varnish:stable --format '{{ .TagEntry.GitCommit }} {{ .TagEntry.Directory }}' 0c295b528f28a98650fb2580eab6d34b30b165c4 stable/debian $ git -C "$BASHBREW_CACHE/git" archive 0c295b528f28a98650fb2580eab6d34b30b165c4:stable/debian/ | ./tar-scrubber | sha256sum 3aef5ac859b23d65dfe5e9f2a47750e9a32852222829cfba762a870c1473fad6 $ bashbrew cat --format '{{ .ArchGitChecksum arch .TagEntry }}' varnish:stable 3aef5ac859b23d65dfe5e9f2a47750e9a32852222829cfba762a870c1473fad6 ``` (Choosing `varnish:stable` there because it currently has [some 100% valid dangling symlinks](https://github.com/varnish/docker-varnish/tree/6b1c6ffedcfececac71e46a85122c1adaef25868/stable/debian/scripts) that tripped up my code beautifully 💕) From a performance perspective (which was the original reason for looking into / implementing this), running the `meta-scripts/sources.sh` script against `--all` vs this, my local system gets ~18.5m vs ~4.5m (faster being this new pure-Go implementation).
- Loading branch information
Showing
12 changed files
with
641 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha256" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/docker-library/bashbrew/manifest" | ||
"github.com/docker-library/bashbrew/pkg/tarscrub" | ||
) | ||
|
||
func (r Repo) archContextTar(arch string, entry *manifest.Manifest2822Entry, w io.Writer) error { | ||
f, err := r.archGitFS(arch, entry) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return tarscrub.WriteTar(f, w) | ||
} | ||
|
||
func (r Repo) ArchGitChecksum(arch string, entry *manifest.Manifest2822Entry) (string, error) { | ||
h := sha256.New() | ||
err := r.archContextTar(arch, entry, h) | ||
if err != nil { | ||
return "", err | ||
} | ||
return fmt.Sprintf("%x", h.Sum(nil)), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.