Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI prints for successful operations #974

Merged
merged 1 commit into from
Sep 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Awesome letting them know they got the remote too!

}

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 it was a success, print to terminal
if err == nil {
cmd.Printf("Successfully reset specified changes for repository %s\n", gun)
}
return err
}

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
}