mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 03:36:19 -04:00
Add option to fetch Docker-Content-Digest
Code reused from manifest.go; this one is helpful to figure out if tags have changed
This commit is contained in:
parent
5a91099e76
commit
80cac4cc4b
3 changed files with 47 additions and 0 deletions
|
@ -46,6 +46,7 @@ AUTHOR:
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
delete, rm delete a specific reference of a repository
|
delete, rm delete a specific reference of a repository
|
||||||
|
digest get the Docker-Content-Digest
|
||||||
layer, download download a layer for the specific reference of a repository
|
layer, download download a layer for the specific reference of a repository
|
||||||
list, ls list all repositories
|
list, ls list all repositories
|
||||||
manifest get the json manifest for the specific reference of a repository
|
manifest get the json manifest for the specific reference of a repository
|
||||||
|
@ -102,6 +103,12 @@ latest
|
||||||
stable
|
stable
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Get the Docker-Content-Digest
|
||||||
|
```console
|
||||||
|
$ reg digest htop
|
||||||
|
"sha256:791158756cc0f5b27ef8c5c546284568fc9b7f4cf1429fb736aff3ee2d2e340f"
|
||||||
|
```
|
||||||
|
|
||||||
## Get a Manifest
|
## Get a Manifest
|
||||||
|
|
||||||
```console
|
```console
|
||||||
|
|
39
digest.go
Normal file
39
digest.go
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/genuinetools/reg/repoutils"
|
||||||
|
"github.com/urfave/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
var digestCommand = cli.Command{
|
||||||
|
Name: "digest",
|
||||||
|
Usage: "get the Docker-Content-Digest",
|
||||||
|
Action: func(c *cli.Context) error {
|
||||||
|
if len(c.Args()) < 1 {
|
||||||
|
return fmt.Errorf("pass the name of the repository")
|
||||||
|
}
|
||||||
|
|
||||||
|
repo, ref, err := repoutils.GetRepoAndRef(c.Args()[0])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var digest interface{}
|
||||||
|
digest, err = r.Digest(repo, ref)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := json.MarshalIndent(digest, " ", " ")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(string(b))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
1
main.go
1
main.go
|
@ -57,6 +57,7 @@ func main() {
|
||||||
|
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
deleteCommand,
|
deleteCommand,
|
||||||
|
digestCommand,
|
||||||
layerCommand,
|
layerCommand,
|
||||||
listCommand,
|
listCommand,
|
||||||
manifestCommand,
|
manifestCommand,
|
||||||
|
|
Loading…
Reference in a new issue