Add DockerCacheName to be able to use it from templates
- like the following to get golang:latest and the cache name of its parent
```console
$ bashbrew cat --format '{{ range .Entries }}{{ $.DockerCacheName . }}{{ range .Tags }}{{"\n"}}{{ join ":" $.RepoName . }}{{end}}{{"\n"}}{{end}}' golang:latest
```
This commit is contained in:
parent
e1b855bce7
commit
a712a5d847
|
|
@ -65,13 +65,11 @@ func cmdBuild(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheHash, err := r.dockerCacheHash(&entry)
|
cacheTag, err := r.DockerCacheName(&entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewMultiError(fmt.Errorf(`failed calculating "cache hash" for %q (tags %q)`, r.RepoName, entry.TagsString()), err)
|
return cli.NewMultiError(fmt.Errorf(`failed calculating "cache hash" for %q (tags %q)`, r.RepoName, entry.TagsString()), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheTag := "bashbrew/cache:" + cacheHash
|
|
||||||
|
|
||||||
// check whether we've already built this artifact
|
// check whether we've already built this artifact
|
||||||
_, err = dockerInspect("{{.Id}}", cacheTag)
|
_, err = dockerInspect("{{.Id}}", cacheTag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,14 @@ func dockerfileFrom(dockerfile io.Reader) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r Repo) DockerCacheName(entry *manifest.Manifest2822Entry) (string, error) {
|
||||||
|
cacheHash, err := r.dockerCacheHash(entry)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return "bashbrew/cache:" + cacheHash, err
|
||||||
|
}
|
||||||
|
|
||||||
func (r Repo) dockerCacheHash(entry *manifest.Manifest2822Entry) (string, error) {
|
func (r Repo) dockerCacheHash(entry *manifest.Manifest2822Entry) (string, error) {
|
||||||
uniqueBits, err := r.dockerBuildUniqueBits(entry)
|
uniqueBits, err := r.dockerBuildUniqueBits(entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue