Repository navigation
fix(installer): vendor CLI installs with CONFIG_URL #225
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b6941b8
fix(installer): put vendor CLIs on the PATH, and propagate command fa…
pjcdawkins b5707fe
test(installer): test CONFIG_URL installs in containers
pjcdawkins faddc56
fix(installer): share root installs of vendor CLIs with other users
pjcdawkins 596ddca
fix(installer): handle symlinked bin directories and restrictive umasks
pjcdawkins fd809d6
fix(config): keep a config file's mode when updating it
pjcdawkins 32e8fad
fix(installer): put shared vendor configs in /etc/upsun/platform-alt
pjcdawkins d7e20fe
fix: address review of vendor CLI installs
pjcdawkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| //go:build unix | ||
|
|
||
| package alt_test | ||
|
|
||
| import ( | ||
| "context" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "os" | ||
| "path/filepath" | ||
| "syscall" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/upsun/cli/internal/config" | ||
| "github.com/upsun/cli/internal/config/alt" | ||
| ) | ||
|
|
||
| // TestUpdateKeepsMode checks that an update keeps a shared config readable under a restrictive umask. | ||
| func TestUpdateKeepsMode(t *testing.T) { | ||
| tempDir := t.TempDir() | ||
| testConfigFilename := filepath.Join(tempDir, "config.yaml") | ||
| require.NoError(t, os.WriteFile(testConfigFilename, testConfig, 0o600)) | ||
| require.NoError(t, os.Chmod(testConfigFilename, 0o644)) | ||
| hourAgo := time.Now().Add(-time.Hour) | ||
| require.NoError(t, os.Chtimes(testConfigFilename, hourAgo, hourAgo)) | ||
|
|
||
| cnf, err := config.FromYAML(testConfig) | ||
| require.NoError(t, err) | ||
| t.Setenv(cnf.Application.EnvPrefix+"HOME", tempDir) | ||
|
|
||
| server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { | ||
| _, _ = w.Write(testConfigWithMetadata("{version: 1.0.1}")) | ||
| })) | ||
| defer server.Close() | ||
| cnf.SourceFile = testConfigFilename | ||
| cnf.Metadata.URL = server.URL + "/config.yaml" | ||
|
|
||
| oldUmask := syscall.Umask(0o077) | ||
| defer syscall.Umask(oldUmask) | ||
|
|
||
| require.NoError(t, alt.Update(config.ToContext(context.Background(), cnf), cnf, func(string, ...any) {})) | ||
|
|
||
| stat, err := os.Stat(testConfigFilename) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, os.FileMode(0o644), stat.Mode().Perm()) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.