Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
mgyucht committed Nov 23, 2023
1 parent d9fe2ab commit 5ed7580
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package auth

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -131,7 +132,8 @@ func setHost(ctx context.Context, profileName string, persistentAuth *auth.Persi
_, profiles, err := databrickscfg.LoadProfiles(ctx, func(p databrickscfg.Profile) bool {
return p.Name == profileName
})
if err != nil {
// Tolerate ErrNoConfiguration here, as we will write out a configuration as part of the login flow.
if !errors.Is(err, databrickscfg.ErrNoConfiguration) {
return err
}
if persistentAuth.Host == "" {
Expand Down
17 changes: 17 additions & 0 deletions cmd/auth/login_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package auth

import (
"context"
"testing"

"github.com/databricks/cli/libs/auth"
"github.com/databricks/cli/libs/env"
"github.com/stretchr/testify/assert"
)

func TestSetHostDoesNotFailWithNoDatabrickscfg(t *testing.T) {
ctx := context.Background()
ctx = env.Set(ctx, "DATABRICKS_CONFIG_FILE", "./imaginary-file/databrickscfg")
err := setHost(ctx, "foo", &auth.PersistentAuth{Host: "test"}, []string{})
assert.NoError(t, err)
}

0 comments on commit 5ed7580

Please sign in to comment.