feat: allow specifying base64-encoded values in vector-sink DSN urls
This will allow Vector templating to work when using Kubernetes as the scheduler.
This commit is contained in:
@@ -2,6 +2,7 @@ package logs
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -102,5 +103,21 @@ func SinkValueToConfig(appName string, sinkValue string) (VectorSink, error) {
|
||||
data["inputs"] = []string{"docker-null-source"}
|
||||
}
|
||||
|
||||
// add special support for `base64enc:VAL` fields
|
||||
for key, value := range data {
|
||||
valueString, ok := value.(string)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if encodedValue, found := strings.CutPrefix(valueString, "base64enc:"); found {
|
||||
decodedValue, err := base64.StdEncoding.DecodeString(encodedValue)
|
||||
if err != nil {
|
||||
return data, fmt.Errorf("Error decoding base64: %w", err)
|
||||
}
|
||||
data[key] = strings.TrimSpace(string(decodedValue))
|
||||
}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user