@@ -65,9 +65,9 @@ type AzureAuthConfig struct {
65
65
// IdentitySystem indicates the identity provider. Relevant only to hybrid clouds (Azure Stack).
66
66
// Allowed values are 'azure_ad' (default), 'adfs'.
67
67
IdentitySystem string `json:"identitySystem,omitempty" yaml:"identitySystem,omitempty"`
68
- // CloudFQDN represents the hybrid cloud's fully qualified domain name: {location}.{domain}
69
- // If set, cloud provider will generate its autorest.Environment instead of using one of the pre-defined ones .
70
- CloudFQDN string `json:"cloudFQDN ,omitempty" yaml:"cloudFQDN ,omitempty"`
68
+ // ResourceManagerEndpoint is the cloud's resource manager endpoint. If set, cloud provider queries this endpoint
69
+ // in order to generate an autorest.Environment instance instead of using one of the pre-defined Environments .
70
+ ResourceManagerEndpoint string `json:"resourceManagerEndpoint ,omitempty" yaml:"resourceManagerEndpoint ,omitempty"`
71
71
}
72
72
73
73
// GetServicePrincipalToken creates a new service principal token based on the configuration
@@ -133,18 +133,17 @@ func GetServicePrincipalToken(config *AzureAuthConfig, env *azure.Environment) (
133
133
}
134
134
135
135
// ParseAzureEnvironment returns the azure environment.
136
- // If 'cloudFQDN ' is set, environment is computed by quering the cloud's resource manager endpoint.
136
+ // If 'resourceManagerEndpoint ' is set, the environment is computed by quering the cloud's resource manager endpoint.
137
137
// Otherwise, a pre-defined Environment is looked up by name.
138
- func ParseAzureEnvironment (cloudName , cloudFQDN , identitySystem string ) (* azure.Environment , error ) {
138
+ func ParseAzureEnvironment (cloudName , resourceManagerEndpoint , identitySystem string ) (* azure.Environment , error ) {
139
139
var env azure.Environment
140
140
var err error
141
- if cloudFQDN != "" {
142
- resourceManagerEndpoint := fmt .Sprintf ("https://management.%s/" , cloudFQDN )
143
- nameOverride := azure.OverrideProperty {Key : azure .EnvironmentName , Value : cloudName }
141
+ if resourceManagerEndpoint != "" {
144
142
klog .V (4 ).Infof ("Loading environment from resource manager endpoint: %s" , resourceManagerEndpoint )
143
+ nameOverride := azure.OverrideProperty {Key : azure .EnvironmentName , Value : cloudName }
145
144
env , err = azure .EnvironmentFromURL (resourceManagerEndpoint , nameOverride )
146
- if err == nil && strings . EqualFold ( cloudName , "AzureStackCloud" ) {
147
- azureStackOverrides (& env , cloudFQDN , identitySystem )
145
+ if err == nil {
146
+ azureStackOverrides (& env , resourceManagerEndpoint , identitySystem )
148
147
}
149
148
} else if cloudName == "" {
150
149
klog .V (4 ).Info ("Using public cloud environment" )
@@ -172,19 +171,16 @@ func decodePkcs12(pkcs []byte, password string) (*x509.Certificate, *rsa.Private
172
171
}
173
172
174
173
// azureStackOverrides ensures that the Environment matches what AKSe currently generates for Azure Stack
175
- func azureStackOverrides (env * azure.Environment , cloudFQDN , identitySystem string ) {
176
- env .ManagementPortalURL = fmt .Sprintf ("https://portal.%s/" , cloudFQDN )
177
- // TODO: figure out why AKSe does this
178
- // why is autorest not setting ServiceManagementEndpoint?
174
+ func azureStackOverrides (env * azure.Environment , resourceManagerEndpoint , identitySystem string ) {
175
+ env .ManagementPortalURL = strings .Replace (resourceManagerEndpoint , "https://management." , "https://portal." , - 1 )
176
+ // TODO: figure out why AKSe does this, why is autorest not setting ServiceManagementEndpoint?
179
177
env .ServiceManagementEndpoint = env .TokenAudience
180
- // TODO: figure out why AKSe does this
181
- // May not be required, ResourceManagerVMDNSSuffix is not used by k/k
182
- split := strings .Split (cloudFQDN , "." )
183
- domain := strings .Join (split [1 :], "." )
184
- env .ResourceManagerVMDNSSuffix = fmt .Sprintf ("cloudapp.%s" , domain )
185
- // NOTE: autorest sets KeyVaultEndpoint while AKSe does not
178
+ // TODO: figure out why AKSe does this, may not be required, ResourceManagerVMDNSSuffix is not referenced anywhere
179
+ env .ResourceManagerVMDNSSuffix = strings .Replace (resourceManagerEndpoint , "https://management." , "cloudapp." , - 1 )
180
+ env .ResourceManagerVMDNSSuffix = strings .TrimSuffix (env .ResourceManagerVMDNSSuffix , "/" )
186
181
if strings .EqualFold (identitySystem , ADFSIdentitySystem ) {
187
182
env .ActiveDirectoryEndpoint = strings .TrimSuffix (env .ActiveDirectoryEndpoint , "/" )
188
183
env .ActiveDirectoryEndpoint = strings .TrimSuffix (env .ActiveDirectoryEndpoint , "adfs" )
189
184
}
185
+ // NOTE: autorest sets KeyVaultEndpoint while AKSe does not
190
186
}
0 commit comments