Minor amendments for the tag info page to account the cache type of sub-image.

This commit is contained in:
Roman Vynar 2020-02-20 14:53:12 +02:00
parent e1cd96ef12
commit f9899cb785
5 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,9 @@
## Changelog
### 0.9.1 (2020-02-20)
* Minor amendments for the tag info page to account the cache type of sub-image.
### 0.9.0 (2020-02-19)
* Upgrade Go version to 1.13.7, alpine to 3.11 and other dependencies.

View File

@ -119,7 +119,7 @@ Docker image formats and their confusing combinations as supported by this UI:
* Manifest v2 schema 1 + Manifest v2 schema 2: current format of a single image, the image history are coming from schema 1, should be referenced by repo:tag name.
* Manifest v2 schema 1 + Manifest List v2 schema 2: multi-arch image format containing digests of sub-images, the image history are coming from schema 1 (no idea from what sub-image it was picked up when created), should be referenced by repo:tag name.
* Manifest v2 schema 2: current image format referenced by its digest sha256, no image history.
* Manifest List v2 schema 2: multi-arch image format referenced by its digest sha256, no image history.
* Manifest List v2 schema 2: multi-arch image referenced by its digest sha256 or cache image referenced by tag name, no image history.
### Screenshots

View File

@ -263,21 +263,26 @@ func (a *apiClient) viewTagInfo(c echo.Context) error {
layersCount = len(gjson.Get(infoV1, "fsLayers").Array())
}
// Gather sub-image info of multi-arch image
// Gather sub-image info of multi-arch or cache image
var digestList []map[string]interface{}
for _, s := range manifests {
r, _ := gjson.Parse(s.String()).Value().(map[string]interface{})
if s.Get("mediaType").String() == "application/vnd.docker.distribution.manifest.v2+json" {
// Sub-image of the specific arch.
_, dInfoV1, _ := a.client.TagInfo(repoPath, s.Get("digest").String(), true)
var dSize int64
for _, d := range gjson.Get(dInfoV1, "layers.#.size").Array() {
dSize = dSize + d.Int()
}
r["size"] = dSize
// Create link here because there is a bug with jet template when referencing a value by map key in the "if" condition under "range".
if r["mediaType"] == "application/vnd.docker.distribution.manifest.v2+json" {
r["digest"] = fmt.Sprintf(`<a href="%s/%s/%s/%s">%s</a>`, a.config.BasePath, namespace, repo, r["digest"], r["digest"])
}
} else {
// Sub-image of the cache type.
r["size"] = s.Get("size").Int()
}
delete(r, "mediaType")
r["ordered_keys"] = registry.SortedMapKeys(r)
digestList = append(digestList, r)
}

View File

@ -20,12 +20,12 @@
</tr>
</thead>
<tr>
<td width="20%"><b>Image URL</b></td><td>{{ registryHost }}/{{ repoPath }}{{if isDigest}}@{{else}}:{{end}}{{ tag }}</td>
<td width="20%"><b>Image URL</b></td><td>{{ registryHost }}/{{ repoPath }}{{ isDigest ? "@" : ":" }}{{ tag }}</td>
</tr>
<tr>
<td><b>Digest</b></td><td>sha256:{{ sha256 }}</td>
</tr>
{{if not isDigest}}
{{if created}}
<tr>
<td><b>Created On</b></td><td>{{ created|pretty_time }}</td>
</tr>
@ -48,7 +48,7 @@
</table>
{{if digestList}}
<h4>Multi-arch Sub-images <!-- Manifest List v2 schema 2 --></h4>
<h4>Sub-images <!-- Manifest List v2 schema 2: multi-arch or cache image --></h4>
{{range index, manifest := digestList}}
<table class="table table-striped table-bordered">
<thead bgcolor="#ddd">
@ -68,10 +68,8 @@
</td>
{{else if key == "size"}}
<td>{{ manifest[key]|pretty_size }}</td>
{{else if key == "digest"}}
<td><a href="{{ basePath }}/{{ namespace }}/{{ repo }}/{{ manifest["digest"] }}">{{ manifest["digest"] }}</a></td>
{{else}}
<td>{{ manifest[key] }}</td>
<td>{{ manifest[key]|raw }}</td>
{{end}}
</tr>
{{end}}

View File

@ -1,3 +1,3 @@
package main
const version = "0.9.0"
const version = "0.9.1"