Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add double quotes for Windows Package #490

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packaging/windows/amazon-cloudwatch-agent-ctl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Function AgentStart() {
if (!$svc) {
$startCommand = "`"${CWAProgramFiles}\start-amazon-cloudwatch-agent.exe`""
if (${service_name} -eq $CWOCServiceName) {
$startCommand = "`"${CWAProgramFiles}\cwagent-otel-collector.exe`" --config=${YAML}"
$startCommand = "`"${CWAProgramFiles}\cwagent-otel-collector.exe`" --config=`"${YAML}`""
}
New-Service -Name "${service_name}" -DisplayName "${service_display_name}" -Description "${service_display_name}" -DependsOn LanmanServer -BinaryPathName "${startCommand}" | Out-Null
# object returned by New-Service gives errors so retrieve it again
Expand Down Expand Up @@ -363,7 +363,7 @@ Function CWAConfig() {
if ($ConfigLocation -eq $AllConfig) {
Remove-Item -Path "${JSON_DIR}\*" -Force -ErrorAction SilentlyContinue
} else {
& cmd /c "`"$CWAProgramFiles\config-downloader.exe`" --output-dir ${JSON_DIR} --download-source ${ConfigLocation} --mode ${param_mode} --config ${COMMON_CONIG} --multi-config ${multi_config} 2>&1"
& cmd /c "`"$CWAProgramFiles\config-downloader.exe`" --output-dir `"${JSON_DIR}`" --download-source `"${ConfigLocation}`" --mode ${param_mode} --config `"${COMMON_CONIG}`" --multi-config ${multi_config} 2>&1"
CheckCMDResult # Exit immediately if config-downloader outputs any error
}

Expand All @@ -374,13 +374,13 @@ Function CWAConfig() {
Remove-Item "${TOML}" -Force -ErrorAction SilentlyContinue
} else {
Write-Output "Start configuration validation..."
& cmd /c "`"$CWAProgramFiles\config-translator.exe`" --input ${JSON} --input-dir ${JSON_DIR} --output ${TOML} --mode ${param_mode} --config ${COMMON_CONIG} --multi-config ${multi_config} 2>&1"
& cmd /c "`"$CWAProgramFiles\config-translator.exe`" --input `"${JSON}`" --input-dir `"${JSON_DIR}`" --output `"${TOML}`" --mode ${param_mode} --config `"${COMMON_CONIG}`" --multi-config ${multi_config} 2>&1"
CheckCMDResult # Exit immediately if config-translator outputs any error

# Set ErrorActionPreference as Continue to continue on error when schema-test on toml file fails and
# return a UX-friendly message
$ErrorActionPreference = "Continue"
& cmd /c "`"${CWAProgramFiles}\amazon-cloudwatch-agent.exe`" --schematest --config ${TOML} 2>&1" | Out-File $CVLogFile
& cmd /c "`"${CWAProgramFiles}\amazon-cloudwatch-agent.exe`" --schematest --config `"${TOML}`" 2>&1" | Out-File $CVLogFile
if ($LASTEXITCODE -ne 0) {
Write-Output "Configuration validation second phase failed"
Write-Output "======== Error Log ========"
Expand Down Expand Up @@ -451,7 +451,7 @@ Function CWOCConfig() {
Copy-Item "${PREDEFINED_CONFIG_DATA}" -Destination "${YAML_DIR}/default.tmp"
Write-Output "Successfully fetched the config and saved in ${YAML_DIR}\default.tmp"
} else {
& cmd /c "`"$CWAProgramFiles\config-downloader.exe`" --output-dir ${YAML_DIR} --download-source ${OtelConfigLocation} --mode ${param_mode} --config ${COMMON_CONIG} --multi-config ${multi_config} 2>&1"
& cmd /c "`"$CWAProgramFiles\config-downloader.exe`" --output-dir `"${YAML_DIR}`" --download-source `"${OtelConfigLocation}`" --mode ${param_mode} --config `"${COMMON_CONIG}`" --multi-config ${multi_config} 2>&1"
# Use return instead of exit since CWAgent and ADOT Collector should be two independent agents as much as possible
if ($LASTEXITCODE -ne 0) {
return
Expand Down