Skip to content

Commit

Permalink
Support scrapt paths for Linux,MacOs
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhntd committed Jun 24, 2022
1 parent 4ae77f1 commit ca3b885
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
12 changes: 2 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ GOIMPORTS_OPT?= -w -local $(CW_AGENT_IMPORT_PATH)
GOIMPORTS = $(TOOLS_BIN_DIR)/goimports
SHFMT = $(TOOLS_BIN_DIR)/shfmt
LINTER = $(TOOLS_BIN_DIR)/golangci-lint
release: clean test build package-rpm package-deb package-win package-darwin
release: clean build package-rpm package-deb

nightly-release: release

build: check_secrets cwagent-otel-collector amazon-cloudwatch-agent config-translator start-amazon-cloudwatch-agent amazon-cloudwatch-agent-config-wizard config-downloader
build: cwagent-otel-collector amazon-cloudwatch-agent config-translator start-amazon-cloudwatch-agent amazon-cloudwatch-agent-config-wizard config-downloader

check_secrets::
if grep --exclude-dir=build --exclude-dir=vendor -E "(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}|(\"|')?(AWS|aws|Aws)?_?(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)(\"|')?\\s*(:|=>|=)\\s*(\"|')?[A-Za-z0-9/\\+=]{40}(\"|')?" -Rn .; then echo "check_secrets failed"; exit 1; fi;
Expand Down Expand Up @@ -91,29 +91,21 @@ config-translator: copy-version-file
@echo Building config-translator
$(LINUX_AMD64_BUILD)/config-translator github.com/aws/amazon-cloudwatch-agent/cmd/config-translator
$(LINUX_ARM64_BUILD)/config-translator github.com/aws/amazon-cloudwatch-agent/cmd/config-translator
$(WIN_BUILD)/config-translator.exe github.com/aws/amazon-cloudwatch-agent/cmd/config-translator
$(DARWIN_BUILD)/config-translator github.com/aws/amazon-cloudwatch-agent/cmd/config-translator

start-amazon-cloudwatch-agent: copy-version-file
@echo Building start-amazon-cloudwatch-agent
$(LINUX_AMD64_BUILD)/start-amazon-cloudwatch-agent github.com/aws/amazon-cloudwatch-agent/cmd/start-amazon-cloudwatch-agent
$(LINUX_ARM64_BUILD)/start-amazon-cloudwatch-agent github.com/aws/amazon-cloudwatch-agent/cmd/start-amazon-cloudwatch-agent
$(WIN_BUILD)/start-amazon-cloudwatch-agent.exe github.com/aws/amazon-cloudwatch-agent/cmd/start-amazon-cloudwatch-agent
$(DARWIN_BUILD)/start-amazon-cloudwatch-agent github.com/aws/amazon-cloudwatch-agent/cmd/start-amazon-cloudwatch-agent

amazon-cloudwatch-agent-config-wizard: copy-version-file
@echo Building amazon-cloudwatch-agent-config-wizard
$(LINUX_AMD64_BUILD)/amazon-cloudwatch-agent-config-wizard github.com/aws/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent-config-wizard
$(LINUX_ARM64_BUILD)/amazon-cloudwatch-agent-config-wizard github.com/aws/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent-config-wizard
$(WIN_BUILD)/amazon-cloudwatch-agent-config-wizard.exe github.com/aws/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent-config-wizard
$(DARWIN_BUILD)/amazon-cloudwatch-agent-config-wizard github.com/aws/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent-config-wizard

config-downloader: copy-version-file
@echo Building config-downloader
$(LINUX_AMD64_BUILD)/config-downloader github.com/aws/amazon-cloudwatch-agent/cmd/config-downloader
$(LINUX_ARM64_BUILD)/config-downloader github.com/aws/amazon-cloudwatch-agent/cmd/config-downloader
$(WIN_BUILD)/config-downloader.exe github.com/aws/amazon-cloudwatch-agent/cmd/config-downloader
$(DARWIN_BUILD)/config-downloader github.com/aws/amazon-cloudwatch-agent/cmd/config-downloader

# A fast build that only builds amd64, we don't need wizard and config downloader
build-for-docker: build-for-docker-amd64
Expand Down
3 changes: 3 additions & 0 deletions cmd/config-downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,19 @@ func main() {
switch locationArray[0] {
case locationDefault:
outputFilePath = locationDefault
log.Printf("Abot",outputFilePath)
if multiConfig != "remove" {
config, err = defaultJsonConfig(mode)
}
case locationSSM:
outputFilePath = locationSSM + "_" + EscapeFilePath(locationArray[1])
log.Printf("Read",outputFilePath)
if multiConfig != "remove" {
config, err = downloadFromSSM(region, locationArray[1], mode, cc.CredentialsMap())
}
case locationFile:
outputFilePath = locationFile + "_" + EscapeFilePath(filepath.Base(locationArray[1]))
log.Printf("Test",outputFilePath)
if multiConfig != "remove" {
config, err = readFromFile(locationArray[1])
}
Expand Down
10 changes: 4 additions & 6 deletions packaging/dependencies/amazon-cloudwatch-agent-ctl
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,17 @@ cwa_config() {
if [ "${cwa_config_location}" = "${ALL_CONFIG}" ]; then
rm -rf "${JSON_DIR}"/*
else
runDownloaderCommand="${CMDDIR}/config-downloader --output-dir ${JSON_DIR} --download-source ${cwa_config_location} --mode ${param_mode} --config ${COMMON_CONIG} --multi-config ${multi_config}"
echo "${runDownloaderCommand}"
${runDownloaderCommand} || return
runDownloaderCommand=`"${CMDDIR}/config-downloader" --output-dir "${JSON_DIR}" --download-source "${cwa_config_location}" --mode ${param_mode} --config "${COMMON_CONIG}" --multi-config ${multi_config}`
echo "${runDownloaderCommand}" || return
fi

if [ ! "$(ls ${JSON_DIR})" ]; then
echo "all amazon-cloudwatch-agent configurations have been removed"
rm -f "${TOML}"
else
echo "Start configuration validation..."
runTranslatorCommand="${CMDDIR}/config-translator --input ${JSON} --input-dir ${JSON_DIR} --output ${TOML} --mode ${param_mode} --config ${COMMON_CONIG} --multi-config ${multi_config}"
echo "${runTranslatorCommand}"
${runTranslatorCommand} || return
runTranslatorCommand=`"${CMDDIR}/config-translator" --input "${JSON}" --input-dir "${JSON_DIR}" --output "${TOML}" --mode ${param_mode} --config "${COMMON_CONIG}" --multi-config ${multi_config}`
echo "${runTranslatorCommand}" || return

runAgentSchemaTestCommand="${CMDDIR}/amazon-cloudwatch-agent -schematest -config ${TOML}"
echo "${runAgentSchemaTestCommand}"
Expand Down

0 comments on commit ca3b885

Please sign in to comment.