Merge pull request #11030 from cli/bdehamer/release-asset-digest
Add Digest to ReleaseAsset struct
This commit is contained in:
commit
79fc854814
3 changed files with 16 additions and 8 deletions
|
|
@ -71,6 +71,7 @@ type ReleaseAsset struct {
|
|||
Name string
|
||||
Label string
|
||||
Size int64
|
||||
Digest *string
|
||||
State string
|
||||
APIURL string `json:"url"`
|
||||
|
||||
|
|
@ -107,6 +108,7 @@ func (rel *Release) ExportData(fields []string) map[string]interface{} {
|
|||
"name": a.Name,
|
||||
"label": a.Label,
|
||||
"size": a.Size,
|
||||
"digest": a.Digest,
|
||||
"state": a.State,
|
||||
"createdAt": a.CreatedAt,
|
||||
"updatedAt": a.UpdatedAt,
|
||||
|
|
|
|||
|
|
@ -154,10 +154,14 @@ func renderReleaseTTY(io *iostreams.IOStreams, release *shared.Release) error {
|
|||
|
||||
if len(release.Assets) > 0 {
|
||||
fmt.Fprintln(w, cs.Bold("Assets"))
|
||||
//nolint:staticcheck // SA1019: Showing NAME|SIZE headers adds nothing to table.
|
||||
table := tableprinter.New(io, tableprinter.NoHeader)
|
||||
table := tableprinter.New(io, tableprinter.WithHeader("Name", "Digest", "Size"))
|
||||
for _, a := range release.Assets {
|
||||
table.AddField(a.Name)
|
||||
if a.Digest == nil {
|
||||
table.AddField("")
|
||||
} else {
|
||||
table.AddField(*a.Digest)
|
||||
}
|
||||
table.AddField(humanFileSize(a.Size))
|
||||
table.EndRow()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,8 +150,9 @@ func Test_viewRun(t *testing.T) {
|
|||
|
||||
|
||||
Assets
|
||||
windows.zip 12 B
|
||||
linux.tgz 34 B
|
||||
NAME DIGEST SIZE
|
||||
windows.zip sha256:deadc0de 12 B
|
||||
linux.tgz 34 B
|
||||
|
||||
View on GitHub: https://github.com/OWNER/REPO/releases/tags/v1.2.3
|
||||
`),
|
||||
|
|
@ -174,8 +175,9 @@ func Test_viewRun(t *testing.T) {
|
|||
|
||||
|
||||
Assets
|
||||
windows.zip 12 B
|
||||
linux.tgz 34 B
|
||||
NAME DIGEST SIZE
|
||||
windows.zip sha256:deadc0de 12 B
|
||||
linux.tgz 34 B
|
||||
|
||||
View on GitHub: https://github.com/OWNER/REPO/releases/tags/v1.2.3
|
||||
`),
|
||||
|
|
@ -248,8 +250,8 @@ func Test_viewRun(t *testing.T) {
|
|||
"published_at": "%[1]s",
|
||||
"html_url": "https://github.com/OWNER/REPO/releases/tags/v1.2.3",
|
||||
"assets": [
|
||||
{ "name": "windows.zip", "size": 12 },
|
||||
{ "name": "linux.tgz", "size": 34 }
|
||||
{ "name": "windows.zip", "size": 12, "digest": "sha256:deadc0de" },
|
||||
{ "name": "linux.tgz", "size": 34, "digest": null }
|
||||
]
|
||||
}`, tt.releasedAt.Format(time.RFC3339), tt.releaseBody))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue