From bbbf3c6c7f245ea2ddc9d31639e7ebac50eeac2d Mon Sep 17 00:00:00 2001 From: amine Date: Fri, 8 Nov 2019 14:49:24 +0100 Subject: bridge/core: store token in the global config and replace scopes with create date --- commands/bridge_token_add.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'commands/bridge_token_add.go') 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 } -- cgit