Skip to content

Commit

Permalink
adding viper SetConfigType for SecAgent config merge func
Browse files Browse the repository at this point in the history
wip

removing non functional change to remove agent-shared-components as required reviewer
  • Loading branch information
modernplumbing committed Dec 26, 2022
1 parent 0ba212d commit 42a8148
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/security-agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,27 @@ package config
import (
"fmt"
"os"
"path/filepath"

aconfig "github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/util/log"
)

// Merge will merge the security-agent configuration into the existing datadog configuration
func Merge(configPaths []string) error {
// TODO: Unify with System Probe config merge fnc
// TODO: This code is not actually hit at the moment due to the MergeConfigurationFiles fnc. This will be used post-fx refactor.
for _, configPath := range configPaths {
if f, err := os.Open(configPath); err == nil {
err = aconfig.Datadog.MergeConfig(f)
configFileExtension := filepath.Ext(configPath)
if !(configFileExtension == ".yaml" || configFileExtension == ".yml") {
log.Warnf("Security Agent config file is not a yaml file. May not merge properly.")
} else {
log.Infof("Security Agent config setup is setting Datadog Agent config type to yaml.")
config.Datadog.SetConfigType("yaml")
}

err = config.Datadog.MergeConfig(f)
_ = f.Close()
if err != nil {
return fmt.Errorf("error merging %s config file: %w", configPath, err)
Expand Down

0 comments on commit 42a8148

Please sign in to comment.