func()

in pkg/api/v20230701preview/openshiftcluster_convert.go [16:151]


func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
	out := &OpenShiftCluster{
		ID:       oc.ID,
		Name:     oc.Name,
		Type:     oc.Type,
		Location: oc.Location,
		Properties: OpenShiftClusterProperties{
			ProvisioningState: ProvisioningState(oc.Properties.ProvisioningState),
			ClusterProfile: ClusterProfile{
				PullSecret:           string(oc.Properties.ClusterProfile.PullSecret),
				Domain:               oc.Properties.ClusterProfile.Domain,
				Version:              oc.Properties.ClusterProfile.Version,
				ResourceGroupID:      oc.Properties.ClusterProfile.ResourceGroupID,
				FipsValidatedModules: FipsValidatedModules(oc.Properties.ClusterProfile.FipsValidatedModules),
			},
			ConsoleProfile: ConsoleProfile{
				URL: oc.Properties.ConsoleProfile.URL,
			},
			NetworkProfile: NetworkProfile{
				PodCIDR:      oc.Properties.NetworkProfile.PodCIDR,
				ServiceCIDR:  oc.Properties.NetworkProfile.ServiceCIDR,
				OutboundType: OutboundType(oc.Properties.NetworkProfile.OutboundType),
			},
			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,
			},
		},
	}

	if oc.Properties.ServicePrincipalProfile != nil {
		out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{
			ClientID:     oc.Properties.ServicePrincipalProfile.ClientID,
			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 {
		workerProfiles := oc.Properties.WorkerProfiles

		// Use enriched worker profile data when available
		if oc.Properties.WorkerProfilesStatus != nil {
			workerProfiles = oc.Properties.WorkerProfilesStatus
		}

		out.Properties.WorkerProfiles = make([]WorkerProfile, 0, len(workerProfiles))
		for _, p := range 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.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.Tags != nil {
		out.Tags = make(map[string]string, len(oc.Tags))
		for k, v := range oc.Tags {
			out.Tags[k] = v
		}
	}

	out.SystemData = &SystemData{
		CreatedBy:          oc.SystemData.CreatedBy,
		CreatedAt:          oc.SystemData.CreatedAt,
		CreatedByType:      CreatedByType(oc.SystemData.CreatedByType),
		LastModifiedBy:     oc.SystemData.LastModifiedBy,
		LastModifiedAt:     oc.SystemData.LastModifiedAt,
		LastModifiedByType: CreatedByType(oc.SystemData.LastModifiedByType),
	}

	return out
}