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

fix: config dir default empty #1376

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
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: 3 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,13 @@ func (c Config) Write(path string) (err error) {

// Dir is derived in the following order, from lowest
// to highest precedence.
// 1. The static default is DefaultConfigPath (./.config/func)
// 1. The default path is the zero value, indicating "no config path available",
// and users of this package should act accordingly.
// 2. ~/.config/func if it exists (can be expanded: user has a home dir)
// 3. The value of $XDG_CONFIG_PATH/func if the environment variable exists.
// The path is created if it does not already exist.
func Dir() (path string) {
// default path is a relative path used in the unlikely event that
// the user has no home directory (no ~), there is no
// XDG_CONFIG_HOME set
path = filepath.Join(".config", "func")

// ~/.config/func is the default if ~ can be expanded
// Use home if available
if home, err := os.UserHomeDir(); err == nil {
path = filepath.Join(home, ".config", "func")
}
Expand Down
1 change: 1 addition & 0 deletions docker/creds/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ func TestNewCredentialsProvider(t *testing.T) {
}

func TestNewCredentialsProviderEmptyCreds(t *testing.T) {
withCleanHome(t)
credentialsProvider := creds.NewCredentialsProvider(testConfigPath(t), creds.WithVerifyCredentials(func(ctx context.Context, image string, credentials docker.Credentials) error {
if image == "localhost:5555/someorg/someimage:sometag" && credentials == (docker.Credentials{}) {
return nil
Expand Down