From 68163d29f0f195943ce918bd6e467c4f3173bc70 Mon Sep 17 00:00:00 2001 From: Adam <90734270+adam-mateen@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:03:25 -0500 Subject: [PATCH] remove unnecessary param passing --- .../amazon-cloudwatch-agent.go | 1 - cmd/start-amazon-cloudwatch-agent/path.go | 2 -- tool/paths/paths_unix.go | 22 ++++++++-------- tool/paths/paths_windows.go | 26 ++++++++++--------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go b/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go index 1a94924912..e2ee07d1a3 100644 --- a/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go +++ b/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go @@ -259,7 +259,6 @@ func runAgent(ctx context.Context, logger.SetupLogging(logConfig) log.Printf("I! Starting AmazonCloudWatchAgent %s\n", agentinfo.FullVersion()) - log.Printf("I! config: %v, %v",*fConfig, *fOtelConfig) // Need to set SDK log level before plugins get loaded. // Some aws.Config objects get created early and live forever which means // we cannot change the sdk log level without restarting the Agent. diff --git a/cmd/start-amazon-cloudwatch-agent/path.go b/cmd/start-amazon-cloudwatch-agent/path.go index bf17673c52..c898844dcc 100644 --- a/cmd/start-amazon-cloudwatch-agent/path.go +++ b/cmd/start-amazon-cloudwatch-agent/path.go @@ -27,7 +27,6 @@ func startAgent(writer io.WriteCloser) error { paths.AgentBinaryPath, // when using syscall.Exec, must pass binary name as args[0] "-config", paths.TomlConfigPath, "-envconfig", paths.EnvConfigPath, - "-otelconfig", paths.YamlConfigPath, "-pidfile", paths.AgentDir + "/var/amazon-cloudwatch-agent.pid", } if err := syscall.Exec(paths.AgentBinaryPath, execArgs, os.Environ()); err != nil { @@ -65,7 +64,6 @@ func startAgent(writer io.WriteCloser) error { paths.AgentBinaryPath, "-config", paths.TomlConfigPath, "-envconfig", paths.EnvConfigPath, - "-otelconfig", paths.YamlConfigPath, "-pidfile", paths.AgentDir + "/var/amazon-cloudwatch-agent.pid", } if err = syscall.Exec(name, agentCmd, os.Environ()); err != nil { diff --git a/tool/paths/paths_unix.go b/tool/paths/paths_unix.go index b6272581fd..c59c70232a 100644 --- a/tool/paths/paths_unix.go +++ b/tool/paths/paths_unix.go @@ -6,6 +6,8 @@ package paths +import "path/filepath" + const ( AgentDir = "/opt/aws/amazon-cloudwatch-agent" BinaryDir = "bin" @@ -17,15 +19,13 @@ const ( ) func init() { - JsonConfigPath = AgentDir + "/etc/" + JSON - JsonDirPath = AgentDir + "/etc/" + JsonDir - EnvConfigPath = AgentDir + "/etc/" + ENV - TomlConfigPath = AgentDir + "/etc/" + TOML - CommonConfigPath = AgentDir + "/etc/" + COMMON_CONFIG - YamlConfigPath = AgentDir + "/etc/" + YAML - - AgentLogFilePath = AgentDir + "/logs/" + AGENT_LOG_FILE - - TranslatorBinaryPath = AgentDir + "/bin/" + TranslatorBinaryName - AgentBinaryPath = AgentDir + "/bin/" + AgentBinaryName + JsonConfigPath = filepath.Join(AgentDir, "etc", JSON) + JsonDirPath = filepath.Join(AgentDir, "etc", JsonDir) + EnvConfigPath = filepath.Join(AgentDir, "etc", ENV) + TomlConfigPath = filepath.Join(AgentDir, "etc", TOML) + CommonConfigPath = filepath.Join(AgentDir, "etc", COMMON_CONFIG) + YamlConfigPath = filepath.Join(AgentDir, "etc", YAML) + AgentLogFilePath = filepath.Join(AgentDir, "logs", AGENT_LOG_FILE) + TranslatorBinaryPath = filepath.Join(AgentDir, "bin", TranslatorBinaryName) + AgentBinaryPath = filepath.Join(AgentDir, "bin", AgentBinaryName) } diff --git a/tool/paths/paths_windows.go b/tool/paths/paths_windows.go index 009696a3ae..1234cfe77d 100644 --- a/tool/paths/paths_windows.go +++ b/tool/paths/paths_windows.go @@ -6,7 +6,10 @@ package paths -import "os" +import ( + "os" + "path/filepath" +) const ( AgentDir = "\\Amazon\\AmazonCloudWatchAgent\\" @@ -25,19 +28,18 @@ func init() { programData = os.Getenv("ProgramData") } else { // Windows 2003 - programData = os.Getenv("ALLUSERSPROFILE") + "\\Application Data" + programData = filepath.Join(os.Getenv("ALLUSERSPROFILE"), "Application Data") } AgentRootDir := programFiles + AgentDir AgentConfigDir := programData + AgentDir - - JsonConfigPath = AgentConfigDir + "\\" + JSON - JsonDirPath = AgentConfigDir + JsonDir - EnvConfigPath = AgentConfigDir + "\\" + ENV - TomlConfigPath = AgentConfigDir + "\\" + TOML - YamlConfigPath = AgentConfigDir + "\\" + YAML - CommonConfigPath = AgentConfigDir + "\\" + COMMON_CONFIG - AgentLogFilePath = AgentConfigDir + "\\Logs\\" + AGENT_LOG_FILE - TranslatorBinaryPath = AgentRootDir + "\\" + TranslatorBinaryName - AgentBinaryPath = AgentRootDir + "\\" + AgentBinaryName + JsonConfigPath = filepath.Join(AgentConfigDir, JSON) + JsonDirPath = filepath.Join(AgentConfigDir, JsonDir) + EnvConfigPath = filepath.Join(AgentConfigDir, ENV) + TomlConfigPath = filepath.Join(AgentConfigDir, TOML) + YamlConfigPath = filepath.Join(AgentConfigDir, YAML) + CommonConfigPath = filepath.Join(AgentConfigDir, COMMON_CONFIG) + AgentLogFilePath = filepath.Join(AgentConfigDir, AGENT_LOG_FILE) + TranslatorBinaryPath = filepath.Join(AgentRootDir, TranslatorBinaryName) + AgentBinaryPath = filepath.Join(AgentRootDir, AgentBinaryName) }