Skip to content

Commit

Permalink
cmd: better "updating index" message (kubernetes-sigs#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetb authored Oct 14, 2018
1 parent c5f54f5 commit 4826243
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/krew/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ All plugins will be downloaded and made available to: "kubectl plugin <name>"`,
},
PreRunE: func(cmd *cobra.Command, args []string) error {
if *manifest == "" {
return ensureUpdated(cmd, args)
return ensureIndexUpdated(cmd, args)
}
glog.V(4).Infof("--manifest specified, not ensuring plugin index")
return nil
Expand Down
10 changes: 6 additions & 4 deletions cmd/krew/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"os"

"github.com/GoogleContainerTools/krew/pkg/gitutil"
"github.com/golang/glog"

"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand All @@ -34,14 +35,15 @@ var updateCmd = &cobra.Command{
Long: `Update local plugin index.
Fetch the newest version of Krew and all formulae from GitHub using git(1) and
perform any necessary migrations.`,
RunE: ensureUpdated,
RunE: ensureIndexUpdated,
}

func ensureUpdated(_ *cobra.Command, _ []string) error {
func ensureIndexUpdated(_ *cobra.Command, _ []string) error {
glog.V(1).Infof("Updating the local copy of plugin index (%s)", paths.IndexPath())
if err := gitutil.EnsureUpdated(IndexURI, paths.IndexPath()); err != nil {
return errors.Wrapf(err, "failed to ensure that the index path %q is updated", paths.IndexPath())
return errors.Wrap(err, "failed to update the local index")
}
fmt.Fprintln(os.Stderr, "Updated index")
fmt.Fprintln(os.Stderr, "Updated the local copy of plugin index.")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/krew/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ kubectl plugin upgrade foo bar"`,
}
return nil
},
PreRunE: ensureUpdated,
PreRunE: ensureIndexUpdated,
}

func init() {
Expand Down

0 comments on commit 4826243

Please sign in to comment.