github.com/GGP1/kure@v0.8.4/commands/config/argon2/argon2.go (about) 1 package argon2 2 3 import ( 4 "fmt" 5 6 "github.com/GGP1/kure/auth" 7 cmdutil "github.com/GGP1/kure/commands" 8 "github.com/GGP1/kure/commands/config/argon2/test" 9 authDB "github.com/GGP1/kure/db/auth" 10 11 "github.com/spf13/cobra" 12 bolt "go.etcd.io/bbolt" 13 ) 14 15 const example = ` 16 kure config argon2` 17 18 // NewCmd returns a new command. 19 func NewCmd(db *bolt.DB) *cobra.Command { 20 cmd := &cobra.Command{ 21 Use: "argon2", 22 Short: "Display currently used argon2 parameters", 23 Aliases: []string{"argon"}, 24 Example: example, 25 PreRunE: auth.Login(db), 26 RunE: runArgon2(db), 27 } 28 29 cmd.AddCommand(test.NewCmd()) 30 31 return cmd 32 } 33 34 func runArgon2(db *bolt.DB) cmdutil.RunEFunc { 35 return func(cmd *cobra.Command, args []string) error { 36 params, err := authDB.GetParams(db) 37 if err != nil { 38 return err 39 } 40 41 fmt.Printf("Iterations: %d\nMemory: %d\nThreads: %d\n", 42 params.Argon2.Iterations, params.Argon2.Memory, params.Argon2.Threads) 43 return nil 44 } 45 }