Skip to content

Commit

Permalink
Added go-password for cryptographically secure pseudorandom “passwords”
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilyes512 committed Jul 27, 2018
1 parent 46d01fa commit b306093
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
name = "gopkg.in/src-d/go-git.v4"
version = "4.5.0"

[[constraint]]
name = "github.com/Masterminds/sprig"
version = "2.15.0"

[[constraint]]
name = "github.com/sethvargo/go-password"
version = "0.1.1"

[prune]
go-tests = true
unused-packages = true
12 changes: 12 additions & 0 deletions pkg/template/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"text/template"
"time"

"github.com/sethvargo/go-password/password"
)

var (
Expand Down Expand Up @@ -83,6 +85,16 @@ var (

// String utilities
"toTitle": strings.ToTitle,

// password.Generate(length, numDigits, numSymbols int, noUpper, allowRepeat bool) (string, error)
"password": func(length, numDigits, numSymbols int, noUpper, allowRepeat bool) string {
res, err := password.Generate(length, numDigits, numSymbols, noUpper, allowRepeat)
if err != nil {
return fmt.Sprintf("failed to generate password: %s", err)
}

return res
},
}

// Options contain the default options for the template execution.
Expand Down

0 comments on commit b306093

Please sign in to comment.