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:
Jose Diaz-Gonzalez
2025-08-23 15:46:57 -04:00
parent d4484d0373
commit 9c41bed78b
4 changed files with 62 additions and 0 deletions

View File

@@ -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
}