Skip to content

Commit 5f1ca1d

Browse files
committed
Fix descriptions of unencrypted-regex and encrypted-regex flags.
Signed-off-by: Mitar <mitar.git@tnode.com>
1 parent b7da2fc commit 5f1ca1d

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

cmd/sops/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,11 +678,11 @@ func main() {
678678
},
679679
cli.StringFlag{
680680
Name: "unencrypted-regex",
681-
Usage: "set the unencrypted key suffix. When specified, only keys matching the regex will be left unencrypted.",
681+
Usage: "set the unencrypted key regex. When specified, only keys matching the regex will be left unencrypted.",
682682
},
683683
cli.StringFlag{
684684
Name: "encrypted-regex",
685-
Usage: "set the encrypted key suffix. When specified, only keys matching the regex will be encrypted.",
685+
Usage: "set the encrypted key regex. When specified, only keys matching the regex will be encrypted.",
686686
},
687687
cli.StringFlag{
688688
Name: "config",

config/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,15 @@ func configFromRule(rule *creationRule, kmsEncryptionContext map[string]*string)
242242
if rule.EncryptedSuffix != "" {
243243
cryptRuleCount++
244244
}
245+
if rule.UnencryptedRegex != "" {
246+
cryptRuleCount++
247+
}
245248
if rule.EncryptedRegex != "" {
246249
cryptRuleCount++
247250
}
248251

249252
if cryptRuleCount > 1 {
250-
return nil, fmt.Errorf("error loading config: cannot use more than one of encrypted_suffix, unencrypted_suffix, or encrypted_regex for the same rule")
253+
return nil, fmt.Errorf("error loading config: cannot use more than one of encrypted_suffix, unencrypted_suffix, encrypted_regex, or unencrypted_regex for the same rule")
251254
}
252255

253256
groups, err := getKeyGroupsFromCreationRule(rule, kmsEncryptionContext)

config/config_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,19 @@ creation_rules:
140140
version: fooversion
141141
`)
142142

143-
var sampleConfigWithRegexParameters = []byte(`
143+
var sampleConfigWithEncryptedRegexParameters = []byte(`
144144
creation_rules:
145145
- path_regex: barbar*
146146
kms: "1"
147147
pgp: "2"
148148
encrypted_regex: "^enc:"
149+
`)
150+
151+
var sampleConfigWithUnencryptedRegexParameters = []byte(`
152+
creation_rules:
153+
- path_regex: barbar*
154+
kms: "1"
155+
pgp: "2"
149156
unencrypted_regex: "^dec:"
150157
`)
151158

@@ -226,7 +233,7 @@ creation_rules:
226233
var sampleConfigWithComplicatedRegexp = []byte(`
227234
creation_rules:
228235
- path_regex: "stage/dev/feature-.*"
229-
kms: dev-feature
236+
kms: dev-feature
230237
- path_regex: "stage/dev/.*"
231238
kms: dev
232239
- path_regex: "stage/staging/.*"
@@ -396,13 +403,13 @@ func TestLoadConfigFileWithEncryptedSuffix(t *testing.T) {
396403
}
397404

398405
func TestLoadConfigFileWithUnencryptedRegex(t *testing.T) {
399-
conf, err := parseCreationRuleForFile(parseConfigFile(sampleConfigWithRegexParameters, t), "/conf/path", "barbar", nil)
406+
conf, err := parseCreationRuleForFile(parseConfigFile(sampleConfigWithUnencryptedRegexParameters, t), "/conf/path", "barbar", nil)
400407
assert.Equal(t, nil, err)
401408
assert.Equal(t, "^dec:", conf.UnencryptedRegex)
402409
}
403410

404411
func TestLoadConfigFileWithEncryptedRegex(t *testing.T) {
405-
conf, err := parseCreationRuleForFile(parseConfigFile(sampleConfigWithRegexParameters, t), "/conf/path", "barbar", nil)
412+
conf, err := parseCreationRuleForFile(parseConfigFile(sampleConfigWithEncryptedRegexParameters, t), "/conf/path", "barbar", nil)
406413
assert.Equal(t, nil, err)
407414
assert.Equal(t, "^enc:", conf.EncryptedRegex)
408415
}

0 commit comments

Comments
 (0)