From 98901a490a6730cb2140f3ad9ead50b00ae47a8e Mon Sep 17 00:00:00 2001 From: akvlad Date: Thu, 17 Oct 2024 12:48:12 +0300 Subject: [PATCH] take secrets back --- common/config/qryn.go | 15 ++++++++------- common/config/qryn_oss.go | 3 +-- destinations/data/qryn.yaml | 1 + destinations/data/qrynoss.yaml | 1 + 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/common/config/qryn.go b/common/config/qryn.go index df77a7c6e..bc0ea0d5d 100644 --- a/common/config/qryn.go +++ b/common/config/qryn.go @@ -11,19 +11,19 @@ import ( const ( qrynHost = "QRYN_URL" qrynAPIKey = "QRYN_API_KEY" - qrynAPISecret = "QRYN_API_SECRET" qrynAddExporterName = "QRYN_ADD_EXPORTER_NAME" resourceToTelemetryConversion = "QRYN_RESOURCE_TO_TELEMETRY_CONVERSION" qrynSecretsOptional = "__QRYN_SECRETS_OPTIONAL__" + qrynPasswordFieldName = "__QRYN_PASSWORD_FIELD_NAME__" ) type qrynConf struct { host string key string - secret string addExporterName bool resourceToTelemetryConversion bool secretsOptional bool + passwordFieldName string } type Qryn struct{} @@ -39,7 +39,11 @@ func (g *Qryn) ModifyConfig(dest ExporterConfigurer, currentConfig *Config) erro return err } - baseURL, err := parseURL(dest.GetConfig()[qrynHost], conf.key, conf.secret) + passwordPlaceholder := "${QRYN_API_SECRET}" + if conf.passwordFieldName != "" { + passwordPlaceholder = "${" + conf.passwordFieldName + "}" + } + baseURL, err := parseURL(dest.GetConfig()[qrynHost], conf.key, passwordPlaceholder) if err != nil { return errors.New("API host is not a valid") } @@ -120,10 +124,10 @@ func (g *Qryn) getConfigs(dest ExporterConfigurer) qrynConf { return qrynConf{ host: dest.GetConfig()[qrynHost], key: dest.GetConfig()[qrynAPIKey], - secret: dest.GetConfig()[qrynAPISecret], addExporterName: dest.GetConfig()[qrynAddExporterName] == "Yes", resourceToTelemetryConversion: dest.GetConfig()[resourceToTelemetryConversion] == "Yes", secretsOptional: dest.GetConfig()[qrynSecretsOptional] == "1", + passwordFieldName: dest.GetConfig()[qrynPasswordFieldName], } } @@ -134,9 +138,6 @@ func (g *Qryn) checkConfigs(conf *qrynConf) error { if !conf.secretsOptional && conf.key == "" { return errors.New("missing API key") } - if !conf.secretsOptional && conf.secret == "" { - return errors.New("missing API secret") - } return nil } diff --git a/common/config/qryn_oss.go b/common/config/qryn_oss.go index 03e1bbacf..b09b306d5 100644 --- a/common/config/qryn_oss.go +++ b/common/config/qryn_oss.go @@ -7,7 +7,6 @@ import ( const ( qrynOssHost = "QRYN_OSS_URL" qrynOssUsername = "QRYN_OSS_USERNAME" - qrynOssPassword = "QRYN_OSS_PASSWORD" qrynOssresourceToTelemetryConversion = "QRYN_OSS_RESOURCE_TO_TELEMETRY_CONVERSION" qrynOssAddExporterName = "QRYN_OSS_ADD_EXPORTER_NAME" ) @@ -24,10 +23,10 @@ func (d QrynOssDest) GetConfig() map[string]string { conf := d.ExporterConfigurer.GetConfig() conf[qrynHost] = conf[qrynOssHost] conf[qrynAPIKey] = conf[qrynOssUsername] - conf[qrynAPISecret] = conf[qrynOssPassword] conf[resourceToTelemetryConversion] = conf[qrynOssresourceToTelemetryConversion] conf[qrynSecretsOptional] = "1" conf[qrynAddExporterName] = conf[qrynOssAddExporterName] + conf[qrynPasswordFieldName] = "QRYN_OSS_PASSWORD" return conf } diff --git a/destinations/data/qryn.yaml b/destinations/data/qryn.yaml index 7307366a8..e8ef742ef 100644 --- a/destinations/data/qryn.yaml +++ b/destinations/data/qryn.yaml @@ -20,6 +20,7 @@ spec: componentProps: type: password required: true + secret: true - name: QRYN_API_KEY displayName: API Key componentType: input diff --git a/destinations/data/qrynoss.yaml b/destinations/data/qrynoss.yaml index f5c4b588e..2d1cfc062 100644 --- a/destinations/data/qrynoss.yaml +++ b/destinations/data/qrynoss.yaml @@ -19,6 +19,7 @@ spec: componentType: input componentProps: type: password + secret: true - name: QRYN_OSS_USERNAME displayName: Basic auth username componentType: input