-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KEEP] Introduce
DatabricksEnvironment
and fix Azure MSI auth from …
…ACR, where IMDS doesn't give host environment information
- Loading branch information
Showing
7 changed files
with
107 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,56 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type Cloud string | ||
|
||
const ( | ||
CloudUnspecified Cloud = "Unspecified" | ||
CloudAWS Cloud = "AWS" | ||
CloudAzure Cloud = "Azure" | ||
CloudGCP Cloud = "GCP" | ||
) | ||
|
||
type DatabricksEnvironment struct { | ||
Cloud Cloud | ||
DnsZone string | ||
AzureApplicationID string | ||
AzureEnvironment *azureEnvironment | ||
} | ||
|
||
func (de DatabricksEnvironment) DeploymentURL(name string) string { | ||
return fmt.Sprintf("https://%s%s", name, de.DnsZone) | ||
} | ||
|
||
var envs = []DatabricksEnvironment{ | ||
{Cloud: CloudUnspecified, DnsZone: "localhost"}, | ||
|
||
{Cloud: CloudAWS, DnsZone: ".dev.databricks.com"}, | ||
{Cloud: CloudAWS, DnsZone: ".staging.cloud.databricks.com"}, | ||
{Cloud: CloudAWS, DnsZone: ".cloud.databricks.com"}, | ||
{Cloud: CloudAWS, DnsZone: ".cloud.databricks.us"}, | ||
|
||
{Cloud: CloudAzure, DnsZone: ".dev.azuredatabricks.net", AzureApplicationID: "62a912ac-b58e-4c1d-89ea-b2dbfc7358fc", AzureEnvironment: &publicCloud}, | ||
{Cloud: CloudAzure, DnsZone: ".staging.azuredatabricks.net", AzureApplicationID: "4a67d088-db5c-48f1-9ff2-0aace800ae68", AzureEnvironment: &publicCloud}, | ||
{Cloud: CloudAzure, DnsZone: ".azuredatabricks.net", AzureApplicationID: "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d", AzureEnvironment: &publicCloud}, | ||
{Cloud: CloudAzure, DnsZone: ".databricks.azure.us", AzureApplicationID: "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d", AzureEnvironment: &usGovernmentCloud}, | ||
{Cloud: CloudAzure, DnsZone: ".databricks.azure.cn", AzureApplicationID: "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d", AzureEnvironment: &chinaCloud}, | ||
|
||
{Cloud: CloudGCP, DnsZone: ".dev.gcp.databricks.com"}, | ||
{Cloud: CloudGCP, DnsZone: ".staging.gcp.databricks.com"}, | ||
{Cloud: CloudGCP, DnsZone: ".gcp.databricks.com"}, | ||
} | ||
|
||
func (c *Config) Environment() (*DatabricksEnvironment, error) { | ||
hostname := c.CanonicalHostName() | ||
for _, e := range append(c.DatabricksEnvironments, envs...) { | ||
if strings.HasSuffix(hostname, e.DnsZone) { | ||
return &e, nil | ||
} | ||
} | ||
// TODO: do we return default one or do we return error?... | ||
return nil, fmt.Errorf("cannot find DatabricksEnvironment for %s", hostname) | ||
} |