Skip to content

Commit

Permalink
feat: Support dynamic AzureEnvironmentSpecConfig (Azure#386)
Browse files Browse the repository at this point in the history
* Support dynamic AzureEnvironmentSpecConfig

* remove the DcosSpecConfig from surface area

* use !="" to compare string for readability

* remove unused default AzureEnvironmentSpecConfig in vlabs

* Update pkg/api/azenvtypes.go for AzureStackCloudSpec comments

Co-Authored-By: honcao <honcao@microsoft.com>

* put default value of Azure Stack Environment Spec Config into default.go

* add an wapper assging the dst string if the src string is not empty

* assigning structs to variables for reuse

* add new pubic function to support azurestack.

* update comments for GetDefaultStringWithOverwrite

* move set default custom cloud profile to seperate file
  • Loading branch information
honcao authored and Justin Hackett committed Mar 14, 2019
1 parent 3f39148 commit 3501ceb
Show file tree
Hide file tree
Showing 20 changed files with 1,422 additions and 89 deletions.
50 changes: 25 additions & 25 deletions pkg/api/azenvtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import "fmt"

//AzureEnvironmentSpecConfig is the overall configuration differences in different cloud environments.
type AzureEnvironmentSpecConfig struct {
CloudName string
DockerSpecConfig DockerSpecConfig
KubernetesSpecConfig KubernetesSpecConfig
DCOSSpecConfig DCOSSpecConfig
EndpointConfig AzureEndpointConfig
OSImageConfig map[Distro]AzureOSImageConfig
CloudName string `json:"cloudName,omitempty"`
DockerSpecConfig DockerSpecConfig `json:"dockerSpecConfig,omitempty"`
KubernetesSpecConfig KubernetesSpecConfig `json:"kubernetesSpecConfig,omitempty"`
DCOSSpecConfig DCOSSpecConfig `json:"-"`
EndpointConfig AzureEndpointConfig `json:"endpointConfig,omitempty"`
OSImageConfig map[Distro]AzureOSImageConfig `json:"osImageConfig,omitempty"`
}

//DockerSpecConfig is the configurations of docker
type DockerSpecConfig struct {
DockerEngineRepo string
DockerComposeDownloadURL string
DockerEngineRepo string `json:"dockerEngineRepo,omitempty"`
DockerComposeDownloadURL string `json:"dockerComposeDownloadURL,omitempty"`
}

//DCOSSpecConfig is the configurations of DCOS
Expand All @@ -36,31 +36,31 @@ type DCOSSpecConfig struct {

//KubernetesSpecConfig is the kubernetes container images used.
type KubernetesSpecConfig struct {
KubernetesImageBase string
TillerImageBase string
ACIConnectorImageBase string
NVIDIAImageBase string
AzureCNIImageBase string
EtcdDownloadURLBase string
KubeBinariesSASURLBase string
WindowsTelemetryGUID string
CNIPluginsDownloadURL string
VnetCNILinuxPluginsDownloadURL string
VnetCNIWindowsPluginsDownloadURL string
ContainerdDownloadURLBase string
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
TillerImageBase string `json:"tillerImageBase,omitempty"`
ACIConnectorImageBase string `json:"aciConnectorImageBase,omitempty"`
NVIDIAImageBase string `json:"nvidiaImageBase,omitempty"`
AzureCNIImageBase string `json:"azureCNIImageBase,omitempty"`
EtcdDownloadURLBase string `json:"etcdDownloadURLBase,omitempty"`
KubeBinariesSASURLBase string `json:"kubeBinariesSASURLBase,omitempty"`
WindowsTelemetryGUID string `json:"windowsTelemetryGUID,omitempty"`
CNIPluginsDownloadURL string `json:"cniPluginsDownloadURL,omitempty"`
VnetCNILinuxPluginsDownloadURL string `json:"vnetCNILinuxPluginsDownloadURL,omitempty"`
VnetCNIWindowsPluginsDownloadURL string `json:"vnetCNIWindowsPluginsDownloadURL,omitempty"`
ContainerdDownloadURLBase string `json:"containerdDownloadURLBase,omitempty"`
}

//AzureEndpointConfig describes an Azure endpoint
type AzureEndpointConfig struct {
ResourceManagerVMDNSSuffix string
ResourceManagerVMDNSSuffix string `json:"resourceManagerVMDNSSuffix,omitempty"`
}

//AzureOSImageConfig describes an Azure OS image
type AzureOSImageConfig struct {
ImageOffer string
ImageSku string
ImagePublisher string
ImageVersion string
ImageOffer string `json:"imageOffer,omitempty"`
ImageSku string `json:"imageSku,omitempty"`
ImagePublisher string `json:"imagePublisher,omitempty"`
ImageVersion string `json:"imageVersion,omitempty"`
}

var (
Expand Down
96 changes: 74 additions & 22 deletions pkg/api/converterfromapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1172,28 +1172,80 @@ func convertFeatureFlagsToVLabs(api *FeatureFlags, vlabs *vlabs.FeatureFlags) {
vlabs.BlockOutboundInternet = api.BlockOutboundInternet
}

func convertCloudProfileToVLabs(api *CustomCloudProfile, vlabs *vlabs.CustomCloudProfile) {
func convertCloudProfileToVLabs(api *CustomCloudProfile, vlabsccp *vlabs.CustomCloudProfile) {
if api.Environment != nil {
vlabs.Environment = &azure.Environment{}
vlabs.Environment.Name = api.Environment.Name
vlabs.Environment.ManagementPortalURL = api.Environment.ManagementPortalURL
vlabs.Environment.PublishSettingsURL = api.Environment.PublishSettingsURL
vlabs.Environment.ServiceManagementEndpoint = api.Environment.ServiceManagementEndpoint
vlabs.Environment.ResourceManagerEndpoint = api.Environment.ResourceManagerEndpoint
vlabs.Environment.ActiveDirectoryEndpoint = api.Environment.ActiveDirectoryEndpoint
vlabs.Environment.GalleryEndpoint = api.Environment.GalleryEndpoint
vlabs.Environment.KeyVaultEndpoint = api.Environment.KeyVaultEndpoint
vlabs.Environment.GraphEndpoint = api.Environment.GraphEndpoint
vlabs.Environment.ServiceBusEndpoint = api.Environment.ServiceBusEndpoint
vlabs.Environment.BatchManagementEndpoint = api.Environment.BatchManagementEndpoint
vlabs.Environment.StorageEndpointSuffix = api.Environment.StorageEndpointSuffix
vlabs.Environment.SQLDatabaseDNSSuffix = api.Environment.SQLDatabaseDNSSuffix
vlabs.Environment.TrafficManagerDNSSuffix = api.Environment.TrafficManagerDNSSuffix
vlabs.Environment.KeyVaultDNSSuffix = api.Environment.KeyVaultDNSSuffix
vlabs.Environment.ServiceBusEndpointSuffix = api.Environment.ServiceBusEndpointSuffix
vlabs.Environment.ServiceManagementVMDNSSuffix = api.Environment.ServiceManagementVMDNSSuffix
vlabs.Environment.ResourceManagerVMDNSSuffix = api.Environment.ResourceManagerVMDNSSuffix
vlabs.Environment.ContainerRegistryDNSSuffix = api.Environment.ContainerRegistryDNSSuffix
vlabs.Environment.TokenAudience = api.Environment.TokenAudience
vlabsccp.Environment = &azure.Environment{}
vlabsccp.Environment.Name = api.Environment.Name
vlabsccp.Environment.ManagementPortalURL = api.Environment.ManagementPortalURL
vlabsccp.Environment.PublishSettingsURL = api.Environment.PublishSettingsURL
vlabsccp.Environment.ServiceManagementEndpoint = api.Environment.ServiceManagementEndpoint
vlabsccp.Environment.ResourceManagerEndpoint = api.Environment.ResourceManagerEndpoint
vlabsccp.Environment.ActiveDirectoryEndpoint = api.Environment.ActiveDirectoryEndpoint
vlabsccp.Environment.GalleryEndpoint = api.Environment.GalleryEndpoint
vlabsccp.Environment.KeyVaultEndpoint = api.Environment.KeyVaultEndpoint
vlabsccp.Environment.GraphEndpoint = api.Environment.GraphEndpoint
vlabsccp.Environment.ServiceBusEndpoint = api.Environment.ServiceBusEndpoint
vlabsccp.Environment.BatchManagementEndpoint = api.Environment.BatchManagementEndpoint
vlabsccp.Environment.StorageEndpointSuffix = api.Environment.StorageEndpointSuffix
vlabsccp.Environment.SQLDatabaseDNSSuffix = api.Environment.SQLDatabaseDNSSuffix
vlabsccp.Environment.TrafficManagerDNSSuffix = api.Environment.TrafficManagerDNSSuffix
vlabsccp.Environment.KeyVaultDNSSuffix = api.Environment.KeyVaultDNSSuffix
vlabsccp.Environment.ServiceBusEndpointSuffix = api.Environment.ServiceBusEndpointSuffix
vlabsccp.Environment.ServiceManagementVMDNSSuffix = api.Environment.ServiceManagementVMDNSSuffix
vlabsccp.Environment.ResourceManagerVMDNSSuffix = api.Environment.ResourceManagerVMDNSSuffix
vlabsccp.Environment.ContainerRegistryDNSSuffix = api.Environment.ContainerRegistryDNSSuffix
vlabsccp.Environment.TokenAudience = api.Environment.TokenAudience
}

if api.AzureEnvironmentSpecConfig != nil {
vlabsccp.AzureEnvironmentSpecConfig = &vlabs.AzureEnvironmentSpecConfig{}
convertAzureEnvironmentSpecConfigToVLabs(api.AzureEnvironmentSpecConfig, vlabsccp.AzureEnvironmentSpecConfig)
}

}

func convertAzureEnvironmentSpecConfigToVLabs(api *AzureEnvironmentSpecConfig, vlabses *vlabs.AzureEnvironmentSpecConfig) {
vlabses.CloudName = api.CloudName
vlabses.DCOSSpecConfig = vlabs.DCOSSpecConfig{
DCOS188BootstrapDownloadURL: api.DCOSSpecConfig.DCOS188BootstrapDownloadURL,
DCOS190BootstrapDownloadURL: api.DCOSSpecConfig.DCOS190BootstrapDownloadURL,
DCOS198BootstrapDownloadURL: api.DCOSSpecConfig.DCOS198BootstrapDownloadURL,
DCOS110BootstrapDownloadURL: api.DCOSSpecConfig.DCOS110BootstrapDownloadURL,
DCOS111BootstrapDownloadURL: api.DCOSSpecConfig.DCOS111BootstrapDownloadURL,
DCOSWindowsBootstrapDownloadURL: api.DCOSSpecConfig.DCOSWindowsBootstrapDownloadURL,
DcosRepositoryURL: api.DCOSSpecConfig.DcosRepositoryURL,
DcosClusterPackageListID: api.DCOSSpecConfig.DcosClusterPackageListID,
DcosProviderPackageID: api.DCOSSpecConfig.DcosProviderPackageID,
}

vlabses.DockerSpecConfig = vlabs.DockerSpecConfig{
DockerEngineRepo: api.DockerSpecConfig.DockerEngineRepo,
DockerComposeDownloadURL: api.DockerSpecConfig.DockerComposeDownloadURL,
}
vlabses.EndpointConfig = vlabs.AzureEndpointConfig{
ResourceManagerVMDNSSuffix: api.EndpointConfig.ResourceManagerVMDNSSuffix,
}
vlabses.KubernetesSpecConfig = vlabs.KubernetesSpecConfig{
KubernetesImageBase: api.KubernetesSpecConfig.KubernetesImageBase,
TillerImageBase: api.KubernetesSpecConfig.TillerImageBase,
ACIConnectorImageBase: api.KubernetesSpecConfig.ACIConnectorImageBase,
NVIDIAImageBase: api.KubernetesSpecConfig.NVIDIAImageBase,
AzureCNIImageBase: api.KubernetesSpecConfig.AzureCNIImageBase,
EtcdDownloadURLBase: api.KubernetesSpecConfig.EtcdDownloadURLBase,
KubeBinariesSASURLBase: api.KubernetesSpecConfig.KubeBinariesSASURLBase,
WindowsTelemetryGUID: api.KubernetesSpecConfig.WindowsTelemetryGUID,
CNIPluginsDownloadURL: api.KubernetesSpecConfig.CNIPluginsDownloadURL,
VnetCNILinuxPluginsDownloadURL: api.KubernetesSpecConfig.VnetCNILinuxPluginsDownloadURL,
VnetCNIWindowsPluginsDownloadURL: api.KubernetesSpecConfig.VnetCNIWindowsPluginsDownloadURL,
ContainerdDownloadURLBase: api.KubernetesSpecConfig.ContainerdDownloadURLBase,
}
vlabses.OSImageConfig = map[vlabs.Distro]vlabs.AzureOSImageConfig{}
for k, v := range api.OSImageConfig {
vlabses.OSImageConfig[vlabs.Distro(string(k))] = vlabs.AzureOSImageConfig{
ImageOffer: v.ImageOffer,
ImageSku: v.ImageSku,
ImagePublisher: v.ImagePublisher,
ImageVersion: v.ImageVersion,
}
}
}
Loading

0 comments on commit 3501ceb

Please sign in to comment.