Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nfx committed Feb 17, 2023
1 parent 9c8eab6 commit 22b9012
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 15 additions & 5 deletions common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ func (c *DatabricksClient) Put(ctx context.Context, path string, request any) er
return c.Do(ctx, http.MethodPut, path, request, nil, c.addApiPrefix)
}

type apiVersion string
type ApiVersion string

const (
API_1_2 apiVersion = "1.2"
API_2_0 apiVersion = "2.0"
API_2_1 apiVersion = "2.1"
API_1_2 ApiVersion = "1.2"
API_2_0 ApiVersion = "2.0"
API_2_1 ApiVersion = "2.1"
)

func (c *DatabricksClient) addApiPrefix(r *http.Request) error {
if r.URL == nil {
return fmt.Errorf("no URL found in request")
}
ctx := r.Context()
av, ok := ctx.Value(Api).(apiVersion)
av, ok := ctx.Value(Api).(ApiVersion)
if !ok {
av = API_2_0
}
Expand Down Expand Up @@ -192,3 +192,13 @@ func (aa *DatabricksClient) GetAzureJwtProperty(key string) (any, error) {
}
return v, nil
}

func CommonEnvironmentClient() *DatabricksClient {
c, err := client.New(&config.Config{})
if err != nil {
panic(err)
}
return &DatabricksClient{
DatabricksClient: c,
}
}
1 change: 0 additions & 1 deletion exporter/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func newImportContext(c *common.DatabricksClient) *importContext {
p := provider.DatabricksProvider()
p.TerraformVersion = "exporter"
p.SetMeta(c)
c.Provider = p
ctx := context.WithValue(context.Background(), common.Provider, p)
ctx = context.WithValue(ctx, common.ResourceName, "exporter")
c.WithCommandExecutor(func(
Expand Down

0 comments on commit 22b9012

Please sign in to comment.