Skip to content

Commit 7e2bd93

Browse files
committed
feat: getting datadog api key from kubernetes secret.
Signed-off-by: Sudipto Baral <sudiptobaral.me@gmail.com>
1 parent b3d14eb commit 7e2bd93

File tree

1 file changed

+13
-2
lines changed
  • metrics-operator/controllers/common/providers/datadog

1 file changed

+13
-2
lines changed

metrics-operator/controllers/common/providers/datadog/datadog.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ func (d *KeptnDataDogProvider) EvaluateQuery(ctx context.Context, metric metrics
2626
ctx, cancel := context.WithTimeout(ctx, 20*time.Second)
2727
defer cancel()
2828

29+
apiKey, err := getDDSecret(ctx, provider, d.K8sClient)
30+
if err != nil {
31+
return "", nil, err
32+
}
33+
2934
// TODO: get DD_API_KEY and DD_APP_KEY from kubernetes secret
3035
// TODO: patch the context with the keys
3136
// Ref: https://github.com/DataDog/datadog-api-client-go#getting-started
@@ -35,13 +40,19 @@ func (d *KeptnDataDogProvider) EvaluateQuery(ctx context.Context, metric metrics
3540
datadog.ContextAPIKeys,
3641
map[string]datadog.APIKey{
3742
"apiKeyAuth": {
38-
Key: "DD_API_KEY",
43+
Key: apiKey,
3944
},
4045
"appKeyAuth": {
41-
Key: "DD_APP_KEY",
46+
Key: "value", // TODO: get this value from kubernetes secret.
4247
},
4348
},
4449
)
50+
ctx = context.WithValue(ctx,
51+
datadog.ContextServerVariables,
52+
map[string]string{
53+
"site": provider.Spec.TargetServer,
54+
},
55+
)
4556
fromTime := time.Now().AddDate(0, 0, -1)
4657
queryTime := time.Now()
4758

0 commit comments

Comments
 (0)