Skip to content

Commit

Permalink
Minor amendments for the tag info page to account the cache type of s…
Browse files Browse the repository at this point in the history
…ub-image.
  • Loading branch information
roman-vynar committed Feb 20, 2020
1 parent e1cd96e commit f9899cb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 4 additions & 6 deletions templates/tag_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ <h4>Image Details</h4>
</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>
Expand All @@ -48,7 +48,7 @@ <h4>Image Details</h4>
</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">
Expand All @@ -68,10 +68,8 @@ <h4>Multi-arch Sub-images <!-- Manifest List v2 schema 2 --></h4>
</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}}
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

const version = "0.9.0"
const version = "0.9.1"

0 comments on commit f9899cb

Please sign in to comment.