Skip to content

Commit

Permalink
Merge pull request #886 from HuKeping/autopublish
Browse files Browse the repository at this point in the history
Introduce a flag for auto publishing
  • Loading branch information
cyli authored Aug 9, 2016
2 parents da2a273 + 6c386a6 commit f76c23e
Show file tree
Hide file tree
Showing 4 changed files with 465 additions and 26 deletions.
9 changes: 7 additions & 2 deletions cmd/notary/delegations.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type delegationCommander struct {
paths []string
allPaths, removeAll, forceYes bool
keyIDs []string

autoPublish bool
}

func (d *delegationCommander) GetCommand() *cobra.Command {
Expand All @@ -66,11 +68,13 @@ func (d *delegationCommander) GetCommand() *cobra.Command {
cmdRemDelg.Flags().StringSliceVar(&d.paths, "paths", nil, "List of paths to remove")
cmdRemDelg.Flags().BoolVarP(&d.forceYes, "yes", "y", false, "Answer yes to the removal question (no confirmation)")
cmdRemDelg.Flags().BoolVar(&d.allPaths, "all-paths", false, "Remove all paths from this delegation")
cmdRemDelg.Flags().BoolVarP(&d.autoPublish, "publish", "p", false, htAutoPublish)
cmd.AddCommand(cmdRemDelg)

cmdAddDelg := cmdDelegationAddTemplate.ToCommand(d.delegationAdd)
cmdAddDelg.Flags().StringSliceVar(&d.paths, "paths", nil, "List of paths to add")
cmdAddDelg.Flags().BoolVar(&d.allPaths, "all-paths", false, "Add all paths to this delegation")
cmdAddDelg.Flags().BoolVarP(&d.autoPublish, "publish", "p", false, htAutoPublish)
cmd.AddCommand(cmdAddDelg)
return cmd
}
Expand Down Expand Up @@ -265,7 +269,7 @@ func (d *delegationCommander) delegationRemove(cmd *cobra.Command, args []string
}
cmd.Println("")

return nil
return maybeAutoPublish(cmd, d.autoPublish, gun, config, d.retriever)
}

// delegationAdd creates a new delegation by adding a public key from a certificate to a specific role in a GUN
Expand Down Expand Up @@ -359,5 +363,6 @@ func (d *delegationCommander) delegationAdd(cmd *cobra.Command, args []string) e
"Addition of delegation role %s %sto repository \"%s\" staged for next publish.\n",
role, addingItems, gun)
cmd.Println("")
return nil

return maybeAutoPublish(cmd, d.autoPublish, gun, config, d.retriever)
}
Loading

0 comments on commit f76c23e

Please sign in to comment.