Merge branch 'demo' of github.com:docker/vetinari into demo

This commit is contained in:
Diogo Monica 2015-06-18 15:13:29 -07:00
commit a353ee13e7
1 changed files with 19 additions and 9 deletions

View File

@ -253,29 +253,36 @@ func tufList(cmd *cobra.Command, args []string) {
func tufLookup(cmd *cobra.Command, args []string) { func tufLookup(cmd *cobra.Command, args []string) {
if len(args) < 2 { if len(args) < 2 {
cmd.Usage() cmd.Usage()
fatalf("must specify a GUN and target path to look up.") fatalf("must specify a GUN and target name")
} }
gun := args[0] gun := args[0]
targetName := args[1] targetName := args[1]
kdb := keys.NewDB() kdb := keys.NewDB()
repo := tuf.NewTufRepo(kdb, nil) repo := tuf.NewTufRepo(kdb, nil)
remote, err := store.NewHTTPStore( remote, err := store.NewHTTPStore(
"https://vetinari:4443/v2"+gun+"/_trust/tuf/", "https://vetinari:4443/v2/"+gun+"/_trust/tuf/",
"", "",
"json", "json",
"", "",
) )
rootJSON, err := remote.GetMeta("root", 5<<20)
rootJSON, err := remote.GetMeta("root", 0) if err != nil {
fmt.Println("Couldn't get initial root")
fatalf(err.Error())
}
root := &data.Signed{} root := &data.Signed{}
err = json.Unmarshal(rootJSON, root) err = json.Unmarshal(rootJSON, root)
if err != nil { if err != nil {
fmt.Println("Couldn't parse initial root")
fatalf(err.Error()) fatalf(err.Error())
} }
// TODO: Validate the root file against the key store // TODO: Validate the root file against the key store
repo.SetRoot(root) err = repo.SetRoot(root)
if err != nil {
fmt.Println("Error setting root")
fatalf(err.Error())
}
c := client.NewClient( c := client.NewClient(
repo, repo,
@ -285,11 +292,14 @@ func tufLookup(cmd *cobra.Command, args []string) {
err = c.Update() err = c.Update()
if err != nil { if err != nil {
fmt.Println("Update failed")
fatalf(err.Error()) fatalf(err.Error())
} }
m := c.TargetMeta(targetName) meta := c.TargetMeta(targetName)
// TODO: how to we want to output hash and size if meta == nil {
fmt.Println(m.Hashes["sha256"], " ", m.Length) return
}
fmt.Println(targetName, fmt.Sprintf("sha256:%s", meta.Hashes["sha256"]), meta.Length)
} }
func tufPush(cmd *cobra.Command, args []string) { func tufPush(cmd *cobra.Command, args []string) {