You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
// TODO "unfiltered" or something for not applying Dockerfile filtering (once that's implemented)
435
+
},
436
+
Before: subcommandBeforeFactory("context"),
437
+
Action: func(c*cli.Context) error {
438
+
repos, err:=repos(false, c.Args()...)
439
+
iferr!=nil {
440
+
returnerr
441
+
}
442
+
iflen(repos) !=1 {
443
+
returnfmt.Errorf("'context' expects to act on exactly one architecture of one entry of one repo (got %d repos)", len(repos))
444
+
}
445
+
446
+
r, err:=fetch(repos[0])
447
+
iferr!=nil {
448
+
returnerr
449
+
}
450
+
451
+
// TODO technically something like "hello-world:latest" *could* be relaxed a little if it resolves via architecture to one and only one entry 🤔 (but that's a little hard to implement with the existing internal data structures -- see TODO at the top of "sort.go")
452
+
453
+
ifr.TagEntry==nil {
454
+
returnfmt.Errorf("'context' expects to act on exactly one architecture of one entry of one repo (no specific entry of %q selected)", r.RepoName)
455
+
}
456
+
iflen(r.TagEntries) !=1 {
457
+
returnfmt.Errorf("'context' expects to act on exactly one architecture of one entry of one repo (got %d entires)", len(r.TagEntries))
458
+
}
459
+
460
+
if!r.TagEntry.HasArchitecture(arch) {
461
+
returnfmt.Errorf("%q does not include architecture %q", path.Join(namespace, r.RepoName)+":"+r.TagEntry.Tags[0], arch)
462
+
}
463
+
464
+
ifc.Bool("sha256") {
465
+
sum, err:=r.ArchGitChecksum(arch, r.TagEntry)
466
+
iferr!=nil {
467
+
returnerr
468
+
}
469
+
fmt.Println(sum)
470
+
returnnil
471
+
} else {
472
+
ifxTerm.IsTerminal(int(os.Stdout.Fd())) {
473
+
returnfmt.Errorf("cowardly refusing to output a tar to a terminal")
Copy file name to clipboardExpand all lines: cmd/bashbrew/sort.go
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@ import (
5
5
"pault.ag/go/topsort"
6
6
)
7
7
8
+
// TODO unify archFilter and applyConstraints handling by pre-filtering the full list of Repo objects such that all that remains are things we should process (thus removing all "if" statements throughout the various loops); re-doing the Architectures and Entries lists to only include ones we should process, etc
0 commit comments