func convert_v1beta3_Image_To_api_Image(in *Image, out *newer.Image, s conversion.Scope) error { if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { return err } out.DockerImageReference = in.DockerImageReference out.DockerImageManifest = in.DockerImageManifest version := in.DockerImageMetadataVersion if len(version) == 0 { version = "1.0" } if len(in.DockerImageMetadata.RawJSON) > 0 { // TODO: add a way to default the expected kind and version of an object if not set obj, err := kapi.Scheme.New(version, "DockerImage") if err != nil { return err } if err := kapi.Scheme.DecodeInto(in.DockerImageMetadata.RawJSON, obj); err != nil { return err } if err := s.Convert(obj, &out.DockerImageMetadata, 0); err != nil { return err } } out.DockerImageMetadataVersion = version return nil }
func convert_v1beta3_DeploymentTriggerImageChangeParams_To_api_DeploymentTriggerImageChangeParams(in *DeploymentTriggerImageChangeParams, out *newer.DeploymentTriggerImageChangeParams, s conversion.Scope) error { out.Automatic = in.Automatic out.ContainerNames = make([]string, len(in.ContainerNames)) copy(out.ContainerNames, in.ContainerNames) out.LastTriggeredImage = in.LastTriggeredImage if err := s.Convert(&in.From, &out.From, 0); err != nil { return err } switch in.From.Kind { case "DockerImage": ref, err := imageapi.ParseDockerImageReference(in.From.Name) if err != nil { return err } out.Tag = ref.Tag ref.Tag, ref.ID = "", "" out.RepositoryName = ref.String() case "ImageStreamTag": name, tag, ok := imageapi.SplitImageStreamTag(in.From.Name) if !ok { return fmt.Errorf("ImageStreamTag object references must be in the form <name>:<tag>: %s", in.From.Name) } out.From.Kind = "ImageStream" out.From.Name = name out.Tag = tag } return nil }
func convert_api_Template_To_v1_Template(in *newer.Template, out *Template, s conversion.Scope) error { //FIXME: DefaultConvert should not overwrite the Labels field on the // the base object. This is likely a bug in the DefaultConvert // code. For now, it is called before converting the labels. if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil { return err } return s.Convert(&in.ObjectLabels, &out.Labels, 0) }
func convert_v1_BuildStatus_To_api_Build(in *BuildStatus, out *newer.Build, s conversion.Scope) error { out.Cancelled = in.Cancelled out.CompletionTimestamp = in.CompletionTimestamp if err := s.Convert(&in.Config, &out.Config, 0); err != nil { return err } out.Duration = in.Duration out.Message = in.Message out.StartTimestamp = in.StartTimestamp return nil }
func convert_api_Route_To_v1_Route(in *newer.Route, out *Route, s conversion.Scope) error { if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil { return err } out.Spec.Path = in.Path out.Spec.Host = in.Host out.Spec.To.Kind = "Service" out.Spec.To.Name = in.ServiceName return s.Convert(&in.TLS, &out.Spec.TLS, 0) }
func convert_v1beta3_Route_To_api_Route(in *Route, out *newer.Route, s conversion.Scope) error { if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil { return err } out.Path = in.Spec.Path out.Host = in.Spec.Host if in.Spec.To.Kind == "Service" || len(in.Spec.To.Kind) == 0 { out.ServiceName = in.Spec.To.Name } return s.Convert(&in.Spec.TLS, &out.TLS, 0) }
func convert_v1_BuildConfig_To_api_BuildConfig(in *BuildConfig, out *newer.BuildConfig, s conversion.Scope) error { if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil { return err } if err := s.Convert(&in.Spec, &out.Parameters, 0); err != nil { return err } if err := s.Convert(&in.Spec.Triggers, &out.Triggers, 0); err != nil { return err } out.LastVersion = in.Status.LastVersion return nil }
func convert_api_ImageStreamTag_To_v1beta3_ImageStreamTag(in *newer.ImageStreamTag, out *ImageStreamTag, s conversion.Scope) error { if err := s.Convert(&in.Image, &out.Image, 0); err != nil { return err } if err := s.Convert(&in.Image.ObjectMeta, &out.ObjectMeta, 0); err != nil { return err } out.ImageName = in.Image.Name out.Name = in.Name return nil }
func convert_v1beta3_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.ServiceSpec, s conversion.Scope) error { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*ServiceSpec))(in) } if in.Ports != nil { out.Ports = make([]api.ServicePort, len(in.Ports)) for i := range in.Ports { if err := convert_v1beta3_ServicePort_To_api_ServicePort(&in.Ports[i], &out.Ports[i], s); err != nil { return err } } } else { out.Ports = nil } if in.Selector != nil { out.Selector = make(map[string]string) for key, val := range in.Selector { out.Selector[key] = val } } else { out.Selector = nil } out.PortalIP = in.PortalIP typeIn := in.Type if typeIn == "" { if in.CreateExternalLoadBalancer { typeIn = ServiceTypeLoadBalancer } else { typeIn = ServiceTypeClusterIP } } if err := s.Convert(&typeIn, &out.Type, 0); err != nil { return err } if in.PublicIPs != nil { out.DeprecatedPublicIPs = make([]string, len(in.PublicIPs)) for i := range in.PublicIPs { out.DeprecatedPublicIPs[i] = in.PublicIPs[i] } } else { out.DeprecatedPublicIPs = nil } out.SessionAffinity = api.ServiceAffinity(in.SessionAffinity) return nil }
func convert_api_PolicyRule_To_v1_PolicyRule(in *newer.PolicyRule, out *PolicyRule, s conversion.Scope) error { if err := s.Convert(&in.AttributeRestrictions, &out.AttributeRestrictions, 0); err != nil { return err } out.Resources = []string{} out.Resources = append(out.Resources, in.Resources.List()...) out.Verbs = []string{} out.Verbs = append(out.Verbs, in.Verbs.List()...) out.ResourceNames = in.ResourceNames.List() out.NonResourceURLsSlice = in.NonResourceURLs.List() return nil }
func convert_v1beta3_ImageStreamImage_To_api_ImageStreamImage(in *ImageStreamImage, out *newer.ImageStreamImage, s conversion.Scope) error { imageName := in.ImageName isiName := in.Name if err := s.Convert(&in.Image, &out.Image, 0); err != nil { return err } if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { return err } out.Image.Name = imageName out.Name = isiName return nil }
func convert_v1beta3_ContainerStateTerminated_To_api_ContainerStateTerminated(in *ContainerStateTerminated, out *api.ContainerStateTerminated, s conversion.Scope) error { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*ContainerStateTerminated))(in) } out.ExitCode = in.ExitCode out.Signal = in.Signal out.Reason = in.Reason out.Message = in.Message if err := s.Convert(&in.StartedAt, &out.StartedAt, 0); err != nil { return err } if err := s.Convert(&in.FinishedAt, &out.FinishedAt, 0); err != nil { return err } out.ContainerID = in.ContainerID return nil }
func convert_v1_PolicyRule_To_api_PolicyRule(in *PolicyRule, out *newer.PolicyRule, s conversion.Scope) error { if err := s.Convert(&in.AttributeRestrictions, &out.AttributeRestrictions, 0); err != nil { return err } out.Resources = util.StringSet{} out.Resources.Insert(in.Resources...) out.Verbs = util.StringSet{} out.Verbs.Insert(in.Verbs...) out.ResourceNames = util.NewStringSet(in.ResourceNames...) out.NonResourceURLs = util.NewStringSet(in.NonResourceURLsSlice...) return nil }
// rawExtensionToEmbeddedObject does the conversion you would expect from the name, using the information // given in conversion.Scope. It's placed in all schemes as a ConversionFunc to enable plugins; // see the comment for RawExtension. func (self *Scheme) rawExtensionToEmbeddedObject(in *RawExtension, out *EmbeddedObject, s conversion.Scope) error { if len(in.RawJSON) == 0 || (len(in.RawJSON) == 4 && string(in.RawJSON) == "null") { out.Object = nil return nil } // Figure out the type and kind of the output object. inVersion, outVersion, scheme := self.fromScope(s) _, kind, err := scheme.raw.DataVersionAndKind(in.RawJSON) if err != nil { return err } // We have to make this object ourselves because we don't store the version field for // plugin objects. inObj, err := scheme.New(inVersion, kind) if err != nil { return err } err = scheme.DecodeInto(in.RawJSON, inObj) if err != nil { return err } // Make the desired internal version, and do the conversion. outObj, err := scheme.New(outVersion, kind) if err != nil { return err } err = scheme.Convert(inObj, outObj) if err != nil { return err } // Last step, clear the Kind field; that should always be blank in memory. err = s.Convert( &emptyPlugin{PluginBase: PluginBase{Kind: ""}}, outObj, conversion.SourceToDest|conversion.IgnoreMissingFields|conversion.AllowDifferentFieldTypeNames, ) if err != nil { return err } out.Object = outObj return nil }
func convert_v1_DeploymentConfigSpec_To_api_DeploymentTemplate(in *DeploymentConfigSpec, out *newer.DeploymentTemplate, s conversion.Scope) error { out.ControllerTemplate.Replicas = in.Replicas if in.Selector != nil { out.ControllerTemplate.Selector = make(map[string]string) for k, v := range in.Selector { out.ControllerTemplate.Selector[k] = v } } if in.Template != nil { if err := s.Convert(&in.Template, &out.ControllerTemplate.Template, 0); err != nil { return err } } if err := s.Convert(&in.Strategy, &out.Strategy, 0); err != nil { return err } return nil }
func convert_api_DeploymentStrategy_To_v1beta3_DeploymentStrategy(in *newer.DeploymentStrategy, out *DeploymentStrategy, s conversion.Scope) error { if err := s.Convert(&in.Type, &out.Type, 0); err != nil { return err } if err := s.Convert(&in.CustomParams, &out.CustomParams, 0); err != nil { return err } if err := s.Convert(&in.RecreateParams, &out.RecreateParams, 0); err != nil { return err } if err := s.Convert(&in.RollingParams, &out.RollingParams, 0); err != nil { return err } if err := s.Convert(&in.Resources, &out.Resources, 0); err != nil { return err } return nil }
// embeddedObjectToRawExtension does the conversion you would expect from the name, using the information // given in conversion.Scope. It's placed in the DefaultScheme as a ConversionFunc to enable plugins; // see the comment for RawExtension. func (self *Scheme) embeddedObjectToRawExtension(in *EmbeddedObject, out *RawExtension, s conversion.Scope) error { if in.Object == nil { out.RawJSON = []byte("null") return nil } // Figure out the type and kind of the output object. _, outVersion, scheme := self.fromScope(s) _, kind, err := scheme.raw.ObjectVersionAndKind(in.Object) if err != nil { return err } // Manufacture an object of this type and kind. outObj, err := scheme.New(outVersion, kind) if err != nil { return err } // Manually do the conversion. err = s.Convert(in.Object, outObj, 0) if err != nil { return err } // Copy the kind field into the ouput object. err = s.Convert( &emptyPlugin{PluginBase: PluginBase{Kind: kind}}, outObj, conversion.SourceToDest|conversion.IgnoreMissingFields|conversion.AllowDifferentFieldTypeNames, ) if err != nil { return err } // Because we provide the correct version, EncodeToVersion will not attempt a conversion. raw, err := scheme.EncodeToVersion(outObj, outVersion) if err != nil { // TODO: if this fails, create an Unknown-- maybe some other // component will understand it. return err } out.RawJSON = raw return nil }
func convert_v1_Build_To_api_Build(in *Build, out *newer.Build, s conversion.Scope) error { if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { return err } if err := s.Convert(&in.Status, out, 0); err != nil { return err } if err := s.Convert(&in.Spec, &out.Parameters, 0); err != nil { return err } return s.Convert(&in.Status.Phase, &out.Status, 0) }
func convert_api_DeploymentTriggerImageChangeParams_To_v1beta3_DeploymentTriggerImageChangeParams(in *newer.DeploymentTriggerImageChangeParams, out *DeploymentTriggerImageChangeParams, s conversion.Scope) error { out.Automatic = in.Automatic out.ContainerNames = make([]string, len(in.ContainerNames)) copy(out.ContainerNames, in.ContainerNames) out.LastTriggeredImage = in.LastTriggeredImage if err := s.Convert(&in.From, &out.From, 0); err != nil { return err } switch in.From.Kind { case "ImageStream": out.From.Kind = "ImageStreamTag" tag := in.Tag if len(tag) == 0 { tag = imageapi.DefaultImageTag } out.From.Name = fmt.Sprintf("%s:%s", in.From.Name, tag) } return nil }
// The docker metadata must be cast to a version func convert_api_Image_To_v1beta3_Image(in *newer.Image, out *Image, s conversion.Scope) error { if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { return err } out.DockerImageReference = in.DockerImageReference out.DockerImageManifest = in.DockerImageManifest version := in.DockerImageMetadataVersion if len(version) == 0 { version = "1.0" } data, err := kapi.Scheme.EncodeToVersion(&in.DockerImageMetadata, version) if err != nil { return err } out.DockerImageMetadata.RawJSON = data out.DockerImageMetadataVersion = version return nil }
func convert_v1_BuildConfigSpec_To_api_BuildParameters(in *BuildConfigSpec, out *newer.BuildParameters, s conversion.Scope) error { out.ServiceAccount = in.ServiceAccount if err := s.Convert(&in.Strategy, &out.Strategy, 0); err != nil { return err } if in.Strategy.Type == SourceBuildStrategyType { out.Strategy.Type = newer.SourceBuildStrategyType } if err := s.Convert(&in.Source, &out.Source, 0); err != nil { return err } if err := s.Convert(&in.Output, &out.Output, 0); err != nil { return err } if err := s.Convert(&in.Revision, &out.Revision, 0); err != nil { return err } if err := s.Convert(&in.Resources, &out.Resources, 0); err != nil { return err } return nil }
func convert_api_ImageStream_To_v1beta3_ImageStream(in *newer.ImageStream, out *ImageStream, s conversion.Scope) error { if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { return err } if err := s.Convert(&in.Spec, &out.Spec, 0); err != nil { return err } return s.Convert(&in.Status, &out.Status, 0) }
func convert_api_DeploymentConfig_To_v1beta3_DeploymentConfig(in *newer.DeploymentConfig, out *DeploymentConfig, s conversion.Scope) error { if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil { return err } if err := s.Convert(&in.Template, &out.Spec, 0); err != nil { return err } if err := s.Convert(&in.Triggers, &out.Spec.Triggers, 0); err != nil { return err } out.Status.LatestVersion = in.LatestVersion if err := s.Convert(&in.Details, &out.Status.Details, 0); err != nil { return err } return nil }
func convert_api_ImageStreamStatus_To_v1beta3_ImageStreamStatus(in *newer.ImageStreamStatus, out *ImageStreamStatus, s conversion.Scope) error { out.DockerImageRepository = in.DockerImageRepository out.Tags = make([]NamedTagEventList, 0, 0) return s.Convert(&in.Tags, &out.Tags, 0) }
func convert_api_Container_To_v1beta3_Container(in *api.Container, out *Container, s conversion.Scope) error { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*api.Container))(in) } out.Name = in.Name out.Image = in.Image if in.Command != nil { out.Command = make([]string, len(in.Command)) for i := range in.Command { out.Command[i] = in.Command[i] } } if in.Args != nil { out.Args = make([]string, len(in.Args)) for i := range in.Args { out.Args[i] = in.Args[i] } } out.WorkingDir = in.WorkingDir if in.Ports != nil { out.Ports = make([]ContainerPort, len(in.Ports)) for i := range in.Ports { if err := convert_api_ContainerPort_To_v1beta3_ContainerPort(&in.Ports[i], &out.Ports[i], s); err != nil { return err } } } if in.Env != nil { out.Env = make([]EnvVar, len(in.Env)) for i := range in.Env { if err := convert_api_EnvVar_To_v1beta3_EnvVar(&in.Env[i], &out.Env[i], s); err != nil { return err } } } if err := s.Convert(&in.Resources, &out.Resources, 0); err != nil { return err } if in.VolumeMounts != nil { out.VolumeMounts = make([]VolumeMount, len(in.VolumeMounts)) for i := range in.VolumeMounts { if err := convert_api_VolumeMount_To_v1beta3_VolumeMount(&in.VolumeMounts[i], &out.VolumeMounts[i], s); err != nil { return err } } } if in.LivenessProbe != nil { out.LivenessProbe = new(Probe) if err := convert_api_Probe_To_v1beta3_Probe(in.LivenessProbe, out.LivenessProbe, s); err != nil { return err } } else { out.LivenessProbe = nil } if in.ReadinessProbe != nil { out.ReadinessProbe = new(Probe) if err := convert_api_Probe_To_v1beta3_Probe(in.ReadinessProbe, out.ReadinessProbe, s); err != nil { return err } } else { out.ReadinessProbe = nil } if in.Lifecycle != nil { out.Lifecycle = new(Lifecycle) if err := convert_api_Lifecycle_To_v1beta3_Lifecycle(in.Lifecycle, out.Lifecycle, s); err != nil { return err } } else { out.Lifecycle = nil } out.TerminationMessagePath = in.TerminationMessagePath out.ImagePullPolicy = PullPolicy(in.ImagePullPolicy) if in.SecurityContext != nil { out.SecurityContext = new(SecurityContext) if err := convert_api_SecurityContext_To_v1beta3_SecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil { return err } } else { out.SecurityContext = nil } // now that we've converted set the container field from security context if out.SecurityContext != nil && out.SecurityContext.Privileged != nil { out.Privileged = *out.SecurityContext.Privileged } // now that we've converted set the container field from security context if out.SecurityContext != nil && out.SecurityContext.Capabilities != nil { out.Capabilities = *out.SecurityContext.Capabilities } return nil }
func convert_v1beta3_Container_To_api_Container(in *Container, out *api.Container, s conversion.Scope) error { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*Container))(in) } out.Name = in.Name out.Image = in.Image if in.Command != nil { out.Command = make([]string, len(in.Command)) for i := range in.Command { out.Command[i] = in.Command[i] } } if in.Args != nil { out.Args = make([]string, len(in.Args)) for i := range in.Args { out.Args[i] = in.Args[i] } } out.WorkingDir = in.WorkingDir if in.Ports != nil { out.Ports = make([]api.ContainerPort, len(in.Ports)) for i := range in.Ports { if err := convert_v1beta3_ContainerPort_To_api_ContainerPort(&in.Ports[i], &out.Ports[i], s); err != nil { return err } } } if in.Env != nil { out.Env = make([]api.EnvVar, len(in.Env)) for i := range in.Env { if err := convert_v1beta3_EnvVar_To_api_EnvVar(&in.Env[i], &out.Env[i], s); err != nil { return err } } } if err := s.Convert(&in.Resources, &out.Resources, 0); err != nil { return err } if in.VolumeMounts != nil { out.VolumeMounts = make([]api.VolumeMount, len(in.VolumeMounts)) for i := range in.VolumeMounts { if err := convert_v1beta3_VolumeMount_To_api_VolumeMount(&in.VolumeMounts[i], &out.VolumeMounts[i], s); err != nil { return err } } } if in.LivenessProbe != nil { out.LivenessProbe = new(api.Probe) if err := convert_v1beta3_Probe_To_api_Probe(in.LivenessProbe, out.LivenessProbe, s); err != nil { return err } } else { out.LivenessProbe = nil } if in.ReadinessProbe != nil { out.ReadinessProbe = new(api.Probe) if err := convert_v1beta3_Probe_To_api_Probe(in.ReadinessProbe, out.ReadinessProbe, s); err != nil { return err } } else { out.ReadinessProbe = nil } if in.Lifecycle != nil { out.Lifecycle = new(api.Lifecycle) if err := convert_v1beta3_Lifecycle_To_api_Lifecycle(in.Lifecycle, out.Lifecycle, s); err != nil { return err } } else { out.Lifecycle = nil } out.TerminationMessagePath = in.TerminationMessagePath out.ImagePullPolicy = api.PullPolicy(in.ImagePullPolicy) if in.SecurityContext != nil { if in.SecurityContext.Capabilities != nil { if !reflect.DeepEqual(in.SecurityContext.Capabilities.Add, in.Capabilities.Add) || !reflect.DeepEqual(in.SecurityContext.Capabilities.Drop, in.Capabilities.Drop) { return fmt.Errorf("container capability settings do not match security context settings, cannot convert") } } if in.SecurityContext.Privileged != nil { if in.Privileged != *in.SecurityContext.Privileged { return fmt.Errorf("container privileged settings do not match security context settings, cannot convert") } } } if in.SecurityContext != nil { out.SecurityContext = new(api.SecurityContext) if err := convert_v1beta3_SecurityContext_To_api_SecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil { return err } } else { out.SecurityContext = nil } return nil }
func convert_v1beta3_ImageStreamStatus_To_api_ImageStreamStatus(in *ImageStreamStatus, out *newer.ImageStreamStatus, s conversion.Scope) error { out.DockerImageRepository = in.DockerImageRepository out.Tags = make(map[string]newer.TagEventList) return s.Convert(&in.Tags, &out.Tags, 0) }
func convert_v1_Template_To_api_Template(in *Template, out *newer.Template, s conversion.Scope) error { if err := s.Convert(&in.Labels, &out.ObjectLabels, 0); err != nil { return err } return s.DefaultConvert(in, out, conversion.IgnoreMissingFields) }
func convert_v1beta3_ImageStreamSpec_To_api_ImageStreamSpec(in *ImageStreamSpec, out *newer.ImageStreamSpec, s conversion.Scope) error { out.DockerImageRepository = in.DockerImageRepository out.Tags = make(map[string]newer.TagReference) return s.Convert(&in.Tags, &out.Tags, 0) }
func convert_api_ImageStreamSpec_To_v1beta3_ImageStreamSpec(in *newer.ImageStreamSpec, out *ImageStreamSpec, s conversion.Scope) error { out.DockerImageRepository = in.DockerImageRepository out.Tags = make([]NamedTagReference, 0, 0) return s.Convert(&in.Tags, &out.Tags, 0) }