-
Notifications
You must be signed in to change notification settings - Fork 7
/
environment.go
58 lines (50 loc) · 1.32 KB
/
environment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"crypto/tls"
"fmt"
"log"
"net/http"
"strings"
)
type Environment struct {
aadLoginUrl string
apiVersion string
armUrl string
httpTransport http.Transport
}
const (
PublicEnvironmentName = "Public"
GermanEnvironmentName = "AzureGermanCloud"
)
var (
// Public Azure
publicAzureEnvironment = Environment{
aadLoginUrl: "https://login.microsoftonline.com",
apiVersion: "2017-08-01",
armUrl: "https://management.azure.com",
httpTransport: http.Transport{},
}
germanAzureEnvironment = Environment{
aadLoginUrl: "https://login.microsoftonline.de",
apiVersion: "2016-06-01",
armUrl: "https://management.microsoftazure.de",
httpTransport: http.Transport{
TLSClientConfig: &tls.Config{
MaxVersion: tls.VersionTLS11,
Renegotiation: tls.RenegotiateFreelyAsClient,
},
},
}
)
func getCurrentEnvironment(environmentName string) *Environment {
if strings.EqualFold(environmentName, PublicEnvironmentName) {
return &publicAzureEnvironment
} else if strings.EqualFold(environmentName, GermanEnvironmentName) {
return &germanAzureEnvironment
}
log.Fatalf("Unknown environment: %s", environmentName)
return nil
}
func (environment Environment) getAadLoginUrl(TenantID string) string {
return fmt.Sprintf("%s/%s/oauth2/token", environment.aadLoginUrl, TenantID)
}