mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-19 06:21:41 -04:00
35 lines
579 B
Go
35 lines
579 B
Go
// Copyright IBM Corp. 2024, 2026
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package packer
|
|
|
|
import (
|
|
"strings"
|
|
|
|
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
|
)
|
|
|
|
func RegisterSecret(secret string) {
|
|
if secret == "" {
|
|
return
|
|
}
|
|
|
|
secrets := map[string]struct{}{
|
|
secret: {},
|
|
}
|
|
|
|
normalized := strings.ReplaceAll(secret, "\r\n", "\n")
|
|
secrets[normalized] = struct{}{}
|
|
|
|
for _, line := range strings.Split(normalized, "\n") {
|
|
if line == "" {
|
|
continue
|
|
}
|
|
secrets[line] = struct{}{}
|
|
}
|
|
|
|
for value := range secrets {
|
|
packersdk.LogSecretFilter.Set(value)
|
|
}
|
|
}
|