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>
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/genuinetools/reg/registry"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var manifestCommand = cli.Command{
|
|
Name: "manifest",
|
|
Usage: "get the json manifest for the specific reference of a repository",
|
|
Flags: []cli.Flag{
|
|
cli.BoolFlag{
|
|
Name: "v1",
|
|
Usage: "force the version of the manifest retrieved to v1",
|
|
},
|
|
},
|
|
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
|
|
}
|
|
|
|
var manifest interface{}
|
|
if c.Bool("v1") {
|
|
// Get the v1 manifest if it was explicitly asked for.
|
|
manifest, err = r.ManifestV1(image.Path, image.Reference())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
// Get the v2 manifest.
|
|
manifest, err = r.Manifest(image.Path, image.Reference())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
b, err := json.MarshalIndent(manifest, " ", " ")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println(string(b))
|
|
|
|
return nil
|
|
},
|
|
}
|