Skip to content

Commit aa7eb56

Browse files
committed
Get only the last word of the credential name as the field name, if it's larger than seven characters
1 parent 1f44f6e commit aa7eb56

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cmd/contrib/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,22 @@ func newPlugin() error {
189189
}
190190
}
191191

192-
// As a placeholder, assume the field name is the short version (max 7 chars) of the credential name, starting
193-
// from the last word. For example:
192+
// As a placeholder, assume the field name is the short version (max 7 chars) of the credential name, starting from the last word.
193+
//
194+
// For example:
194195
// "Personal Access Token" => "Token"
195196
// "Secret Key" => "Key"
196197
// "API Key" => "API Key"
198+
//
199+
// When the last word of the credential name is greater than seven characters, the last word is used as the field name
197200
var fieldNameSplit []string
198201
lengthCutoff := 7
199202
for i := range credNameSplit {
200203
word := credNameSplit[len(credNameSplit)-1-i]
204+
if i == 0 {
205+
fieldNameSplit = append([]string{word}, fieldNameSplit...)
206+
continue
207+
}
201208
if len(strings.Join(append(fieldNameSplit, word), " ")) > lengthCutoff {
202209
break
203210
}

0 commit comments

Comments
 (0)