in pkg/api/admin/openshiftcluster_convert.go [17:232]
func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
out := &OpenShiftCluster{
ID: oc.ID,
Name: oc.Name,
Type: oc.Type,
Location: oc.Location,
Properties: OpenShiftClusterProperties{
ArchitectureVersion: ArchitectureVersion(oc.Properties.ArchitectureVersion),
ProvisioningState: ProvisioningState(oc.Properties.ProvisioningState),
LastProvisioningState: ProvisioningState(oc.Properties.LastProvisioningState),
FailedProvisioningState: ProvisioningState(oc.Properties.FailedProvisioningState),
LastAdminUpdateError: oc.Properties.LastAdminUpdateError,
MaintenanceTask: MaintenanceTask(oc.Properties.MaintenanceTask),
OperatorFlags: OperatorFlags(oc.Properties.OperatorFlags),
OperatorVersion: oc.Properties.OperatorVersion,
CreatedAt: oc.Properties.CreatedAt,
CreatedBy: oc.Properties.CreatedBy,
ProvisionedBy: oc.Properties.ProvisionedBy,
MaintenanceState: MaintenanceState(oc.Properties.MaintenanceState),
ClusterProfile: ClusterProfile{
Domain: oc.Properties.ClusterProfile.Domain,
Version: oc.Properties.ClusterProfile.Version,
ResourceGroupID: oc.Properties.ClusterProfile.ResourceGroupID,
FipsValidatedModules: FipsValidatedModules(oc.Properties.ClusterProfile.FipsValidatedModules),
},
FeatureProfile: FeatureProfile{
GatewayEnabled: oc.Properties.FeatureProfile.GatewayEnabled,
},
ConsoleProfile: ConsoleProfile{
URL: oc.Properties.ConsoleProfile.URL,
},
NetworkProfile: NetworkProfile{
SoftwareDefinedNetwork: SoftwareDefinedNetwork(oc.Properties.NetworkProfile.SoftwareDefinedNetwork),
PodCIDR: oc.Properties.NetworkProfile.PodCIDR,
ServiceCIDR: oc.Properties.NetworkProfile.ServiceCIDR,
MTUSize: MTUSize(oc.Properties.NetworkProfile.MTUSize),
OutboundType: OutboundType(oc.Properties.NetworkProfile.OutboundType),
APIServerPrivateEndpointIP: oc.Properties.NetworkProfile.APIServerPrivateEndpointIP,
GatewayPrivateEndpointIP: oc.Properties.NetworkProfile.GatewayPrivateEndpointIP,
GatewayPrivateLinkID: oc.Properties.NetworkProfile.GatewayPrivateLinkID,
PreconfiguredNSG: func() PreconfiguredNSG {
if oc.Properties.NetworkProfile.PreconfiguredNSG == "" {
return PreconfiguredNSGDisabled
}
return PreconfiguredNSG(oc.Properties.NetworkProfile.PreconfiguredNSG)
}(),
},
MasterProfile: MasterProfile{
VMSize: VMSize(oc.Properties.MasterProfile.VMSize),
SubnetID: oc.Properties.MasterProfile.SubnetID,
EncryptionAtHost: EncryptionAtHost(oc.Properties.MasterProfile.EncryptionAtHost),
DiskEncryptionSetID: oc.Properties.MasterProfile.DiskEncryptionSetID,
},
APIServerProfile: APIServerProfile{
Visibility: Visibility(oc.Properties.APIServerProfile.Visibility),
URL: oc.Properties.APIServerProfile.URL,
IP: oc.Properties.APIServerProfile.IP,
IntIP: oc.Properties.APIServerProfile.IntIP,
},
StorageSuffix: oc.Properties.StorageSuffix,
ImageRegistryStorageAccountName: oc.Properties.ImageRegistryStorageAccountName,
InfraID: oc.Properties.InfraID,
},
}
if oc.Properties.ServicePrincipalProfile != nil {
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{
ClientID: oc.Properties.ServicePrincipalProfile.ClientID,
SPObjectID: oc.Properties.ServicePrincipalProfile.SPObjectID,
ClientSecret: string(oc.Properties.ServicePrincipalProfile.ClientSecret),
}
}
if oc.Properties.NetworkProfile.LoadBalancerProfile != nil {
out.Properties.NetworkProfile.LoadBalancerProfile = &LoadBalancerProfile{}
if oc.Properties.NetworkProfile.LoadBalancerProfile.AllocatedOutboundPorts != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.AllocatedOutboundPorts = oc.Properties.NetworkProfile.LoadBalancerProfile.AllocatedOutboundPorts
}
if oc.Properties.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs = &ManagedOutboundIPs{
Count: oc.Properties.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs.Count,
}
}
if oc.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs = make([]EffectiveOutboundIP, 0, len(oc.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs))
for _, effectiveOutboundIP := range oc.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs {
out.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs = append(out.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs, EffectiveOutboundIP{
ID: effectiveOutboundIP.ID,
})
}
}
if oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs = make([]OutboundIP, 0, len(oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs))
for _, outboundIP := range oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs = append(out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs, OutboundIP{
ID: outboundIP.ID,
})
}
}
if oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes = make([]OutboundIPPrefix, 0, len(oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes))
for _, outboundIPPrefix := range oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes = append(out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes, OutboundIPPrefix{
ID: outboundIPPrefix.ID,
})
}
}
}
if oc.Properties.WorkerProfiles != nil {
out.Properties.WorkerProfiles = make([]WorkerProfile, 0, len(oc.Properties.WorkerProfiles))
for _, p := range oc.Properties.WorkerProfiles {
out.Properties.WorkerProfiles = append(out.Properties.WorkerProfiles, WorkerProfile{
Name: p.Name,
VMSize: VMSize(p.VMSize),
DiskSizeGB: p.DiskSizeGB,
SubnetID: p.SubnetID,
Count: p.Count,
EncryptionAtHost: EncryptionAtHost(p.EncryptionAtHost),
DiskEncryptionSetID: p.DiskEncryptionSetID,
})
}
}
if oc.Properties.WorkerProfilesStatus != nil {
out.Properties.WorkerProfilesStatus = make([]WorkerProfile, 0, len(oc.Properties.WorkerProfilesStatus))
for _, p := range oc.Properties.WorkerProfilesStatus {
out.Properties.WorkerProfilesStatus = append(out.Properties.WorkerProfilesStatus, WorkerProfile{
Name: p.Name,
VMSize: VMSize(p.VMSize),
DiskSizeGB: p.DiskSizeGB,
SubnetID: p.SubnetID,
Count: p.Count,
EncryptionAtHost: EncryptionAtHost(p.EncryptionAtHost),
DiskEncryptionSetID: p.DiskEncryptionSetID,
})
}
}
if oc.Properties.IngressProfiles != nil {
out.Properties.IngressProfiles = make([]IngressProfile, 0, len(oc.Properties.IngressProfiles))
for _, p := range oc.Properties.IngressProfiles {
out.Properties.IngressProfiles = append(out.Properties.IngressProfiles, IngressProfile{
Name: p.Name,
Visibility: Visibility(p.Visibility),
IP: p.IP,
})
}
}
if oc.Properties.Install != nil {
out.Properties.Install = &Install{
Now: oc.Properties.Install.Now,
Phase: InstallPhase(oc.Properties.Install.Phase),
}
}
if oc.Tags != nil {
out.Tags = make(map[string]string, len(oc.Tags))
for k, v := range oc.Tags {
out.Tags[k] = v
}
}
if oc.Identity != nil {
out.Identity = &ManagedServiceIdentity{}
out.Identity.Type = ManagedServiceIdentityType(oc.Identity.Type)
out.Identity.PrincipalID = oc.Identity.PrincipalID
out.Identity.TenantID = oc.Identity.TenantID
out.Identity.UserAssignedIdentities = make(map[string]UserAssignedIdentity, len(oc.Identity.UserAssignedIdentities))
for k := range oc.Identity.UserAssignedIdentities {
var temp UserAssignedIdentity
temp.ClientID = oc.Identity.UserAssignedIdentities[k].ClientID
temp.PrincipalID = oc.Identity.UserAssignedIdentities[k].PrincipalID
out.Identity.UserAssignedIdentities[k] = temp
}
}
if oc.Properties.PlatformWorkloadIdentityProfile != nil && oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities != nil {
out.Properties.PlatformWorkloadIdentityProfile = &PlatformWorkloadIdentityProfile{}
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities = make(map[string]PlatformWorkloadIdentity, len(oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities))
for name, pwi := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities {
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[name] = PlatformWorkloadIdentity{
ResourceID: pwi.ResourceID,
ClientID: pwi.ClientID,
ObjectID: pwi.ObjectID,
}
}
}
if oc.Properties.RegistryProfiles != nil {
out.Properties.RegistryProfiles = make([]RegistryProfile, len(oc.Properties.RegistryProfiles))
for i, v := range oc.Properties.RegistryProfiles {
out.Properties.RegistryProfiles[i].Name = v.Name
out.Properties.RegistryProfiles[i].Username = v.Username
out.Properties.RegistryProfiles[i].IssueDate = v.IssueDate
}
}
if oc.Properties.ClusterProfile.OIDCIssuer != nil {
out.Properties.ClusterProfile.OIDCIssuer = pointerutils.ToPtr(OIDCIssuer(*oc.Properties.ClusterProfile.OIDCIssuer))
}
out.Properties.HiveProfile = HiveProfile{
Namespace: oc.Properties.HiveProfile.Namespace,
CreatedByHive: oc.Properties.HiveProfile.CreatedByHive,
}
return out
}