Skip to content

Commit

Permalink
Add CLI prints for successful operations
Browse files Browse the repository at this point in the history
Signed-off-by: Riyaz Faizullabhoy <[email protected]>
  • Loading branch information
riyazdf committed Sep 22, 2016
1 parent 3b5c8ad commit 277e67a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
6 changes: 5 additions & 1 deletion cmd/notary/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ func (k *keyCommander) keysRotate(cmd *cobra.Command, args []string) error {
}
}

return nRepo.RotateKey(rotateKeyRole, k.rotateKeyServerManaged)
if err := nRepo.RotateKey(rotateKeyRole, k.rotateKeyServerManaged); err != nil {
return err
}
cmd.Printf("Successfully rotated %s key for repository %s\n", rotateKeyRole, gun)
return nil
}

func removeKeyInteractively(keyStores []trustmanager.KeyStore, keyID string,
Expand Down
35 changes: 26 additions & 9 deletions cmd/notary/tuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,13 @@ func (t *tufCommander) tufDeleteGUN(cmd *cobra.Command, args []string) error {

// Only initialize a roundtripper if we get the remote flag
var rt http.RoundTripper
var remoteDeleteInfo string
if t.deleteRemote {
rt, err = getTransport(config, gun, admin)
if err != nil {
return err
}
remoteDeleteInfo = " and remote"
}

nRepo, err := notaryclient.NewNotaryRepository(
Expand All @@ -362,9 +364,13 @@ func (t *tufCommander) tufDeleteGUN(cmd *cobra.Command, args []string) error {
return err
}

cmd.Printf("Deleting trust data for repository %s.\n", gun)
cmd.Printf("Deleting trust data for repository %s\n", gun)

return nRepo.DeleteTrustData(t.deleteRemote)
if err := nRepo.DeleteTrustData(t.deleteRemote); err != nil {
return err
}
cmd.Printf("Successfully deleted local%s trust data for repository %s\n", remoteDeleteInfo, gun)
return nil
}

func (t *tufCommander) tufInit(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -619,9 +625,15 @@ func (t *tufCommander) tufReset(cmd *cobra.Command, args []string) error {
}

if t.resetAll {
return cl.Clear(t.archiveChangelist)
err = cl.Clear(t.archiveChangelist)
} else {
err = cl.Remove(t.deleteIdx)
}
return cl.Remove(t.deleteIdx)
if err != nil {
return err
}
cmd.Printf("Successfully reset specified changes for repository %s\n", gun)
return nil
}

func (t *tufCommander) tufPublish(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -654,10 +666,7 @@ func (t *tufCommander) tufPublish(cmd *cobra.Command, args []string) error {
return err
}

if err = nRepo.Publish(); err != nil {
return err
}
return nil
return publishAndPrintToCLI(cmd, nRepo, gun)
}

func (t *tufCommander) tufRemove(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -1005,5 +1014,13 @@ func maybeAutoPublish(cmd *cobra.Command, doPublish bool, gun string, config *vi
}

cmd.Println("Auto-publishing changes to", gun)
return nRepo.Publish()
return publishAndPrintToCLI(cmd, nRepo, gun)
}

func publishAndPrintToCLI(cmd *cobra.Command, nRepo *notaryclient.NotaryRepository, gun string) error {
if err := nRepo.Publish(); err != nil {
return err
}
cmd.Printf("Successfully published changes for repository %s\n", gun)
return nil
}

0 comments on commit 277e67a

Please sign in to comment.