-
Notifications
You must be signed in to change notification settings - Fork 77
Keep config.yaml file if existing #139
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
Conversation
|
Sync'ed with @qingling128. We need to make consistency among Linux and Windows. Thus default-config.yaml isn't necessary to have in this case. I will remove it in next commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had some unsent comments on older commits… If you find you want to address them, we can do that in a follow-up PR.
pkg/goo/maint.ps1
Outdated
| $InstallDir = [regex]::Replace($InstallDir,'^<([^>]+)>',$envFromMatch) | ||
|
|
||
| $configFilePath = "$InstallDir\config\config.yaml" | ||
| if (-not(Test-Path -Path $configFilePath -PathType Leaf)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a space after -not.
pkg/goo/maint.ps1
Outdated
| Write-Host "The file [$configFilePath] has been created." | ||
| } | ||
| catch { | ||
| throw $_.Exception.Message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why catch and rethrow, when you can just let it propagate naturally?
pkg/goo/maint.ps1
Outdated
| if (-not(Test-Path -Path $configFilePath -PathType Leaf)) { | ||
| try { | ||
| Copy-Item -Path "$InstallDir\config\default-config.yaml" -Destination $configFilePath | ||
| Write-Host "The file [$configFilePath] has been created." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like Copied default config into [$configFilePath].?
pkg/goo/maint.ps1
Outdated
| } | ||
| } | ||
| else { | ||
| Write-Host "Keep [$configFilePath] as-is because a file with that name already exists." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not worth adding this message…
pkg/goo/maint.ps1
Outdated
| $InstallDir = [regex]::Replace($InstallDir,'^<([^>]+)>',$envFromMatch) | ||
|
|
||
| $configFilePath = "$InstallDir\config\config.yaml" | ||
| if (-not(Test-Path -Path $configFilePath -PathType Leaf)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Careful — this will run both when $Action is "install" and when $Action is "uninstall". You probably want to run it only in the "install" case.
Test when there is no config file
Test when there is config file
ToDOO
work with jimmy on documenting the caveat for previous versions as a known issue SGTM. e.g. a note in https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/installation#upgrade and https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/transition#migrate_preview
later after we have at least two versions of ops-agent that contains this change, we can add a testcase in ops-agent-test.go for checking if existing config file is kept untouched.