diff --git a/apis/fluentd/v1alpha1/plugins/secret_types.go b/apis/fluentd/v1alpha1/plugins/secret_types.go index 162835037..d633158ce 100644 --- a/apis/fluentd/v1alpha1/plugins/secret_types.go +++ b/apis/fluentd/v1alpha1/plugins/secret_types.go @@ -23,19 +23,23 @@ type ValueSource struct { SecretKeyRef corev1.SecretKeySelector `json:"secretKeyRef,omitempty"` } -type SecretLoader struct { +type SecretLoader interface { + LoadSecret(s Secret) (string, error) +} + +type SecretLoaderStruct struct { client client.Client namespace string } func NewSecretLoader(c client.Client, ns string, l logr.Logger) SecretLoader { - return SecretLoader{ + return SecretLoaderStruct{ client: c, namespace: ns, } } -func (sl SecretLoader) LoadSecret(s Secret) (string, error) { +func (sl SecretLoaderStruct) LoadSecret(s Secret) (string, error) { var secret corev1.Secret if err := sl.client.Get(context.Background(), client.ObjectKey{Name: s.ValueFrom.SecretKeyRef.Name, Namespace: sl.namespace}, &secret); err != nil { return "", err diff --git a/apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-loki.cfg b/apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-loki.cfg index 64c3f6304..d0e4fd1bb 100644 --- a/apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-loki.cfg +++ b/apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-loki.cfg @@ -30,8 +30,11 @@ extract_kubernetes_labels true include_thread_label true insecure_tls true + password s3cr3tP@ssword remove_keys key31,key32 + tenant 0c3ba7a4-3148-4605-b62a-afc92dd1c4d7 url http://loki-logging-data.kubesphere-logging-system.svc:3100 + username s3cr3tUsern4me