mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 11:46:20 -04:00
f3a9b00ec8
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
39 lines
653 B
Go
39 lines
653 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/genuinetools/reg/registry"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var digestCommand = cli.Command{
|
|
Name: "digest",
|
|
Usage: "get the digest",
|
|
Action: func(c *cli.Context) error {
|
|
if len(c.Args()) < 1 {
|
|
return fmt.Errorf("pass the name of the repository")
|
|
}
|
|
|
|
image, err := registry.ParseImage(c.Args().First())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Create the registry client.
|
|
r, err := createRegistryClient(c, image.Domain)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Get the digest.
|
|
digest, err := r.Digest(image)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println(digest.String())
|
|
|
|
return nil
|
|
},
|
|
}
|