Merge branch 'pr-93'

* pr-93:
  Add option to fetch Docker-Content-Digest
  Fix typo
This commit is contained in:
Jess Frazelle 2018-06-06 14:18:54 -04:00
commit 9534afc84a
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3
4 changed files with 50 additions and 2 deletions

View file

@ -11,6 +11,7 @@ Docker registry v2 command line client.
+ [Auth](#auth)
+ [List Repositories and Tags](#list-repositories-and-tags)
+ [Get a Manifest](#get-a-manifest)
+ [Get the Digest](#get-the-digest)
+ [Download a Layer](#download-a-layer)
+ [Delete an Image](#delete-an-image)
+ [Vulnerability Reports](#vulnerability-reports)
@ -49,6 +50,7 @@ AUTHOR:
COMMANDS:
delete, rm delete a specific reference of a repository
digest get the digest
layer, download download a layer for the specific reference of a repository
list, ls list all repositories
manifest get the json manifest for the specific reference of a repository
@ -105,7 +107,7 @@ latest
stable
```
### Get a Manifest
## Get a Manifest
```console
$ reg manifest htop
@ -126,6 +128,12 @@ $ reg manifest htop
}
```
## Get the Digest
```console
$ reg digest htop
sha256:791158756cc0f5b27ef8c5c546284568fc9b7f4cf1429fb736aff3ee2d2e340f
```
### Download a Layer
```console

39
digest.go Normal file
View 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
},
}

View file

@ -67,6 +67,7 @@ func main() {
app.Commands = []cli.Command{
deleteCommand,
digestCommand,
layerCommand,
listCommand,
manifestCommand,

View file

@ -14,7 +14,7 @@ var manifestCommand = cli.Command{
Flags: []cli.Flag{
cli.BoolFlag{
Name: "v1",
Usage: "force the version of the manifest retreived to v1",
Usage: "force the version of the manifest retrieved to v1",
},
},
Action: func(c *cli.Context) error {