Skip to content

Commit

Permalink
Fixed & refactored linting issues in databricks package
Browse files Browse the repository at this point in the history
  • Loading branch information
stikkireddy committed Apr 20, 2020
1 parent 67dca86 commit 08e3eb7
Show file tree
Hide file tree
Showing 26 changed files with 273 additions and 251 deletions.
15 changes: 10 additions & 5 deletions databricks/azure_ws_init.go
Expand Up @@ -7,11 +7,13 @@ import (
"net/http"
)

// List of management information
const (
ManagementResourceEndpoint string = "https://management.core.windows.net/"
ADBResourceID string = "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d"
)

// AzureAuth is a struct that contains information about the azure sp authentication
type AzureAuth struct {
TokenPayload *TokenPayload
ManagementToken string
Expand All @@ -20,21 +22,24 @@ type AzureAuth struct {
AdbPlatformToken string
}

// TokenPayload contains all the auth information for azure sp authentication
type TokenPayload struct {
ManagedResourceGroup string
AzureRegion string
WorkspaceName string
ResourceGroup string
SubscriptionId string
SubscriptionID string
ClientSecret string
ClientID string
TenantID string
}

// WsProps contains information about the workspace properties
type WsProps struct {
ManagedResourceGroupID string `json:"managedResourceGroupId"`
}

// WorkspaceRequest contains the request information for getting workspace information
type WorkspaceRequest struct {
Properties *WsProps `json:"properties"`
Name string `json:"name"`
Expand Down Expand Up @@ -63,13 +68,13 @@ func (a *AzureAuth) getManagementToken(config *service.DBApiClientConfig) error
return nil
}

func (a *AzureAuth) getWorkspaceId(config *service.DBApiClientConfig) error {
func (a *AzureAuth) getWorkspaceID(config *service.DBApiClientConfig) error {
log.Println("[DEBUG] Getting Workspace ID via management token.")
url := "https://management.azure.com/subscriptions/" + a.TokenPayload.SubscriptionId + "/resourceGroups/" + a.TokenPayload.ResourceGroup + "/providers/Microsoft.Databricks/workspaces/" + a.TokenPayload.WorkspaceName + "" +
url := "https://management.azure.com/subscriptions/" + a.TokenPayload.SubscriptionID + "/resourceGroups/" + a.TokenPayload.ResourceGroup + "/providers/Microsoft.Databricks/workspaces/" + a.TokenPayload.WorkspaceName + "" +
"?api-version=2018-04-01"

payload := &WorkspaceRequest{
Properties: &WsProps{ManagedResourceGroupID: "/subscriptions/" + a.TokenPayload.SubscriptionId + "/resourceGroups/" + a.TokenPayload.ManagedResourceGroup},
Properties: &WsProps{ManagedResourceGroupID: "/subscriptions/" + a.TokenPayload.SubscriptionID + "/resourceGroups/" + a.TokenPayload.ManagedResourceGroup},
Name: a.TokenPayload.WorkspaceName,
Location: a.TokenPayload.AzureRegion,
}
Expand Down Expand Up @@ -157,7 +162,7 @@ func (a *AzureAuth) initWorkspaceAndGetClient(config *service.DBApiClientConfig)
return dbClient, err
}

err = a.getWorkspaceId(config)
err = a.getWorkspaceID(config)
if err != nil {
return dbClient, err
}
Expand Down
2 changes: 1 addition & 1 deletion databricks/azure_ws_init_test.go
Expand Up @@ -33,7 +33,7 @@ func TestAzureAuthCreateApiToken(t *testing.T) {
AdbAccessToken: "",
AdbPlatformToken: "",
}
azureAuth.TokenPayload.SubscriptionId = os.Getenv("ARM_SUBSCRIPTION_ID")
azureAuth.TokenPayload.SubscriptionID = os.Getenv("ARM_SUBSCRIPTION_ID")
azureAuth.TokenPayload.TenantID = os.Getenv("ARM_TENANT_ID")
azureAuth.TokenPayload.ClientID = os.Getenv("ARM_CLIENT_ID")
azureAuth.TokenPayload.ClientSecret = os.Getenv("ARM_CLIENT_SECRET")
Expand Down

0 comments on commit 08e3eb7

Please sign in to comment.