fix: zli images show if signed instead of signature (#886)

Signed-off-by: Lisca Ana-Roberta <ana.kagome@yahoo.com>
This commit is contained in:
Lisca Ana-Roberta
2022-10-20 19:35:24 +03:00
committed by GitHub
parent 76714d53f8
commit 7f9052972d
5 changed files with 217 additions and 69 deletions
+11 -5
View File
@@ -119,7 +119,7 @@ func (service searchService) getImagesGQL(ctx context.Context, config searchConf
imageName string,
) (*imageListStructGQL, error) {
query := fmt.Sprintf(`{ImageList(repo: "%s") {`+`
RepoName Tag Digest ConfigDigest Size Layers {Size Digest}}
RepoName Tag Digest ConfigDigest Size Layers {Size Digest} IsSigned}
}`,
imageName)
result := &imageListStructGQL{}
@@ -846,6 +846,7 @@ type imageStruct struct {
Layers []layer `json:"layers"`
Size string `json:"size"`
verbose bool
IsSigned bool `json:"isSigned"`
}
type imageListStructGQL struct {
@@ -911,6 +912,7 @@ func (img imageStruct) stringPlainText(maxImgNameLen, maxTagLen int) (string, er
table.SetColMinWidth(colDigestIndex, digestWidth)
table.SetColMinWidth(colSizeIndex, sizeWidth)
table.SetColMinWidth(colIsSignedIndex, isSignedWidth)
if img.verbose {
table.SetColMinWidth(colConfigIndex, configWidth)
@@ -925,12 +927,14 @@ func (img imageStruct) stringPlainText(maxImgNameLen, maxTagLen int) (string, er
imgSize, _ := strconv.ParseUint(img.Size, 10, 64)
size := ellipsize(strings.ReplaceAll(humanize.Bytes(imgSize), " ", ""), sizeWidth, ellipsis)
config := ellipsize(img.ConfigDigest, configWidth, "")
row := make([]string, 6) //nolint:gomnd
isSigned := img.IsSigned
row := make([]string, 7) //nolint:gomnd
row[colImageNameIndex] = imageName
row[colTagIndex] = tagName
row[colDigestIndex] = digest
row[colSizeIndex] = size
row[colIsSignedIndex] = strconv.FormatBool(isSigned)
if img.verbose {
row[colConfigIndex] = config
@@ -945,7 +949,7 @@ func (img imageStruct) stringPlainText(maxImgNameLen, maxTagLen int) (string, er
size := ellipsize(strings.ReplaceAll(humanize.Bytes(layerSize), " ", ""), sizeWidth, ellipsis)
layerDigest := ellipsize(entry.Digest, digestWidth, "")
layerRow := make([]string, 6) //nolint:gomnd
layerRow := make([]string, 7) //nolint:gomnd
layerRow[colImageNameIndex] = ""
layerRow[colTagIndex] = ""
layerRow[colDigestIndex] = ""
@@ -1112,6 +1116,7 @@ const (
tagWidth = 24
digestWidth = 8
sizeWidth = 8
isSignedWidth = 8
configWidth = 8
layersWidth = 8
ellipsis = "..."
@@ -1120,8 +1125,9 @@ const (
colTagIndex = 1
colDigestIndex = 2
colConfigIndex = 3
colLayersIndex = 4
colSizeIndex = 5
colIsSignedIndex = 4
colLayersIndex = 5
colSizeIndex = 6
cveIDWidth = 16
cveSeverityWidth = 8