forked from Azure/acs-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
converterfromagentpoolonlyapi.go
102 lines (93 loc) · 4 KB
/
converterfromagentpoolonlyapi.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package api
import "github.com/Azure/acs-engine/pkg/api/agentPoolOnlyApi/v20170831"
///////////////////////////////////////////////////////////
// The converter exposes functions to convert the top level
// ContainerService resource
//
// All other functions are internal helper functions used
// for converting.
///////////////////////////////////////////////////////////
// ConvertContainerServiceToV20170831AgentPoolOnly converts an unversioned ContainerService to a v20170831 ContainerService
func ConvertContainerServiceToV20170831AgentPoolOnly(api *ContainerService) *v20170831.ManagedCluster {
v20170831HCP := &v20170831.ManagedCluster{}
v20170831HCP.ID = api.ID
v20170831HCP.Location = api.Location
v20170831HCP.Name = api.Name
if api.Plan != nil {
v20170831HCP.Plan = &v20170831.ResourcePurchasePlan{}
convertResourcePurchasePlanToV20170831AgentPoolOnly(api.Plan, v20170831HCP.Plan)
}
v20170831HCP.Tags = map[string]string{}
for k, v := range api.Tags {
v20170831HCP.Tags[k] = v
}
v20170831HCP.Type = api.Type
v20170831HCP.Properties = &v20170831.Properties{}
convertPropertiesToV20170831AgentPoolOnly(api.Properties, v20170831HCP.Properties)
return v20170831HCP
}
// convertResourcePurchasePlanToV20170831 converts a v20170831 ResourcePurchasePlan to an unversioned ResourcePurchasePlan
func convertResourcePurchasePlanToV20170831AgentPoolOnly(api *ResourcePurchasePlan, v20170831 *v20170831.ResourcePurchasePlan) {
v20170831.Name = api.Name
v20170831.Product = api.Product
v20170831.PromotionCode = api.PromotionCode
v20170831.Publisher = api.Publisher
}
func convertPropertiesToV20170831AgentPoolOnly(api *Properties, p *v20170831.Properties) {
p.ProvisioningState = v20170831.ProvisioningState(api.ProvisioningState)
if api.OrchestratorProfile != nil {
if api.OrchestratorProfile.OrchestratorVersion != "" {
p.KubernetesVersion = api.OrchestratorProfile.OrchestratorVersion
}
}
if api.HostedMasterProfile != nil {
p.DNSPrefix = api.HostedMasterProfile.DNSPrefix
p.FQDN = api.HostedMasterProfile.FQDN
}
p.AgentPoolProfiles = []*v20170831.AgentPoolProfile{}
for _, apiProfile := range api.AgentPoolProfiles {
v20170831Profile := &v20170831.AgentPoolProfile{}
convertAgentPoolProfileToV20170831AgentPoolOnly(apiProfile, v20170831Profile)
p.AgentPoolProfiles = append(p.AgentPoolProfiles, v20170831Profile)
}
if api.LinuxProfile != nil {
p.LinuxProfile = &v20170831.LinuxProfile{}
convertLinuxProfileToV20170831AgentPoolOnly(api.LinuxProfile, p.LinuxProfile)
}
if api.WindowsProfile != nil {
p.WindowsProfile = &v20170831.WindowsProfile{}
convertWindowsProfileToV20170831AgentPoolOnly(api.WindowsProfile, p.WindowsProfile)
}
if api.ServicePrincipalProfile != nil {
p.ServicePrincipalProfile = &v20170831.ServicePrincipalProfile{}
convertServicePrincipalProfileToV20170831AgentPoolOnly(api.ServicePrincipalProfile, p.ServicePrincipalProfile)
}
}
func convertLinuxProfileToV20170831AgentPoolOnly(api *LinuxProfile, obj *v20170831.LinuxProfile) {
obj.AdminUsername = api.AdminUsername
obj.SSH.PublicKeys = []v20170831.PublicKey{}
for _, d := range api.SSH.PublicKeys {
obj.SSH.PublicKeys = append(obj.SSH.PublicKeys, v20170831.PublicKey{
KeyData: d.KeyData,
})
}
}
func convertWindowsProfileToV20170831AgentPoolOnly(api *WindowsProfile, v20170831Profile *v20170831.WindowsProfile) {
v20170831Profile.AdminUsername = api.AdminUsername
v20170831Profile.AdminPassword = api.AdminPassword
}
func convertAgentPoolProfileToV20170831AgentPoolOnly(api *AgentPoolProfile, p *v20170831.AgentPoolProfile) {
p.Name = api.Name
p.Count = api.Count
p.VMSize = api.VMSize
p.OSType = v20170831.OSType(api.OSType)
p.SetSubnet(api.Subnet)
p.OSDiskSizeGB = api.OSDiskSizeGB
p.StorageProfile = api.StorageProfile
p.VnetSubnetID = api.VnetSubnetID
}
func convertServicePrincipalProfileToV20170831AgentPoolOnly(api *ServicePrincipalProfile, v20170831 *v20170831.ServicePrincipalProfile) {
v20170831.ClientID = api.ClientID
v20170831.Secret = api.Secret
// v20170831.KeyvaultSecretRef = api.KeyvaultSecretRef
}