diff options
author | amine <hilalyamine@gmail.com> | 2019-11-08 14:49:24 +0100 |
---|---|---|
committer | amine <hilalyamine@gmail.com> | 2019-11-09 14:52:20 +0100 |
commit | bbbf3c6c7f245ea2ddc9d31639e7ebac50eeac2d (patch) | |
tree | 17883d25b5d1f2f1b1fe2f2bf33b44d1259b938e /commands/bridge_token_add.go | |
parent | 4dc7b8b06ed5d48eca077b81a0b8c90777b8fe82 (diff) | |
download | git-bug-bbbf3c6c7f245ea2ddc9d31639e7ebac50eeac2d.tar.gz |
bridge/core: store token in the global config and replace scopes with create date
Diffstat (limited to 'commands/bridge_token_add.go')
-rw-r--r-- | commands/bridge_token_add.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/commands/bridge_token_add.go b/commands/bridge_token_add.go index 7b7a8964..58e9f472 100644 --- a/commands/bridge_token_add.go +++ b/commands/bridge_token_add.go @@ -8,17 +8,17 @@ import ( ) var ( - bridgeToken core.Token + bridgeTokenValue string + bridgeTokenTarget string ) func runBridgeTokenAdd(cmd *cobra.Command, args []string) error { - _ = bridgeToken.Id() // TODO: a better design to avoid doing this - - if err := bridgeToken.Validate(); err != nil { + token := core.NewToken(bridgeTokenValue, bridgeTokenTarget) + if err := token.Validate(); err != nil { return errors.Wrap(err, "invalid token") } - return core.StoreToken(repo, &bridgeToken) + return core.StoreToken(repo, token) } var bridgeTokenAddCmd = &cobra.Command{ @@ -31,9 +31,7 @@ var bridgeTokenAddCmd = &cobra.Command{ func init() { bridgeTokenCmd.AddCommand(bridgeTokenAddCmd) - bridgeTokenAddCmd.Flags().BoolVarP(&bridgeToken.Global, "global", "g", false, "") - bridgeTokenAddCmd.Flags().StringVarP(&bridgeToken.Value, "value", "v", "", "") - bridgeTokenAddCmd.Flags().StringVarP(&bridgeToken.Target, "target", "t", "", "") - bridgeTokenAddCmd.Flags().StringArrayVarP(&bridgeToken.Scopes, "scopes", "s", []string{}, "") + bridgeTokenAddCmd.Flags().StringVarP(&bridgeTokenValue, "value", "v", "", "") + bridgeTokenAddCmd.Flags().StringVarP(&bridgeTokenTarget, "target", "t", "", "") bridgeTokenAddCmd.Flags().SortFlags = false } |