- 
                Notifications
    You must be signed in to change notification settings 
- Fork 69
Deprecate -endpoint flag #235
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
This removes the documentation of the endpoint flag but still allows it to be used to override either the config or ennvironment variables.
| What is the original purpose of removing this (especially if we're hardening it with tests in this PR)? | 
| i'm using it here sourcegraph/deploy-sourcegraph#687 | 
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.
Approve the code, but addressing @efritz question in the PR description and links to tickets etc. would be great to have :)
| oldToken := os.Getenv("SRC_ACCESS_TOKEN") | ||
| defer func() { os.Setenv("SRC_ACCESS_TOKEN", oldToken) }() | ||
| oldEndpoint := os.Getenv("SRC_ENDPOINT") | ||
| defer func() { os.Setenv("SRC_ENDPOINT", oldEndpoint) }() | ||
|  | ||
| if err := os.Setenv("SRC_ACCESS_TOKEN", test.envToken); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.Setenv("SRC_ENDPOINT", test.envEndpoint); err != nil { | ||
| t.Fatal(err) | ||
| } | 
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.
Maybe a bit easier to parse visually and read 😄 But, I was in the mood to write a tiny function just now, feel free to ignore:
| oldToken := os.Getenv("SRC_ACCESS_TOKEN") | |
| defer func() { os.Setenv("SRC_ACCESS_TOKEN", oldToken) }() | |
| oldEndpoint := os.Getenv("SRC_ENDPOINT") | |
| defer func() { os.Setenv("SRC_ENDPOINT", oldEndpoint) }() | |
| if err := os.Setenv("SRC_ACCESS_TOKEN", test.envToken); err != nil { | |
| t.Fatal(err) | |
| } | |
| if err := os.Setenv("SRC_ENDPOINT", test.envEndpoint); err != nil { | |
| t.Fatal(err) | |
| } | |
| setEnvVar := func(name, val string) { | |
| old := os.Getenv(name) | |
| if err := os.Setenv(name, val); err != nil { | |
| t.Fatal(err) | |
| } | |
| t.Cleanup(func() { os.Setenv(name, old) }) | |
| } | |
| setEnvVar("SRC_ACCESS_TOKEN", test.envToken) | |
| setEnvVar("SRC_ENDPOINT", test.envEndpoint) | 
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| return filePath, func() { os.RemoveAll(tmpDir) } | 
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.
Since you already have t at hand, you could do this:
| return filePath, func() { os.RemoveAll(tmpDir) } | |
| t.Cleanup(func() { os.RemoveAll(tmpDir) }) | |
| return filePath | 
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.
I used t.Cleanup originally but src-cli is using an older version of Go in the build pipeline.
Let me check how easy it is to update that
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.
See comments and commits, I couldn't get Appveyor to use Go 1.14
Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
This reverts commit 5f86ece.
Apparently Go 1.14.3 is installed by default: https://www.appveyor.com/docs/windows-images-software/#golang
| Nothing I've tried seems to get Appveyor to use Go 1.14 so I'm giving up for now and I'll create an issue | 
* Deprecate -endpoint flag This removes the documentation of the endpoint flag but still allows it to be used to override either the config or ennvironment variables. * Update changelog. * Update cmd/src/main.go Co-authored-by: Thorsten Ball <mrnugget@gmail.com> * Clean up CHANGELOG * Use t.Cleanup * Use Go 1.14 * Use Go 1.14 in Travis too * Try specific version of Go for Appveyor * Try example appveyor.yml * Revert "Try example appveyor.yml" This reverts commit 5f86ece. * One more attempt, use different GOPATH Apparently Go 1.14.3 is installed by default: https://www.appveyor.com/docs/windows-images-software/#golang * Revert back to being Go 1.13 compatible Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
This removes the documentation of the endpoint flag but still allows it
to be used to override either the config or ennvironment variables.