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

Use config.Environment() to find MySQL AAD resource ID #1529

Merged
Merged
Changes from 1 commit
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
19 changes: 18 additions & 1 deletion pkg/resourcemanager/mysql/mysqlhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ const DriverName = "mysql"
// assume will exist).
const SystemDatabase = "mysql"

func GetMySQLAADResourceID() string {
// TODO: Switch this to use config.Environment().ResourceIdentifiers.OSSRDBMS
// TODO: when that change is in azure-go-sdk
// TODO: See: https://github.com/Azure/go-autorest/pull/635
envName := config.Environment().Name

if envName == "AzureUSGovernmentCloud" {
return "https://ossrdbms-aad.database.usgovcloudapi.net"
} else if envName == "AzureChinaCloud" {
return "https://ossrdbms-aad.database.chinacloudapi.cn"
} else if envName == "AzureGermanCloud" {
return "https://ossrdbms-aad.database.cloudapi.de"
}

return "https://ossrdbms-aad.database.windows.net"
}

func GetMySQLDatabaseDNSSuffix() string {
// TODO: We need an environment specific way of getting the DNS suffix
// TODO: which the Go SDK doesn't seem to have.
Expand Down Expand Up @@ -84,7 +101,7 @@ func ConnectToSQLDBAsCurrentUser(
user string,
clientID string) (*sql.DB, error) {

tokenProvider, err := iam.GetMSITokenProviderForResourceByClientID("https://ossrdbms-aad.database.windows.net", clientID)
tokenProvider, err := iam.GetMSITokenProviderForResourceByClientID(GetMySQLAADResourceID(), clientID)
if err != nil {
return nil, err
}
Expand Down