func Convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversion.Scope) error { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*PodSpec))(in) } if in.Volumes != nil { out.Volumes = make([]api.Volume, len(in.Volumes)) for i := range in.Volumes { if err := Convert_v1_Volume_To_api_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil { return err } } } else { out.Volumes = nil } if in.Containers != nil { out.Containers = make([]api.Container, len(in.Containers)) for i := range in.Containers { if err := Convert_v1_Container_To_api_Container(&in.Containers[i], &out.Containers[i], s); err != nil { return err } } } else { out.Containers = nil } out.RestartPolicy = api.RestartPolicy(in.RestartPolicy) if in.TerminationGracePeriodSeconds != nil { out.TerminationGracePeriodSeconds = new(int64) *out.TerminationGracePeriodSeconds = *in.TerminationGracePeriodSeconds } else { out.TerminationGracePeriodSeconds = nil } if in.ActiveDeadlineSeconds != nil { out.ActiveDeadlineSeconds = new(int64) *out.ActiveDeadlineSeconds = *in.ActiveDeadlineSeconds } else { out.ActiveDeadlineSeconds = nil } out.DNSPolicy = api.DNSPolicy(in.DNSPolicy) if in.NodeSelector != nil { out.NodeSelector = make(map[string]string) for key, val := range in.NodeSelector { out.NodeSelector[key] = val } } else { out.NodeSelector = nil } // We support DeprecatedServiceAccount as an alias for ServiceAccountName. // If both are specified, ServiceAccountName (the new field) wins. out.ServiceAccountName = in.ServiceAccountName if in.ServiceAccountName == "" { out.ServiceAccountName = in.DeprecatedServiceAccount } out.NodeName = in.NodeName if in.SecurityContext != nil { out.SecurityContext = new(api.PodSecurityContext) if err := Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil { return err } } // the host namespace fields have to be handled specially for backward compatibility // with v1.0.0 if out.SecurityContext == nil { out.SecurityContext = new(api.PodSecurityContext) } out.SecurityContext.HostNetwork = in.HostNetwork out.SecurityContext.HostPID = in.HostPID out.SecurityContext.HostIPC = in.HostIPC if in.ImagePullSecrets != nil { out.ImagePullSecrets = make([]api.LocalObjectReference, len(in.ImagePullSecrets)) for i := range in.ImagePullSecrets { if err := Convert_v1_LocalObjectReference_To_api_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil { return err } } } else { out.ImagePullSecrets = nil } if in.Tolerations != nil { out.Tolerations = make([]api.Toleration, len(in.Tolerations)) for i := range in.Tolerations { if err := s.Convert(&in.Tolerations[i], &out.Tolerations[i], 0); err != nil { return err } } } else { out.Tolerations = nil } return nil }