Skip to content

Commit

Permalink
fix: support datadog plugin api key to allow for secret injection
Browse files Browse the repository at this point in the history
Signed-off-by: nitintecg <[email protected]>
  • Loading branch information
nitintecg committed Feb 21, 2024
1 parent 2f254cc commit 33950aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 7 additions & 3 deletions apis/fluentbit/v1alpha2/plugins/output/datadog_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type DataDog struct {
// Datadog supports and recommends setting this to gzip.
Compress string `json:"compress,omitempty"`
// Your Datadog API key.
APIKey string `json:"apikey,omitempty"`
APIKey *plugins.Secret `json:"apikey,omitempty"`
// Specify an HTTP Proxy.
Proxy string `json:"proxy,omitempty"`
// To activate the remapping, specify configuration flag provider.
Expand Down Expand Up @@ -61,8 +61,12 @@ func (s *DataDog) Params(sl plugins.SecretLoader) (*params.KVs, error) {
if s.Compress != "" {
kvs.Insert("compress", s.Compress)
}
if s.APIKey != "" {
kvs.Insert("apikey", s.APIKey)
if s.APIKey != nil {
apiKey, err := sl.LoadSecret(*s.APIKey)
if err != nil {
return nil, err
}
kvs.Insert("apikey", apiKey)
}
if s.Proxy != "" {
kvs.Insert("proxy", s.Proxy)
Expand Down
2 changes: 0 additions & 2 deletions apis/fluentbit/v1alpha2/plugins/output/datadog_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func TestOutput_DataDog_Params(t *testing.T) {

dd := DataDog{
Host: "http-intake.logs.datadoghq.com",
APIKey: "1234apikey",
TLS: ptrBool(true),
Compress: "gzip",
Service: "service_name",
Expand All @@ -31,7 +30,6 @@ func TestOutput_DataDog_Params(t *testing.T) {
expected.Insert("Host", "http-intake.logs.datadoghq.com")
expected.Insert("TLS", "true")
expected.Insert("compress", "gzip")
expected.Insert("apikey", "1234apikey")
expected.Insert("json_date_key", "timestamp")
expected.Insert("include_tag_key", "true")
expected.Insert("tag_key", "tagkey")
Expand Down

0 comments on commit 33950aa

Please sign in to comment.