Skip to content

Commit

Permalink
remove unnecessary param passing
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-mateen committed Oct 6, 2023
1 parent bdd6cd4 commit 68163d2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
1 change: 0 additions & 1 deletion cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions cmd/start-amazon-cloudwatch-agent/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
22 changes: 11 additions & 11 deletions tool/paths/paths_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package paths

import "path/filepath"

const (
AgentDir = "/opt/aws/amazon-cloudwatch-agent"
BinaryDir = "bin"
Expand All @@ -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)
}
26 changes: 14 additions & 12 deletions tool/paths/paths_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

package paths

import "os"
import (
"os"
"path/filepath"
)

const (
AgentDir = "\\Amazon\\AmazonCloudWatchAgent\\"
Expand All @@ -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)
}

0 comments on commit 68163d2

Please sign in to comment.