Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 267c5a1

Browse files
committed
Fix error not returned and simplify handling symbols flag
1 parent 3e81da6 commit 267c5a1

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

internals/secrethub/generate.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var (
2828
ErrMinFlagInvalidInteger = errGenerate.Code("min_flag_invalid_int").ErrorPref("second part of --min flag is not an integer: %s")
2929
ErrCharsetSizeNonPositive = errGenerate.Code("charset_size_non_positive").Error("charset size must be > 0")
3030
ErrFlagsMutuallyExclusive = errGenerate.Code("include_exclude_flags_mutually_exclusive").ErrorPref("the following flags are mutually exclusive: --include %s, --exclude %s")
31+
ErrInvalidMinFlag = errGenerate.Code("min_flag_invalid").ErrorPref("min flag is invalid: %s")
3132
)
3233

3334
const defaultLength = 22
@@ -87,12 +88,7 @@ func (cmd *GenerateSecretCommand) before() error {
8788

8889
charset := randchar.Alphanumeric
8990
if useSymbols {
90-
symbols, found := randchar.CharsetByName("symbols")
91-
if found {
92-
charset = charset.Add(symbols)
93-
} else {
94-
return ErrCouldNotFindCharSet("symbols")
95-
}
91+
charset = charset.Add(randchar.Symbols)
9692
}
9793

9894
var includedCharsets []randchar.Charset
@@ -204,7 +200,7 @@ func (cmd *GenerateSecretCommand) run() error {
204200
func parseMinFlag(flag string) (randchar.Charset, int, error) {
205201
elements := strings.Split(flag, ":")
206202
if len(elements) != 2 {
207-
return randchar.Charset{}, 0, nil
203+
return randchar.Charset{}, 0, ErrInvalidMinFlag(flag)
208204
}
209205

210206
count, err := strconv.Atoi(elements[1])

0 commit comments

Comments
 (0)