From 81cf9cd1a8bf371d48a1a250be825a6672ef53f2 Mon Sep 17 00:00:00 2001 From: Dennis Marttinen Date: Fri, 9 Aug 2019 20:37:52 +0300 Subject: [PATCH 1/6] OCIImageClaim -> OCIRef, simplify by naming the field `oci` --- cmd/ignite/cmd/vmcmd/create.go | 2 +- cmd/ignite/run/create.go | 6 +++--- cmd/ignite/run/ps.go | 2 +- pkg/apis/ignite/helpers.go | 4 ++-- pkg/apis/ignite/types.go | 21 +++++---------------- pkg/apis/ignite/v1alpha2/defaults.go | 8 ++------ pkg/apis/ignite/v1alpha2/types.go | 21 +++++---------------- pkg/apis/ignite/validation/validation.go | 23 +++++++++++------------ pkg/apis/meta/v1alpha1/image.go | 16 +++++++++------- pkg/operations/import.go | 4 ++-- pkg/operations/lookup/lookup.go | 10 ++++++---- 11 files changed, 47 insertions(+), 70 deletions(-) diff --git a/cmd/ignite/cmd/vmcmd/create.go b/cmd/ignite/cmd/vmcmd/create.go index 659e7aced..838fe9743 100644 --- a/cmd/ignite/cmd/vmcmd/create.go +++ b/cmd/ignite/cmd/vmcmd/create.go @@ -74,7 +74,7 @@ func addCreateFlags(fs *pflag.FlagSet, cf *run.CreateFlags) { // Register more complex flags with their own flag types cmdutil.SizeVar(fs, &cf.VM.Spec.Memory, "memory", "Amount of RAM to allocate for the VM") cmdutil.SizeVarP(fs, &cf.VM.Spec.DiskSize, "size", "s", "VM filesystem size, for example 5GB or 2048MB") - cmdutil.OCIImageRefVarP(fs, &cf.VM.Spec.Kernel.OCIClaim.Ref, "kernel-image", "k", "Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules") + cmdutil.OCIImageRefVarP(fs, &cf.VM.Spec.Kernel.OCIRef, "kernel-image", "k", "Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules") cmdutil.NetworkModeVar(fs, &cf.VM.Spec.Network.Mode) cmdutil.SSHVar(fs, &cf.SSH) cmdutil.VolumeVarP(fs, &cf.VM.Spec.Storage, "volumes", "v", "Expose block devices from the host inside the VM") diff --git a/cmd/ignite/run/create.go b/cmd/ignite/run/create.go index 3a3e25a3d..be90145b6 100644 --- a/cmd/ignite/run/create.go +++ b/cmd/ignite/run/create.go @@ -46,7 +46,7 @@ func (cf *CreateFlags) constructVMFromCLI(args []string) error { return err } - cf.VM.Spec.Image.OCIClaim.Ref = ociRef + cf.VM.Spec.Image.OCIRef = ociRef } // Parse the --copy-files flag @@ -91,7 +91,7 @@ func (cf *CreateFlags) NewCreateOptions(args []string) (*createOptions, error) { // Get the image, or import it if it doesn't exist var err error - co.image, err = operations.FindOrImportImage(providers.Client, cf.VM.Spec.Image.OCIClaim.Ref) + co.image, err = operations.FindOrImportImage(providers.Client, cf.VM.Spec.Image.OCIRef) if err != nil { return nil, err } @@ -100,7 +100,7 @@ func (cf *CreateFlags) NewCreateOptions(args []string) (*createOptions, error) { cf.VM.SetImage(co.image) // Get the kernel, or import it if it doesn't exist - co.kernel, err = operations.FindOrImportKernel(providers.Client, cf.VM.Spec.Kernel.OCIClaim.Ref) + co.kernel, err = operations.FindOrImportKernel(providers.Client, cf.VM.Spec.Kernel.OCIRef) if err != nil { return nil, err } diff --git a/cmd/ignite/run/ps.go b/cmd/ignite/run/ps.go index e78212a16..de8314bad 100644 --- a/cmd/ignite/run/ps.go +++ b/cmd/ignite/run/ps.go @@ -30,7 +30,7 @@ func Ps(po *psOptions) error { o.Write("VM ID", "IMAGE", "KERNEL", "SIZE", "CPUS", "MEMORY", "CREATED", "STATUS", "IPS", "PORTS", "NAME") for _, vm := range po.allVMs { - o.Write(vm.GetUID(), vm.Spec.Image.OCIClaim.Ref, vm.Spec.Kernel.OCIClaim.Ref, + o.Write(vm.GetUID(), vm.Spec.Image.OCIRef, vm.Spec.Kernel.OCIRef, vm.Spec.DiskSize, vm.Spec.CPUs, vm.Spec.Memory, vm.GetCreated(), formatStatus(vm), vm.Status.IPAddresses, vm.Spec.Network.Ports, vm.GetName()) } diff --git a/pkg/apis/ignite/helpers.go b/pkg/apis/ignite/helpers.go index 8ab1344f6..ad77ee3cb 100644 --- a/pkg/apis/ignite/helpers.go +++ b/pkg/apis/ignite/helpers.go @@ -23,13 +23,13 @@ func GetImageSourceTypes() []ImageSourceType { // SetImage populates relevant fields to an Image on the VM object func (vm *VM) SetImage(image *Image) { - vm.Spec.Image.OCIClaim = image.Spec.OCIClaim + vm.Spec.Image.OCIRef = image.Spec.OCIRef vm.Status.Image = image.Status.OCISource } // SetKernel populates relevant fields to a Kernel on the VM object func (vm *VM) SetKernel(kernel *Kernel) { - vm.Spec.Kernel.OCIClaim = kernel.Spec.OCIClaim + vm.Spec.Kernel.OCIRef = kernel.Spec.OCIRef vm.Status.Kernel = kernel.Status.OCISource } diff --git a/pkg/apis/ignite/types.go b/pkg/apis/ignite/types.go index 75d1ad8a0..3545ac492 100644 --- a/pkg/apis/ignite/types.go +++ b/pkg/apis/ignite/types.go @@ -27,7 +27,7 @@ type Image struct { // ImageSpec declares what the image contains type ImageSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` + OCIRef meta.OCIImageRef `json:"oci"` } // ImageSourceType is an enum of different supported Image Source Types @@ -38,17 +38,6 @@ const ( ImageSourceTypeDocker ImageSourceType = "Docker" ) -// OCIImageClaim defines a claim for importing an OCI image -type OCIImageClaim struct { - // Type defines how the image should be imported - Type ImageSourceType `json:"type"` - // Ref defines the reference to use when talking to the backend. - // This is most commonly the image name, followed by a tag. - // Other supported ways are $registry/$user/$image@sha256:$digest - // This ref is also used as ObjectMeta.Name for kinds Images and Kernels - Ref meta.OCIImageRef `json:"ref"` -} - // OCIImageSource specifies how the OCI image was imported. // It is the status variant of OCIImageClaim type OCIImageSource struct { @@ -136,7 +125,7 @@ type Kernel struct { // KernelSpec describes the properties of a kernel type KernelSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` + OCIRef meta.OCIImageRef `json:"oci"` // Optional future feature, support per-kernel specific default command lines // DefaultCmdLine string } @@ -183,12 +172,12 @@ type VMSpec struct { } type VMImageSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` + OCIRef meta.OCIImageRef `json:"oci"` } type VMKernelSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` - CmdLine string `json:"cmdLine,omitempty"` + OCIRef meta.OCIImageRef `json:"oci"` + CmdLine string `json:"cmdLine,omitempty"` } type VMNetworkSpec struct { diff --git a/pkg/apis/ignite/v1alpha2/defaults.go b/pkg/apis/ignite/v1alpha2/defaults.go index e96f85e2e..39f36174a 100644 --- a/pkg/apis/ignite/v1alpha2/defaults.go +++ b/pkg/apis/ignite/v1alpha2/defaults.go @@ -10,10 +10,6 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error { return RegisterDefaults(scheme) } -func SetDefaults_OCIImageClaim(obj *OCIImageClaim) { - obj.Type = ImageSourceTypeDocker -} - func SetDefaults_PoolSpec(obj *PoolSpec) { if obj.AllocationSize == meta.EmptySize { obj.AllocationSize = meta.NewSizeFromSectors(constants.POOL_ALLOCATION_SIZE_SECTORS) @@ -52,8 +48,8 @@ func SetDefaults_VMSpec(obj *VMSpec) { func SetDefaults_VMKernelSpec(obj *VMKernelSpec) { // Default the kernel image if unset - if len(obj.OCIClaim.Ref) == 0 { - obj.OCIClaim.Ref, _ = meta.NewOCIImageRef(constants.DEFAULT_KERNEL_IMAGE) + if len(obj.OCIRef) == 0 { + obj.OCIRef, _ = meta.NewOCIImageRef(constants.DEFAULT_KERNEL_IMAGE) } if len(obj.CmdLine) == 0 { diff --git a/pkg/apis/ignite/v1alpha2/types.go b/pkg/apis/ignite/v1alpha2/types.go index 7324db32c..91caa7dc1 100644 --- a/pkg/apis/ignite/v1alpha2/types.go +++ b/pkg/apis/ignite/v1alpha2/types.go @@ -27,7 +27,7 @@ type Image struct { // ImageSpec declares what the image contains type ImageSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` + OCIRef meta.OCIImageRef `json:"oci"` } // ImageSourceType is an enum of different supported Image Source Types @@ -38,17 +38,6 @@ const ( ImageSourceTypeDocker ImageSourceType = "Docker" ) -// OCIImageClaim defines a claim for importing an OCI image -type OCIImageClaim struct { - // Type defines how the image should be imported - Type ImageSourceType `json:"type"` - // Ref defines the reference to use when talking to the backend. - // This is most commonly the image name, followed by a tag. - // Other supported ways are $registry/$user/$image@sha256:$digest - // This ref is also used as ObjectMeta.Name for kinds Images and Kernels - Ref meta.OCIImageRef `json:"ref"` -} - // OCIImageSource specifies how the OCI image was imported. // It is the status variant of OCIImageClaim type OCIImageSource struct { @@ -136,7 +125,7 @@ type Kernel struct { // KernelSpec describes the properties of a kernel type KernelSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` + OCIRef meta.OCIImageRef `json:"oci"` // Optional future feature, support per-kernel specific default command lines // DefaultCmdLine string } @@ -183,12 +172,12 @@ type VMSpec struct { } type VMImageSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` + OCIRef meta.OCIImageRef `json:"oci"` } type VMKernelSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` - CmdLine string `json:"cmdLine,omitempty"` + OCIRef meta.OCIImageRef `json:"oci"` + CmdLine string `json:"cmdLine,omitempty"` } type VMNetworkSpec struct { diff --git a/pkg/apis/ignite/validation/validation.go b/pkg/apis/ignite/validation/validation.go index 1cfb1b332..49f7fa812 100644 --- a/pkg/apis/ignite/validation/validation.go +++ b/pkg/apis/ignite/validation/validation.go @@ -13,8 +13,8 @@ import ( // ValidateVM validates a VM object and collects all encountered errors func ValidateVM(obj *api.VM) (allErrs field.ErrorList) { allErrs = append(allErrs, ValidateNetworkMode(obj.Spec.Network.Mode, field.NewPath(".spec.network.mode"))...) - allErrs = append(allErrs, ValidateOCIImageClaim(&obj.Spec.Image.OCIClaim, field.NewPath(".spec.image.ociClaim"))...) - allErrs = append(allErrs, ValidateOCIImageClaim(&obj.Spec.Kernel.OCIClaim, field.NewPath(".spec.kernel.ociClaim"))...) + allErrs = append(allErrs, RequireOCIImageRef(&obj.Spec.Image.OCIRef, field.NewPath(".spec.image.oci"))...) + allErrs = append(allErrs, RequireOCIImageRef(&obj.Spec.Kernel.OCIRef, field.NewPath(".spec.kernel.oci"))...) allErrs = append(allErrs, ValidateFileMappings(&obj.Spec.CopyFiles, field.NewPath(".spec.copyFiles"))...) allErrs = append(allErrs, ValidateVMStorage(&obj.Spec.Storage, field.NewPath(".spec.storage"))...) // TODO: Add vCPU, memory, disk max and min sizes @@ -22,19 +22,12 @@ func ValidateVM(obj *api.VM) (allErrs field.ErrorList) { return } -// ValidateOCIImageClaim validates an OCI image claim -func ValidateOCIImageClaim(c *api.OCIImageClaim, fldPath *field.Path) (allErrs field.ErrorList) { - allErrs = append(allErrs, ValidateImageSourceType(c.Type, fldPath.Child("type"))...) - allErrs = append(allErrs, RequireOCIImageRef(&c.Ref, fldPath.Child("ref"))...) - - return -} - -// RequireOCIImageRef +// RequireOCIImageRef validates that the OCIImageRef is set func RequireOCIImageRef(ref *meta.OCIImageRef, fldPath *field.Path) (allErrs field.ErrorList) { if ref.IsUnset() { - allErrs = append(allErrs, field.Required(fldPath, "ociRef is mandatory")) + allErrs = append(allErrs, field.Required(fldPath, "the OCI reference is mandatory")) } + return } @@ -45,6 +38,7 @@ func ValidateFileMappings(mappings *[]api.FileMapping, fldPath *field.Path) (all allErrs = append(allErrs, ValidateAbsolutePath(mapping.HostPath, mappingPath.Child("hostPath"))...) allErrs = append(allErrs, ValidateAbsolutePath(mapping.VMPath, mappingPath.Child("vmPath"))...) } + return } @@ -62,6 +56,7 @@ func ValidateAbsolutePath(pathStr string, fldPath *field.Path) (allErrs field.Er if !path.IsAbs(pathStr) { allErrs = append(allErrs, field.Invalid(fldPath, pathStr, "path must be absolute")) } + return } @@ -74,9 +69,11 @@ func ValidateNetworkMode(mode api.NetworkMode, fldPath *field.Path) (allErrs fie found = true } } + if !found { allErrs = append(allErrs, field.Invalid(fldPath, mode, fmt.Sprintf("network mode must be one of %v", modes))) } + return } @@ -89,8 +86,10 @@ func ValidateImageSourceType(t api.ImageSourceType, fldPath *field.Path) (allErr found = true } } + if !found { allErrs = append(allErrs, field.Invalid(fldPath, t, fmt.Sprintf("image source type must be one of %v", types))) } + return } diff --git a/pkg/apis/meta/v1alpha1/image.go b/pkg/apis/meta/v1alpha1/image.go index 62f1bdb0c..96a6da781 100644 --- a/pkg/apis/meta/v1alpha1/image.go +++ b/pkg/apis/meta/v1alpha1/image.go @@ -21,13 +21,17 @@ func NewOCIImageRef(imageStr string) (OCIImageRef, error) { if err != nil { return "", err } + namedTagged, ok := named.(reference.NamedTagged) if !ok { - return "", fmt.Errorf("could not parse image name with a tag %s", imageStr) + return "", fmt.Errorf("could not parse image %q with a tag", imageStr) } + return OCIImageRef(reference.FamiliarString(namedTagged)), nil } +// OCIImageRef is a string by which an OCI runtime can identify an image to retrieve. +// It needs to have a tag and usually looks like "weaveworks/ignite-ubuntu:latest". type OCIImageRef string var _ fmt.Stringer = OCIImageRef("") @@ -40,15 +44,13 @@ func (i OCIImageRef) IsUnset() bool { return len(i) == 0 } -func (i *OCIImageRef) UnmarshalJSON(b []byte) error { - var str string - var err error - - if err = json.Unmarshal(b, &str); err != nil { +func (i *OCIImageRef) UnmarshalJSON(b []byte) (err error) { + var s string + if err = json.Unmarshal(b, &s); err != nil { return err } - *i, err = NewOCIImageRef(str) + *i, err = NewOCIImageRef(s) return err } diff --git a/pkg/operations/import.go b/pkg/operations/import.go index b5c567796..caec9aedf 100644 --- a/pkg/operations/import.go +++ b/pkg/operations/import.go @@ -54,7 +54,7 @@ func importImage(c *client.Client, ociRef meta.OCIImageRef) (*api.Image, error) // Set the image name image.Name = ociRef.String() // Set the image's ociRef - image.Spec.OCIClaim.Ref = ociRef + image.Spec.OCIRef = ociRef // Set the image's ociSource image.Status.OCISource = *src @@ -112,7 +112,7 @@ func importKernel(c *client.Client, ociRef meta.OCIImageRef) (*api.Kernel, error // Set the kernel name kernel.Name = ociRef.String() // Set the kernel's ociRef - kernel.Spec.OCIClaim.Ref = ociRef + kernel.Spec.OCIRef = ociRef // Set the kernel's ociSource kernel.Status.OCISource = *src diff --git a/pkg/operations/lookup/lookup.go b/pkg/operations/lookup/lookup.go index c3559c543..3fa24318f 100644 --- a/pkg/operations/lookup/lookup.go +++ b/pkg/operations/lookup/lookup.go @@ -8,17 +8,19 @@ import ( ) func ImageUIDForVM(vm *api.VM, c *client.Client) (meta.UID, error) { - image, err := c.Images().Find(filter.NewNameFilter(vm.Spec.Image.OCIClaim.Ref.String())) + image, err := c.Images().Find(filter.NewNameFilter(vm.Spec.Image.OCIRef.String())) if err != nil { - return meta.UID(""), err + return "", err } + return image.GetUID(), nil } func KernelUIDForVM(vm *api.VM, c *client.Client) (meta.UID, error) { - kernel, err := c.Kernels().Find(filter.NewNameFilter(vm.Spec.Kernel.OCIClaim.Ref.String())) + kernel, err := c.Kernels().Find(filter.NewNameFilter(vm.Spec.Kernel.OCIRef.String())) if err != nil { - return meta.UID(""), err + return "", err } + return kernel.GetUID(), nil } From f0238308683ff7d5d6dc98656e1ea838fc8ad7be Mon Sep 17 00:00:00 2001 From: Dennis Marttinen Date: Fri, 9 Aug 2019 20:47:18 +0300 Subject: [PATCH 2/6] Add conversion for `v1alpha1` for OCIClaim <-> OCIRef --- pkg/apis/ignite/v1alpha1/conversion.go | 100 ++++++++++++ .../v1alpha1/zz_generated.conversion.go | 144 ++++++------------ 2 files changed, 148 insertions(+), 96 deletions(-) diff --git a/pkg/apis/ignite/v1alpha1/conversion.go b/pkg/apis/ignite/v1alpha1/conversion.go index 7cccc81bc..36943d5d9 100644 --- a/pkg/apis/ignite/v1alpha1/conversion.go +++ b/pkg/apis/ignite/v1alpha1/conversion.go @@ -84,3 +84,103 @@ func Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(in *OCIImageSource out.ID, err = meta.ParseOCIContentID(contentRef) return } + +// Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec calls the autogenerated conversion function along with custom conversion logic +func Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) error { + if err := autoConvert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in, out, s); err != nil { + return err + } + + // Convert between the old and new OCI reference format + out.OCIClaim.Ref = in.OCIRef + out.OCIClaim.Type = ImageSourceTypeDocker + + return nil +} + +// Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec calls the autogenerated conversion function along with custom conversion logic +func Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.ImageSpec, s conversion.Scope) error { + if err := autoConvert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in, out, s); err != nil { + return err + } + + // Convert between the old and new OCI reference format + out.OCIRef = in.OCIClaim.Ref + + return nil +} + +// Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec calls the autogenerated conversion function along with custom conversion logic +func Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec(in *ignite.KernelSpec, out *KernelSpec, s conversion.Scope) error { + if err := autoConvert_ignite_KernelSpec_To_v1alpha1_KernelSpec(in, out, s); err != nil { + return err + } + + // Convert between the old and new OCI reference format + out.OCIClaim.Ref = in.OCIRef + out.OCIClaim.Type = ImageSourceTypeDocker + + return nil +} + +// Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec calls the autogenerated conversion function along with custom conversion logic +func Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignite.KernelSpec, s conversion.Scope) error { + if err := autoConvert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in, out, s); err != nil { + return err + } + + // Convert between the old and new OCI reference format + out.OCIRef = in.OCIClaim.Ref + + return nil +} + +// Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec calls the autogenerated conversion function along with custom conversion logic +func Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) error { + if err := autoConvert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in, out, s); err != nil { + return err + } + + // Convert between the old and new OCI reference format + out.OCIClaim.Ref = in.OCIRef + out.OCIClaim.Type = ImageSourceTypeDocker + + return nil +} + +// Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec calls the autogenerated conversion function along with custom conversion logic +func Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ignite.VMImageSpec, s conversion.Scope) error { + if err := autoConvert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in, out, s); err != nil { + return err + } + + // Convert between the old and new OCI reference format + out.OCIRef = in.OCIClaim.Ref + + return nil +} + +// Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec calls the autogenerated conversion function along with custom conversion logic +func Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(in *ignite.VMKernelSpec, out *VMKernelSpec, s conversion.Scope) error { + if err := autoConvert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(in, out, s); err != nil { + return err + } + + // Convert between the old and new OCI reference format + out.OCIClaim.Ref = in.OCIRef + out.OCIClaim.Type = ImageSourceTypeDocker + + return nil +} + +// Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec calls the autogenerated conversion function along with custom conversion logic +func Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out *ignite.VMKernelSpec, s conversion.Scope) error { + if err := autoConvert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in, out, s); err != nil { + return err + } + + // Convert between the old and new OCI reference format + out.OCIRef = in.OCIClaim.Ref + + return nil +} diff --git a/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go b/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go index f1123d1f8..b327bd733 100644 --- a/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go @@ -90,16 +90,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*OCIImageClaim)(nil), (*ignite.OCIImageClaim)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_OCIImageClaim_To_ignite_OCIImageClaim(a.(*OCIImageClaim), b.(*ignite.OCIImageClaim), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*ignite.OCIImageClaim)(nil), (*OCIImageClaim)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_ignite_OCIImageClaim_To_v1alpha1_OCIImageClaim(a.(*ignite.OCIImageClaim), b.(*OCIImageClaim), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*OCIImageSource)(nil), (*ignite.OCIImageSource)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(a.(*OCIImageSource), b.(*ignite.OCIImageSource), scope) }); err != nil { @@ -220,11 +210,31 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*ignite.ImageSpec)(nil), (*ImageSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec(a.(*ignite.ImageSpec), b.(*ImageSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ignite.KernelSpec)(nil), (*KernelSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec(a.(*ignite.KernelSpec), b.(*KernelSpec), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*ignite.OCIImageSource)(nil), (*OCIImageSource)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_ignite_OCIImageSource_To_v1alpha1_OCIImageSource(a.(*ignite.OCIImageSource), b.(*OCIImageSource), scope) }); err != nil { return err } + if err := s.AddConversionFunc((*ignite.VMImageSpec)(nil), (*VMImageSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(a.(*ignite.VMImageSpec), b.(*VMImageSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ignite.VMKernelSpec)(nil), (*VMKernelSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(a.(*ignite.VMKernelSpec), b.(*VMKernelSpec), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*ignite.VMSpec)(nil), (*VMSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_ignite_VMSpec_To_v1alpha1_VMSpec(a.(*ignite.VMSpec), b.(*VMSpec), scope) }); err != nil { @@ -235,11 +245,31 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*ImageSpec)(nil), (*ignite.ImageSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec(a.(*ImageSpec), b.(*ignite.ImageSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*KernelSpec)(nil), (*ignite.KernelSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec(a.(*KernelSpec), b.(*ignite.KernelSpec), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*OCIImageSource)(nil), (*ignite.OCIImageSource)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(a.(*OCIImageSource), b.(*ignite.OCIImageSource), scope) }); err != nil { return err } + if err := s.AddConversionFunc((*VMImageSpec)(nil), (*ignite.VMImageSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(a.(*VMImageSpec), b.(*ignite.VMImageSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*VMKernelSpec)(nil), (*ignite.VMKernelSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(a.(*VMKernelSpec), b.(*ignite.VMKernelSpec), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*VMSpec)(nil), (*ignite.VMSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_VMSpec_To_ignite_VMSpec(a.(*VMSpec), b.(*ignite.VMSpec), scope) }); err != nil { @@ -310,29 +340,15 @@ func Convert_ignite_Image_To_v1alpha1_Image(in *ignite.Image, out *Image, s conv } func autoConvert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.ImageSpec, s conversion.Scope) error { - if err := Convert_v1alpha1_OCIImageClaim_To_ignite_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + // WARNING: in.OCIClaim requires manual conversion: does not exist in peer-type return nil } -// Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec is an autogenerated conversion function. -func Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.ImageSpec, s conversion.Scope) error { - return autoConvert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in, out, s) -} - func autoConvert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) error { - if err := Convert_ignite_OCIImageClaim_To_v1alpha1_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + // WARNING: in.OCIRef requires manual conversion: does not exist in peer-type return nil } -// Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec is an autogenerated conversion function. -func Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) error { - return autoConvert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in, out, s) -} - func autoConvert_v1alpha1_ImageStatus_To_ignite_ImageStatus(in *ImageStatus, out *ignite.ImageStatus, s conversion.Scope) error { if err := Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(&in.OCISource, &out.OCISource, s); err != nil { return err @@ -392,29 +408,15 @@ func Convert_ignite_Kernel_To_v1alpha1_Kernel(in *ignite.Kernel, out *Kernel, s } func autoConvert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignite.KernelSpec, s conversion.Scope) error { - if err := Convert_v1alpha1_OCIImageClaim_To_ignite_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + // WARNING: in.OCIClaim requires manual conversion: does not exist in peer-type return nil } -// Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec is an autogenerated conversion function. -func Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignite.KernelSpec, s conversion.Scope) error { - return autoConvert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in, out, s) -} - func autoConvert_ignite_KernelSpec_To_v1alpha1_KernelSpec(in *ignite.KernelSpec, out *KernelSpec, s conversion.Scope) error { - if err := Convert_ignite_OCIImageClaim_To_v1alpha1_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + // WARNING: in.OCIRef requires manual conversion: does not exist in peer-type return nil } -// Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec is an autogenerated conversion function. -func Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec(in *ignite.KernelSpec, out *KernelSpec, s conversion.Scope) error { - return autoConvert_ignite_KernelSpec_To_v1alpha1_KernelSpec(in, out, s) -} - func autoConvert_v1alpha1_KernelStatus_To_ignite_KernelStatus(in *KernelStatus, out *ignite.KernelStatus, s conversion.Scope) error { out.Version = in.Version if err := Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(&in.OCISource, &out.OCISource, s); err != nil { @@ -441,28 +443,6 @@ func Convert_ignite_KernelStatus_To_v1alpha1_KernelStatus(in *ignite.KernelStatu return autoConvert_ignite_KernelStatus_To_v1alpha1_KernelStatus(in, out, s) } -func autoConvert_v1alpha1_OCIImageClaim_To_ignite_OCIImageClaim(in *OCIImageClaim, out *ignite.OCIImageClaim, s conversion.Scope) error { - out.Type = ignite.ImageSourceType(in.Type) - out.Ref = metav1alpha1.OCIImageRef(in.Ref) - return nil -} - -// Convert_v1alpha1_OCIImageClaim_To_ignite_OCIImageClaim is an autogenerated conversion function. -func Convert_v1alpha1_OCIImageClaim_To_ignite_OCIImageClaim(in *OCIImageClaim, out *ignite.OCIImageClaim, s conversion.Scope) error { - return autoConvert_v1alpha1_OCIImageClaim_To_ignite_OCIImageClaim(in, out, s) -} - -func autoConvert_ignite_OCIImageClaim_To_v1alpha1_OCIImageClaim(in *ignite.OCIImageClaim, out *OCIImageClaim, s conversion.Scope) error { - out.Type = ImageSourceType(in.Type) - out.Ref = metav1alpha1.OCIImageRef(in.Ref) - return nil -} - -// Convert_ignite_OCIImageClaim_To_v1alpha1_OCIImageClaim is an autogenerated conversion function. -func Convert_ignite_OCIImageClaim_To_v1alpha1_OCIImageClaim(in *ignite.OCIImageClaim, out *OCIImageClaim, s conversion.Scope) error { - return autoConvert_ignite_OCIImageClaim_To_v1alpha1_OCIImageClaim(in, out, s) -} - func autoConvert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(in *OCIImageSource, out *ignite.OCIImageSource, s conversion.Scope) error { // WARNING: in.ID requires manual conversion: inconvertible types (string vs *github.com/weaveworks/ignite/pkg/apis/meta/v1alpha1.OCIContentID) out.Size = in.Size @@ -639,55 +619,27 @@ func Convert_ignite_VM_To_v1alpha1_VM(in *ignite.VM, out *VM, s conversion.Scope } func autoConvert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ignite.VMImageSpec, s conversion.Scope) error { - if err := Convert_v1alpha1_OCIImageClaim_To_ignite_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + // WARNING: in.OCIClaim requires manual conversion: does not exist in peer-type return nil } -// Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec is an autogenerated conversion function. -func Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ignite.VMImageSpec, s conversion.Scope) error { - return autoConvert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in, out, s) -} - func autoConvert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) error { - if err := Convert_ignite_OCIImageClaim_To_v1alpha1_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + // WARNING: in.OCIRef requires manual conversion: does not exist in peer-type return nil } -// Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec is an autogenerated conversion function. -func Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) error { - return autoConvert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in, out, s) -} - func autoConvert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out *ignite.VMKernelSpec, s conversion.Scope) error { - if err := Convert_v1alpha1_OCIImageClaim_To_ignite_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + // WARNING: in.OCIClaim requires manual conversion: does not exist in peer-type out.CmdLine = in.CmdLine return nil } -// Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec is an autogenerated conversion function. -func Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out *ignite.VMKernelSpec, s conversion.Scope) error { - return autoConvert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in, out, s) -} - func autoConvert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(in *ignite.VMKernelSpec, out *VMKernelSpec, s conversion.Scope) error { - if err := Convert_ignite_OCIImageClaim_To_v1alpha1_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + // WARNING: in.OCIRef requires manual conversion: does not exist in peer-type out.CmdLine = in.CmdLine return nil } -// Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec is an autogenerated conversion function. -func Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(in *ignite.VMKernelSpec, out *VMKernelSpec, s conversion.Scope) error { - return autoConvert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(in, out, s) -} - func autoConvert_v1alpha1_VMNetworkSpec_To_ignite_VMNetworkSpec(in *VMNetworkSpec, out *ignite.VMNetworkSpec, s conversion.Scope) error { out.Mode = ignite.NetworkMode(in.Mode) out.Ports = *(*metav1alpha1.PortMappings)(unsafe.Pointer(&in.Ports)) From c8b42d8be3f0e262e85e87c9f00615132c03dc6e Mon Sep 17 00:00:00 2001 From: Dennis Marttinen Date: Fri, 9 Aug 2019 20:50:26 +0300 Subject: [PATCH 3/6] Update reconciliation loop to use OCIRef --- pkg/operations/reconcile/reconcile.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/operations/reconcile/reconcile.go b/pkg/operations/reconcile/reconcile.go index 67d797da0..d6679d969 100644 --- a/pkg/operations/reconcile/reconcile.go +++ b/pkg/operations/reconcile/reconcile.go @@ -114,7 +114,7 @@ func create(vm *api.VM) error { // ensureOCIImages imports the base/kernel OCI images if needed func ensureOCIImages(vm *api.VM) error { // Check if a image with this name already exists, or import it - image, err := operations.FindOrImportImage(c, vm.Spec.Image.OCIClaim.Ref) + image, err := operations.FindOrImportImage(c, vm.Spec.Image.OCIRef) if err != nil { return err } @@ -123,7 +123,7 @@ func ensureOCIImages(vm *api.VM) error { vm.SetImage(image) // Check if a kernel with this name already exists, or import it - kernel, err := operations.FindOrImportKernel(c, vm.Spec.Kernel.OCIClaim.Ref) + kernel, err := operations.FindOrImportKernel(c, vm.Spec.Kernel.OCIRef) if err != nil { return err } From 0c7eb4a8911b052ee1d919bf8cfb0a45976f675a Mon Sep 17 00:00:00 2001 From: Dennis Marttinen Date: Fri, 9 Aug 2019 20:51:42 +0300 Subject: [PATCH 4/6] make autogen tidy --- docs/api/ignite_v1alpha1.md | 96 ++++++++++++++++++ docs/api/ignite_v1alpha2.md | 97 +++++++------------ docs/api/meta_v1alpha1.md | 34 ++++--- .../v1alpha2/zz_generated.conversion.go | 64 ++---------- .../ignite/v1alpha2/zz_generated.deepcopy.go | 20 ---- .../ignite/v1alpha2/zz_generated.defaults.go | 12 --- pkg/apis/ignite/zz_generated.deepcopy.go | 20 ---- pkg/openapi/openapi_generated.go | 65 +++---------- pkg/openapi/violations.txt | 4 + 9 files changed, 179 insertions(+), 233 deletions(-) diff --git a/docs/api/ignite_v1alpha1.md b/docs/api/ignite_v1alpha1.md index 40a808734..361762a91 100644 --- a/docs/api/ignite_v1alpha1.md +++ b/docs/api/ignite_v1alpha1.md @@ -15,21 +15,45 @@ - [Constants](#pkg-constants) - [Variables](#pkg-variables) + - [func Convert\_ignite\_ImageSpec\_To\_v1alpha1\_ImageSpec(in + *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) + error](#Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec) + - [func Convert\_ignite\_KernelSpec\_To\_v1alpha1\_KernelSpec(in + *ignite.KernelSpec, out *KernelSpec, s conversion.Scope) + error](#Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec) - [func Convert\_ignite\_OCIImageSource\_To\_v1alpha1\_OCIImageSource(in *ignite.OCIImageSource, out *OCIImageSource, s conversion.Scope) error](#Convert_ignite_OCIImageSource_To_v1alpha1_OCIImageSource) + - [func Convert\_ignite\_VMImageSpec\_To\_v1alpha1\_VMImageSpec(in + *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) + error](#Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec) + - [func Convert\_ignite\_VMKernelSpec\_To\_v1alpha1\_VMKernelSpec(in + *ignite.VMKernelSpec, out *VMKernelSpec, s conversion.Scope) + error](#Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec) - [func Convert\_ignite\_VMSpec\_To\_v1alpha1\_VMSpec(in *ignite.VMSpec, out *VMSpec, s conversion.Scope) error](#Convert_ignite_VMSpec_To_v1alpha1_VMSpec) - [func Convert\_ignite\_VMStatus\_To\_v1alpha1\_VMStatus(in *ignite.VMStatus, out *VMStatus, s conversion.Scope) error](#Convert_ignite_VMStatus_To_v1alpha1_VMStatus) + - [func Convert\_v1alpha1\_ImageSpec\_To\_ignite\_ImageSpec(in + *ImageSpec, out *ignite.ImageSpec, s conversion.Scope) + error](#Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec) + - [func Convert\_v1alpha1\_KernelSpec\_To\_ignite\_KernelSpec(in + *KernelSpec, out *ignite.KernelSpec, s conversion.Scope) + error](#Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec) - [func Convert\_v1alpha1\_OCIImageSource\_To\_ignite\_OCIImageSource(in *OCIImageSource, out *ignite.OCIImageSource, s conversion.Scope) (err error)](#Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource) + - [func Convert\_v1alpha1\_VMImageSpec\_To\_ignite\_VMImageSpec(in + *VMImageSpec, out *ignite.VMImageSpec, s conversion.Scope) + error](#Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec) + - [func Convert\_v1alpha1\_VMKernelSpec\_To\_ignite\_VMKernelSpec(in + *VMKernelSpec, out *ignite.VMKernelSpec, s conversion.Scope) + error](#Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec) - [func Convert\_v1alpha1\_VMSpec\_To\_ignite\_VMSpec(in *VMSpec, out *ignite.VMSpec, s conversion.Scope) error](#Convert_v1alpha1_VMSpec_To_ignite_VMSpec) @@ -124,6 +148,24 @@ var SchemeGroupVersion = schema.GroupVersion{ SchemeGroupVersion is group version used to register these objects +## func [Convert\_ignite\_ImageSpec\_To\_v1alpha1\_ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=3721:3836#L89) + +``` go +func Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) error +``` + +Convert\_ignite\_ImageSpec\_To\_v1alpha1\_ImageSpec calls the +autogenerated conversion function along with custom conversion logic + +## func [Convert\_ignite\_KernelSpec\_To\_v1alpha1\_KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=4676:4795#L114) + +``` go +func Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec(in *ignite.KernelSpec, out *KernelSpec, s conversion.Scope) error +``` + +Convert\_ignite\_KernelSpec\_To\_v1alpha1\_KernelSpec calls the +autogenerated conversion function along with custom conversion logic + ## func [Convert\_ignite\_OCIImageSource\_To\_v1alpha1\_OCIImageSource](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=2032:2167#L50) ``` go @@ -133,6 +175,24 @@ func Convert_ignite_OCIImageSource_To_v1alpha1_OCIImageSource(in *ignite.OCIImag Convert\_ignite\_OCIImageSource\_To\_v1alpha1\_OCIImageSource calls the autogenerated conversion function along with custom conversion logic +## func [Convert\_ignite\_VMImageSpec\_To\_v1alpha1\_VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=5647:5770#L139) + +``` go +func Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) error +``` + +Convert\_ignite\_VMImageSpec\_To\_v1alpha1\_VMImageSpec calls the +autogenerated conversion function along with custom conversion logic + +## func [Convert\_ignite\_VMKernelSpec\_To\_v1alpha1\_VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=6634:6761#L164) + +``` go +func Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(in *ignite.VMKernelSpec, out *VMKernelSpec, s conversion.Scope) error +``` + +Convert\_ignite\_VMKernelSpec\_To\_v1alpha1\_VMKernelSpec calls the +autogenerated conversion function along with custom conversion logic + ## func [Convert\_ignite\_VMSpec\_To\_v1alpha1\_VMSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=299:402#L10) ``` go @@ -151,6 +211,24 @@ func Convert_ignite_VMStatus_To_v1alpha1_VMStatus(in *ignite.VMStatus, out *VMSt Convert\_ignite\_VMStatus\_To\_v1alpha1\_VMStatus calls the autogenerated conversion function along with custom conversion logic +## func [Convert\_v1alpha1\_ImageSpec\_To\_ignite\_ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=4219:4334#L102) + +``` go +func Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.ImageSpec, s conversion.Scope) error +``` + +Convert\_v1alpha1\_ImageSpec\_To\_ignite\_ImageSpec calls the +autogenerated conversion function along with custom conversion logic + +## func [Convert\_v1alpha1\_KernelSpec\_To\_ignite\_KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=5182:5301#L127) + +``` go +func Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignite.KernelSpec, s conversion.Scope) error +``` + +Convert\_v1alpha1\_KernelSpec\_To\_ignite\_KernelSpec calls the +autogenerated conversion function along with custom conversion logic + ## func [Convert\_v1alpha1\_OCIImageSource\_To\_ignite\_OCIImageSource](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=2775:2916#L68) ``` go @@ -160,6 +238,24 @@ func Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(in *OCIImageSource Convert\_v1alpha1\_OCIImageSource\_To\_ignite\_OCIImageSource calls the autogenerated conversion function along with custom conversion logic +## func [Convert\_v1alpha1\_VMImageSpec\_To\_ignite\_VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=6161:6284#L152) + +``` go +func Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ignite.VMImageSpec, s conversion.Scope) error +``` + +Convert\_v1alpha1\_VMImageSpec\_To\_ignite\_VMImageSpec calls the +autogenerated conversion function along with custom conversion logic + +## func [Convert\_v1alpha1\_VMKernelSpec\_To\_ignite\_VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=7156:7283#L177) + +``` go +func Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out *ignite.VMKernelSpec, s conversion.Scope) error +``` + +Convert\_v1alpha1\_VMKernelSpec\_To\_ignite\_VMKernelSpec calls the +autogenerated conversion function along with custom conversion logic + ## func [Convert\_v1alpha1\_VMSpec\_To\_ignite\_VMSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=697:800#L16) ``` go diff --git a/docs/api/ignite_v1alpha2.md b/docs/api/ignite_v1alpha2.md index 99d44cab5..687707943 100644 --- a/docs/api/ignite_v1alpha2.md +++ b/docs/api/ignite_v1alpha2.md @@ -15,8 +15,6 @@ - [Constants](#pkg-constants) - [Variables](#pkg-variables) - - [func SetDefaults\_OCIImageClaim(obj - \*OCIImageClaim)](#SetDefaults_OCIImageClaim) - [func SetDefaults\_PoolSpec(obj \*PoolSpec)](#SetDefaults_PoolSpec) - [func SetDefaults\_VMKernelSpec(obj \*VMKernelSpec)](#SetDefaults_VMKernelSpec) @@ -34,7 +32,6 @@ - [type KernelStatus](#KernelStatus) - [type NetworkMode](#NetworkMode) - [func (nm NetworkMode) String() string](#NetworkMode.String) - - [type OCIImageClaim](#OCIImageClaim) - [type OCIImageSource](#OCIImageSource) - [type Pool](#Pool) - [type PoolDevice](#PoolDevice) @@ -105,37 +102,31 @@ var SchemeGroupVersion = schema.GroupVersion{ SchemeGroupVersion is group version used to register these objects -## func [SetDefaults\_OCIImageClaim](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=263:313#L13) - -``` go -func SetDefaults_OCIImageClaim(obj *OCIImageClaim) -``` - -## func [SetDefaults\_PoolSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=353:393#L17) +## func [SetDefaults\_PoolSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=263:303#L13) ``` go func SetDefaults_PoolSpec(obj *PoolSpec) ``` -## func [SetDefaults\_VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=1235:1283#L53) +## func [SetDefaults\_VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=1145:1193#L49) ``` go func SetDefaults_VMKernelSpec(obj *VMKernelSpec) ``` -## func [SetDefaults\_VMNetworkSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=1520:1570#L64) +## func [SetDefaults\_VMNetworkSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=1418:1468#L60) ``` go func SetDefaults_VMNetworkSpec(obj *VMNetworkSpec) ``` -## func [SetDefaults\_VMSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=919:955#L39) +## func [SetDefaults\_VMSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=829:865#L35) ``` go func SetDefaults_VMSpec(obj *VMSpec) ``` -## type [BlockDeviceVolume](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7799:7859#L212) +## type [BlockDeviceVolume](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7306:7366#L201) ``` go type BlockDeviceVolume struct { @@ -145,7 +136,7 @@ type BlockDeviceVolume struct { BlockDeviceVolume defines a block device on the host -## type [FileMapping](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8094:8189#L223) +## type [FileMapping](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7601:7696#L212) ``` go type FileMapping struct { @@ -174,7 +165,7 @@ type Image struct { Image represents a cached OCI image ready to be used with Ignite +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -## type [ImageSourceType](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=995:1022#L34) +## type [ImageSourceType](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=991:1018#L34) ``` go type ImageSourceType string @@ -189,17 +180,17 @@ const ( ) ``` -## type [ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=854:921#L29) +## type [ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=854:917#L29) ``` go type ImageSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` + OCIRef meta.OCIImageRef `json:"oci"` } ``` ImageSpec declares what the image contains -## type [ImageStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=2024:2173#L62) +## type [ImageStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1540:1689#L51) ``` go type ImageStatus struct { @@ -210,7 +201,7 @@ type ImageStatus struct { ImageStatus defines the status of the image -## type [Kernel](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4552:5019#L126) +## type [Kernel](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4068:4535#L115) ``` go type Kernel struct { @@ -230,17 +221,17 @@ kernels This file is stored in /var/lib/firecracker/kernels/{oci-image-digest}/metadata.json +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -## type [KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=5072:5245#L138) +## type [KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4588:4757#L127) ``` go type KernelSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` + OCIRef meta.OCIImageRef `json:"oci"` } ``` KernelSpec describes the properties of a kernel -## type [KernelStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=5296:5412#L145) +## type [KernelStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4808:4924#L134) ``` go type KernelStatus struct { @@ -251,7 +242,7 @@ type KernelStatus struct { KernelStatus describes the status of a kernel -## type [NetworkMode](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8543:8566#L238) +## type [NetworkMode](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8050:8073#L227) ``` go type NetworkMode string @@ -268,29 +259,13 @@ const ( ) ``` -### func (NetworkMode) [String](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8606:8643#L242) +### func (NetworkMode) [String](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8113:8150#L231) ``` go func (nm NetworkMode) String() string ``` -## type [OCIImageClaim](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1218:1636#L42) - -``` go -type OCIImageClaim struct { - // Type defines how the image should be imported - Type ImageSourceType `json:"type"` - // Ref defines the reference to use when talking to the backend. - // This is most commonly the image name, followed by a tag. - // Other supported ways are $registry/$user/$image@sha256:$digest - // This ref is also used as ObjectMeta.Name for kinds Images and Kernels - Ref meta.OCIImageRef `json:"ref"` -} -``` - -OCIImageClaim defines a claim for importing an OCI image - -## type [OCIImageSource](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1743:1975#L54) +## type [OCIImageSource](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1259:1491#L43) ``` go type OCIImageSource struct { @@ -304,7 +279,7 @@ type OCIImageSource struct { OCIImageSource specifies how the OCI image was imported. It is the status variant of OCIImageClaim -## type [Pool](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=2448:2628#L71) +## type [Pool](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1964:2144#L60) ``` go type Pool struct { @@ -320,7 +295,7 @@ snapshotter part of Ignite, and the file (existing as a singleton) is present at /var/lib/firecracker/snapshotter/pool.json +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -## type [PoolDevice](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=3919:4309#L113) +## type [PoolDevice](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=3435:3825#L102) ``` go type PoolDevice struct { @@ -336,7 +311,7 @@ type PoolDevice struct { PoolDevice defines one device in the pool -## type [PoolDeviceType](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=3648:3674#L103) +## type [PoolDeviceType](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=3164:3190#L92) ``` go type PoolDeviceType string @@ -351,7 +326,7 @@ const ( ) ``` -## type [PoolSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=2675:3388#L81) +## type [PoolSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=2191:2904#L70) ``` go type PoolSpec struct { @@ -372,7 +347,7 @@ type PoolSpec struct { PoolSpec defines the Pool’s specification -## type [PoolStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=3438:3646#L97) +## type [PoolStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=2954:3162#L86) ``` go type PoolStatus struct { @@ -384,7 +359,7 @@ type PoolStatus struct { PoolStatus defines the Pool’s current status -## type [Runtime](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9039:9085#L255) +## type [Runtime](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8546:8592#L244) ``` go type Runtime struct { @@ -394,7 +369,7 @@ type Runtime struct { Runtime specifies the VM’s runtime information -## type [SSH](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8409:8486#L232) +## type [SSH](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7916:7993#L221) ``` go type SSH struct { @@ -419,7 +394,7 @@ func (s *SSH) MarshalJSON() ([]byte, error) func (s *SSH) UnmarshalJSON(b []byte) error ``` -## type [VM](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=5614:6069#L153) +## type [VM](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=5126:5581#L142) ``` go type VM struct { @@ -438,24 +413,24 @@ VM represents a virtual machine run by Firecracker These files are stored in /var/lib/firecracker/vm/{vm-id}/metadata.json +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -## type [VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7052:7121#L185) +## type [VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6564:6629#L174) ``` go type VMImageSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` + OCIRef meta.OCIImageRef `json:"oci"` } ``` -## type [VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7123:7244#L189) +## type [VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6631:6751#L178) ``` go type VMKernelSpec struct { - OCIClaim OCIImageClaim `json:"ociClaim"` - CmdLine string `json:"cmdLine,omitempty"` + OCIRef meta.OCIImageRef `json:"oci"` + CmdLine string `json:"cmdLine,omitempty"` } ``` -## type [VMNetworkSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7246:7364#L194) +## type [VMNetworkSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6753:6871#L183) ``` go type VMNetworkSpec struct { @@ -464,7 +439,7 @@ type VMNetworkSpec struct { } ``` -## type [VMSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6117:7050#L165) +## type [VMSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=5629:6562#L154) ``` go type VMSpec struct { @@ -490,7 +465,7 @@ type VMSpec struct { VMSpec describes the configuration of a VM -## type [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9126:9465#L260) +## type [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8633:8972#L249) ``` go type VMStatus struct { @@ -505,7 +480,7 @@ type VMStatus struct { VMStatus defines the status of a VM -## type [VMStorageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7425:7569#L200) +## type [VMStorageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6932:7076#L189) ``` go type VMStorageSpec struct { @@ -516,7 +491,7 @@ type VMStorageSpec struct { VMStorageSpec defines the VM’s Volumes and VolumeMounts -## type [Volume](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7610:7741#L206) +## type [Volume](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7117:7248#L195) ``` go type Volume struct { @@ -527,7 +502,7 @@ type Volume struct { Volume defines named storage volume -## type [VolumeMount](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7931:8027#L217) +## type [VolumeMount](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7438:7534#L206) ``` go type VolumeMount struct { diff --git a/docs/api/meta_v1alpha1.md b/docs/api/meta_v1alpha1.md index f2d5eb190..a639d773c 100644 --- a/docs/api/meta_v1alpha1.md +++ b/docs/api/meta_v1alpha1.md @@ -47,8 +47,8 @@ error)](#NewOCIImageRef) - [func (i OCIImageRef) IsUnset() bool](#OCIImageRef.IsUnset) - [func (i OCIImageRef) String() string](#OCIImageRef.String) - - [func (i \*OCIImageRef) UnmarshalJSON(b \[\]byte) - error](#OCIImageRef.UnmarshalJSON) + - [func (i \*OCIImageRef) UnmarshalJSON(b \[\]byte) (err + error)](#OCIImageRef.UnmarshalJSON) - [type Object](#Object) - [type ObjectMeta](#ObjectMeta) - [func (o \*ObjectMeta) GetAnnotation(key string) @@ -260,7 +260,7 @@ func (k Kind) Title() string Returns a title case string representation of the Kind -## type [OCIContentID](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=1961:2202#L83) +## type [OCIContentID](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=2112:2353#L85) ``` go type OCIContentID struct { @@ -268,7 +268,7 @@ type OCIContentID struct { } ``` -### func [ParseOCIContentID](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=1532:1589#L60) +### func [ParseOCIContentID](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=1683:1740#L62) ``` go func ParseOCIContentID(str string) (*OCIContentID, error) @@ -283,7 +283,7 @@ Given a full repo digest, such as it will be parsed into the OCI registry format, encoded as “oci://@”. -### func (\*OCIContentID) [Digest](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3137:3182#L127) +### func (\*OCIContentID) [Digest](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3288:3333#L129) ``` go func (o *OCIContentID) Digest() digest.Digest @@ -291,7 +291,7 @@ func (o *OCIContentID) Digest() digest.Digest Digest gets the digest of the content ID -### func (\*OCIContentID) [Local](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3023:3058#L122) +### func (\*OCIContentID) [Local](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3174:3209#L124) ``` go func (o *OCIContentID) Local() bool @@ -300,13 +300,13 @@ func (o *OCIContentID) Local() bool Local returns true if the image has no repoName, i.e. it’s not available from a registry -### func (\*OCIContentID) [MarshalJSON](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3499:3551#L141) +### func (\*OCIContentID) [MarshalJSON](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3650:3702#L143) ``` go func (o *OCIContentID) MarshalJSON() ([]byte, error) ``` -### func (\*OCIContentID) [RepoDigest](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3301:3356#L132) +### func (\*OCIContentID) [RepoDigest](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3452:3507#L134) ``` go func (o *OCIContentID) RepoDigest() (n reference.Named) @@ -315,24 +315,28 @@ func (o *OCIContentID) RepoDigest() (n reference.Named) RepoDigest returns a repo digest based on the OCIContentID if it is not local -### func (\*OCIContentID) [String](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=2285:2323#L91) +### func (\*OCIContentID) [String](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=2436:2474#L93) ``` go func (o *OCIContentID) String() string ``` -### func (\*OCIContentID) [UnmarshalJSON](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3590:3648#L145) +### func (\*OCIContentID) [UnmarshalJSON](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=3741:3799#L147) ``` go func (o *OCIContentID) UnmarshalJSON(b []byte) (err error) ``` -## type [OCIImageRef](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=671:694#L31) +## type [OCIImageRef](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=838:861#L35) ``` go type OCIImageRef string ``` +OCIImageRef is a string by which an OCI runtime can identify an image to +retrieve. It needs to have a tag and usually looks like +“weaveworks/ignite-ubuntu:latest”. + ### func [NewOCIImageRef](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=316:373#L19) ``` go @@ -342,22 +346,22 @@ func NewOCIImageRef(imageStr string) (OCIImageRef, error) NewOCIImageRef parses and normalizes a reference to an OCI (docker) image. -### func (OCIImageRef) [IsUnset](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=794:829#L39) +### func (OCIImageRef) [IsUnset](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=961:996#L43) ``` go func (i OCIImageRef) IsUnset() bool ``` -### func (OCIImageRef) [String](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=734:770#L35) +### func (OCIImageRef) [String](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=901:937#L39) ``` go func (i OCIImageRef) String() string ``` -### func (\*OCIImageRef) [UnmarshalJSON](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=855:906#L43) +### func (\*OCIImageRef) [UnmarshalJSON](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/image.go?s=1022:1079#L47) ``` go -func (i *OCIImageRef) UnmarshalJSON(b []byte) error +func (i *OCIImageRef) UnmarshalJSON(b []byte) (err error) ``` ## type [Object](https://github.com/weaveworks/ignite/tree/master/pkg/apis/meta/v1alpha1/meta.go?s=4245:4680#L186) diff --git a/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go b/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go index 6ccf1f405..b3c717b69 100644 --- a/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go +++ b/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go @@ -100,16 +100,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*OCIImageClaim)(nil), (*ignite.OCIImageClaim)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_OCIImageClaim_To_ignite_OCIImageClaim(a.(*OCIImageClaim), b.(*ignite.OCIImageClaim), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*ignite.OCIImageClaim)(nil), (*OCIImageClaim)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_ignite_OCIImageClaim_To_v1alpha2_OCIImageClaim(a.(*ignite.OCIImageClaim), b.(*OCIImageClaim), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*OCIImageSource)(nil), (*ignite.OCIImageSource)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha2_OCIImageSource_To_ignite_OCIImageSource(a.(*OCIImageSource), b.(*ignite.OCIImageSource), scope) }); err != nil { @@ -350,9 +340,7 @@ func Convert_ignite_Image_To_v1alpha2_Image(in *ignite.Image, out *Image, s conv } func autoConvert_v1alpha2_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.ImageSpec, s conversion.Scope) error { - if err := Convert_v1alpha2_OCIImageClaim_To_ignite_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) return nil } @@ -362,9 +350,7 @@ func Convert_v1alpha2_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.I } func autoConvert_ignite_ImageSpec_To_v1alpha2_ImageSpec(in *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) error { - if err := Convert_ignite_OCIImageClaim_To_v1alpha2_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) return nil } @@ -432,9 +418,7 @@ func Convert_ignite_Kernel_To_v1alpha2_Kernel(in *ignite.Kernel, out *Kernel, s } func autoConvert_v1alpha2_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignite.KernelSpec, s conversion.Scope) error { - if err := Convert_v1alpha2_OCIImageClaim_To_ignite_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) return nil } @@ -444,9 +428,7 @@ func Convert_v1alpha2_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignit } func autoConvert_ignite_KernelSpec_To_v1alpha2_KernelSpec(in *ignite.KernelSpec, out *KernelSpec, s conversion.Scope) error { - if err := Convert_ignite_OCIImageClaim_To_v1alpha2_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) return nil } @@ -481,28 +463,6 @@ func Convert_ignite_KernelStatus_To_v1alpha2_KernelStatus(in *ignite.KernelStatu return autoConvert_ignite_KernelStatus_To_v1alpha2_KernelStatus(in, out, s) } -func autoConvert_v1alpha2_OCIImageClaim_To_ignite_OCIImageClaim(in *OCIImageClaim, out *ignite.OCIImageClaim, s conversion.Scope) error { - out.Type = ignite.ImageSourceType(in.Type) - out.Ref = v1alpha1.OCIImageRef(in.Ref) - return nil -} - -// Convert_v1alpha2_OCIImageClaim_To_ignite_OCIImageClaim is an autogenerated conversion function. -func Convert_v1alpha2_OCIImageClaim_To_ignite_OCIImageClaim(in *OCIImageClaim, out *ignite.OCIImageClaim, s conversion.Scope) error { - return autoConvert_v1alpha2_OCIImageClaim_To_ignite_OCIImageClaim(in, out, s) -} - -func autoConvert_ignite_OCIImageClaim_To_v1alpha2_OCIImageClaim(in *ignite.OCIImageClaim, out *OCIImageClaim, s conversion.Scope) error { - out.Type = ImageSourceType(in.Type) - out.Ref = v1alpha1.OCIImageRef(in.Ref) - return nil -} - -// Convert_ignite_OCIImageClaim_To_v1alpha2_OCIImageClaim is an autogenerated conversion function. -func Convert_ignite_OCIImageClaim_To_v1alpha2_OCIImageClaim(in *ignite.OCIImageClaim, out *OCIImageClaim, s conversion.Scope) error { - return autoConvert_ignite_OCIImageClaim_To_v1alpha2_OCIImageClaim(in, out, s) -} - func autoConvert_v1alpha2_OCIImageSource_To_ignite_OCIImageSource(in *OCIImageSource, out *ignite.OCIImageSource, s conversion.Scope) error { out.ID = (*v1alpha1.OCIContentID)(unsafe.Pointer(in.ID)) out.Size = in.Size @@ -708,9 +668,7 @@ func Convert_ignite_VM_To_v1alpha2_VM(in *ignite.VM, out *VM, s conversion.Scope } func autoConvert_v1alpha2_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ignite.VMImageSpec, s conversion.Scope) error { - if err := Convert_v1alpha2_OCIImageClaim_To_ignite_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) return nil } @@ -720,9 +678,7 @@ func Convert_v1alpha2_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ig } func autoConvert_ignite_VMImageSpec_To_v1alpha2_VMImageSpec(in *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) error { - if err := Convert_ignite_OCIImageClaim_To_v1alpha2_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) return nil } @@ -732,9 +688,7 @@ func Convert_ignite_VMImageSpec_To_v1alpha2_VMImageSpec(in *ignite.VMImageSpec, } func autoConvert_v1alpha2_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out *ignite.VMKernelSpec, s conversion.Scope) error { - if err := Convert_v1alpha2_OCIImageClaim_To_ignite_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) out.CmdLine = in.CmdLine return nil } @@ -745,9 +699,7 @@ func Convert_v1alpha2_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out } func autoConvert_ignite_VMKernelSpec_To_v1alpha2_VMKernelSpec(in *ignite.VMKernelSpec, out *VMKernelSpec, s conversion.Scope) error { - if err := Convert_ignite_OCIImageClaim_To_v1alpha2_OCIImageClaim(&in.OCIClaim, &out.OCIClaim, s); err != nil { - return err - } + out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) out.CmdLine = in.CmdLine return nil } diff --git a/pkg/apis/ignite/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/ignite/v1alpha2/zz_generated.deepcopy.go index e309a3e11..c7a2f6ecf 100644 --- a/pkg/apis/ignite/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/ignite/v1alpha2/zz_generated.deepcopy.go @@ -74,7 +74,6 @@ func (in *Image) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ImageSpec) DeepCopyInto(out *ImageSpec) { *out = *in - out.OCIClaim = in.OCIClaim return } @@ -136,7 +135,6 @@ func (in *Kernel) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KernelSpec) DeepCopyInto(out *KernelSpec) { *out = *in - out.OCIClaim = in.OCIClaim return } @@ -167,22 +165,6 @@ func (in *KernelStatus) DeepCopy() *KernelStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIImageClaim) DeepCopyInto(out *OCIImageClaim) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIImageClaim. -func (in *OCIImageClaim) DeepCopy() *OCIImageClaim { - if in == nil { - return nil - } - out := new(OCIImageClaim) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OCIImageSource) DeepCopyInto(out *OCIImageSource) { *out = *in @@ -359,7 +341,6 @@ func (in *VM) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VMImageSpec) DeepCopyInto(out *VMImageSpec) { *out = *in - out.OCIClaim = in.OCIClaim return } @@ -376,7 +357,6 @@ func (in *VMImageSpec) DeepCopy() *VMImageSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VMKernelSpec) DeepCopyInto(out *VMKernelSpec) { *out = *in - out.OCIClaim = in.OCIClaim return } diff --git a/pkg/apis/ignite/v1alpha2/zz_generated.defaults.go b/pkg/apis/ignite/v1alpha2/zz_generated.defaults.go index d93a73274..ad162b08d 100644 --- a/pkg/apis/ignite/v1alpha2/zz_generated.defaults.go +++ b/pkg/apis/ignite/v1alpha2/zz_generated.defaults.go @@ -12,29 +12,17 @@ import ( // Public to allow building arbitrary schemes. // All generated defaulters are covering - they call all nested defaulters. func RegisterDefaults(scheme *runtime.Scheme) error { - scheme.AddTypeDefaultingFunc(&Image{}, func(obj interface{}) { SetObjectDefaults_Image(obj.(*Image)) }) - scheme.AddTypeDefaultingFunc(&Kernel{}, func(obj interface{}) { SetObjectDefaults_Kernel(obj.(*Kernel)) }) scheme.AddTypeDefaultingFunc(&Pool{}, func(obj interface{}) { SetObjectDefaults_Pool(obj.(*Pool)) }) scheme.AddTypeDefaultingFunc(&VM{}, func(obj interface{}) { SetObjectDefaults_VM(obj.(*VM)) }) return nil } -func SetObjectDefaults_Image(in *Image) { - SetDefaults_OCIImageClaim(&in.Spec.OCIClaim) -} - -func SetObjectDefaults_Kernel(in *Kernel) { - SetDefaults_OCIImageClaim(&in.Spec.OCIClaim) -} - func SetObjectDefaults_Pool(in *Pool) { SetDefaults_PoolSpec(&in.Spec) } func SetObjectDefaults_VM(in *VM) { SetDefaults_VMSpec(&in.Spec) - SetDefaults_OCIImageClaim(&in.Spec.Image.OCIClaim) SetDefaults_VMKernelSpec(&in.Spec.Kernel) - SetDefaults_OCIImageClaim(&in.Spec.Kernel.OCIClaim) SetDefaults_VMNetworkSpec(&in.Spec.Network) } diff --git a/pkg/apis/ignite/zz_generated.deepcopy.go b/pkg/apis/ignite/zz_generated.deepcopy.go index bc2f2edfb..f82809b8b 100644 --- a/pkg/apis/ignite/zz_generated.deepcopy.go +++ b/pkg/apis/ignite/zz_generated.deepcopy.go @@ -74,7 +74,6 @@ func (in *Image) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ImageSpec) DeepCopyInto(out *ImageSpec) { *out = *in - out.OCIClaim = in.OCIClaim return } @@ -136,7 +135,6 @@ func (in *Kernel) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KernelSpec) DeepCopyInto(out *KernelSpec) { *out = *in - out.OCIClaim = in.OCIClaim return } @@ -167,22 +165,6 @@ func (in *KernelStatus) DeepCopy() *KernelStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIImageClaim) DeepCopyInto(out *OCIImageClaim) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIImageClaim. -func (in *OCIImageClaim) DeepCopy() *OCIImageClaim { - if in == nil { - return nil - } - out := new(OCIImageClaim) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OCIImageSource) DeepCopyInto(out *OCIImageSource) { *out = *in @@ -359,7 +341,6 @@ func (in *VM) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VMImageSpec) DeepCopyInto(out *VMImageSpec) { *out = *in - out.OCIClaim = in.OCIClaim return } @@ -376,7 +357,6 @@ func (in *VMImageSpec) DeepCopy() *VMImageSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VMKernelSpec) DeepCopyInto(out *VMKernelSpec) { *out = *in - out.OCIClaim = in.OCIClaim return } diff --git a/pkg/openapi/openapi_generated.go b/pkg/openapi/openapi_generated.go index a83f6e38a..d24ac8114 100644 --- a/pkg/openapi/openapi_generated.go +++ b/pkg/openapi/openapi_generated.go @@ -41,7 +41,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.Kernel": schema_pkg_apis_ignite_v1alpha2_Kernel(ref), "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.KernelSpec": schema_pkg_apis_ignite_v1alpha2_KernelSpec(ref), "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.KernelStatus": schema_pkg_apis_ignite_v1alpha2_KernelStatus(ref), - "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageClaim": schema_pkg_apis_ignite_v1alpha2_OCIImageClaim(ref), "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageSource": schema_pkg_apis_ignite_v1alpha2_OCIImageSource(ref), "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.Pool": schema_pkg_apis_ignite_v1alpha2_Pool(ref), "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.PoolDevice": schema_pkg_apis_ignite_v1alpha2_PoolDevice(ref), @@ -807,17 +806,16 @@ func schema_pkg_apis_ignite_v1alpha2_ImageSpec(ref common.ReferenceCallback) com Description: "ImageSpec declares what the image contains", Type: []string{"object"}, Properties: map[string]spec.Schema{ - "ociClaim": { + "oci": { SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageClaim"), + Type: []string{"string"}, + Format: "", }, }, }, - Required: []string{"ociClaim"}, + Required: []string{"oci"}, }, }, - Dependencies: []string{ - "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageClaim"}, } } @@ -887,17 +885,16 @@ func schema_pkg_apis_ignite_v1alpha2_KernelSpec(ref common.ReferenceCallback) co Description: "KernelSpec describes the properties of a kernel", Type: []string{"object"}, Properties: map[string]spec.Schema{ - "ociClaim": { + "oci": { SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageClaim"), + Type: []string{"string"}, + Format: "", }, }, }, - Required: []string{"ociClaim"}, + Required: []string{"oci"}, }, }, - Dependencies: []string{ - "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageClaim"}, } } @@ -928,34 +925,6 @@ func schema_pkg_apis_ignite_v1alpha2_KernelStatus(ref common.ReferenceCallback) } } -func schema_pkg_apis_ignite_v1alpha2_OCIImageClaim(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "OCIImageClaim defines a claim for importing an OCI image", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "type": { - SchemaProps: spec.SchemaProps{ - Description: "Type defines how the image should be imported", - Type: []string{"string"}, - Format: "", - }, - }, - "ref": { - SchemaProps: spec.SchemaProps{ - Description: "Ref defines the reference to use when talking to the backend. This is most commonly the image name, followed by a tag. Other supported ways are $registry/$user/$image@sha256:$digest This ref is also used as ObjectMeta.Name for kinds Images and Kernels", - Type: []string{"string"}, - Format: "", - }, - }, - }, - Required: []string{"type", "ref"}, - }, - }, - } -} - func schema_pkg_apis_ignite_v1alpha2_OCIImageSource(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1206,17 +1175,16 @@ func schema_pkg_apis_ignite_v1alpha2_VMImageSpec(ref common.ReferenceCallback) c SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "ociClaim": { + "oci": { SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageClaim"), + Type: []string{"string"}, + Format: "", }, }, }, - Required: []string{"ociClaim"}, + Required: []string{"oci"}, }, }, - Dependencies: []string{ - "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageClaim"}, } } @@ -1226,9 +1194,10 @@ func schema_pkg_apis_ignite_v1alpha2_VMKernelSpec(ref common.ReferenceCallback) SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "ociClaim": { + "oci": { SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageClaim"), + Type: []string{"string"}, + Format: "", }, }, "cmdLine": { @@ -1238,11 +1207,9 @@ func schema_pkg_apis_ignite_v1alpha2_VMKernelSpec(ref common.ReferenceCallback) }, }, }, - Required: []string{"ociClaim"}, + Required: []string{"oci"}, }, }, - Dependencies: []string{ - "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageClaim"}, } } diff --git a/pkg/openapi/violations.txt b/pkg/openapi/violations.txt index 3ba10b204..abfa81023 100644 --- a/pkg/openapi/violations.txt +++ b/pkg/openapi/violations.txt @@ -6,6 +6,10 @@ API rule violation: list_type_missing,github.com/weaveworks/ignite/pkg/apis/igni API rule violation: list_type_missing,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMStorageSpec,VolumeMounts API rule violation: list_type_missing,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMStorageSpec,Volumes API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha1,VMSpec,CPUs +API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,ImageSpec,OCIRef +API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,KernelSpec,OCIRef +API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMImageSpec,OCIRef +API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMKernelSpec,OCIRef API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMSpec,CPUs API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/meta/v1alpha1,DMID,index API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/meta/v1alpha1,OCIContentID,digest From 01e08500de0974af050674e0e35cf0760d1cf76d Mon Sep 17 00:00:00 2001 From: Dennis Marttinen Date: Fri, 9 Aug 2019 20:58:40 +0300 Subject: [PATCH 5/6] Fix small typo --- pkg/operations/reconcile/reconcile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/operations/reconcile/reconcile.go b/pkg/operations/reconcile/reconcile.go index d6679d969..bb9c06a92 100644 --- a/pkg/operations/reconcile/reconcile.go +++ b/pkg/operations/reconcile/reconcile.go @@ -131,7 +131,7 @@ func ensureOCIImages(vm *api.VM) error { // Populate relevant data from the Kernel on the VM object vm.SetKernel(kernel) - // Save the file to disk. This will also write the file to /var/lib/firecracker for compability + // Save the file to disk. This will also write the file to /var/lib/firecracker for compatibility. return c.VMs().Set(vm) } From 9d6ab9eba0540a987b683ecee1cba2b1dbaef7f2 Mon Sep 17 00:00:00 2001 From: Dennis Marttinen Date: Mon, 12 Aug 2019 12:40:56 +0300 Subject: [PATCH 6/6] Address feedback, OCIRef -> OCI, remove extras, consolidate conversion --- cmd/ignite/cmd/vmcmd/create.go | 2 +- cmd/ignite/run/create.go | 6 +- cmd/ignite/run/ps.go | 2 +- docs/api/ignite_v1alpha1.md | 34 ++++++-- docs/api/ignite_v1alpha2.md | 78 ++++++++----------- pkg/apis/ignite/helpers.go | 11 +-- pkg/apis/ignite/types.go | 16 +--- pkg/apis/ignite/v1alpha1/conversion.go | 62 +++++++-------- .../v1alpha1/zz_generated.conversion.go | 8 +- pkg/apis/ignite/v1alpha2/defaults.go | 4 +- pkg/apis/ignite/v1alpha2/types.go | 16 +--- .../v1alpha2/zz_generated.conversion.go | 16 ++-- pkg/apis/ignite/validation/validation.go | 21 +---- pkg/openapi/violations.txt | 4 - pkg/operations/import.go | 4 +- pkg/operations/lookup/lookup.go | 4 +- pkg/operations/reconcile/reconcile.go | 4 +- 17 files changed, 120 insertions(+), 172 deletions(-) diff --git a/cmd/ignite/cmd/vmcmd/create.go b/cmd/ignite/cmd/vmcmd/create.go index 838fe9743..0e491d3ee 100644 --- a/cmd/ignite/cmd/vmcmd/create.go +++ b/cmd/ignite/cmd/vmcmd/create.go @@ -74,7 +74,7 @@ func addCreateFlags(fs *pflag.FlagSet, cf *run.CreateFlags) { // Register more complex flags with their own flag types cmdutil.SizeVar(fs, &cf.VM.Spec.Memory, "memory", "Amount of RAM to allocate for the VM") cmdutil.SizeVarP(fs, &cf.VM.Spec.DiskSize, "size", "s", "VM filesystem size, for example 5GB or 2048MB") - cmdutil.OCIImageRefVarP(fs, &cf.VM.Spec.Kernel.OCIRef, "kernel-image", "k", "Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules") + cmdutil.OCIImageRefVarP(fs, &cf.VM.Spec.Kernel.OCI, "kernel-image", "k", "Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules") cmdutil.NetworkModeVar(fs, &cf.VM.Spec.Network.Mode) cmdutil.SSHVar(fs, &cf.SSH) cmdutil.VolumeVarP(fs, &cf.VM.Spec.Storage, "volumes", "v", "Expose block devices from the host inside the VM") diff --git a/cmd/ignite/run/create.go b/cmd/ignite/run/create.go index be90145b6..82a794280 100644 --- a/cmd/ignite/run/create.go +++ b/cmd/ignite/run/create.go @@ -46,7 +46,7 @@ func (cf *CreateFlags) constructVMFromCLI(args []string) error { return err } - cf.VM.Spec.Image.OCIRef = ociRef + cf.VM.Spec.Image.OCI = ociRef } // Parse the --copy-files flag @@ -91,7 +91,7 @@ func (cf *CreateFlags) NewCreateOptions(args []string) (*createOptions, error) { // Get the image, or import it if it doesn't exist var err error - co.image, err = operations.FindOrImportImage(providers.Client, cf.VM.Spec.Image.OCIRef) + co.image, err = operations.FindOrImportImage(providers.Client, cf.VM.Spec.Image.OCI) if err != nil { return nil, err } @@ -100,7 +100,7 @@ func (cf *CreateFlags) NewCreateOptions(args []string) (*createOptions, error) { cf.VM.SetImage(co.image) // Get the kernel, or import it if it doesn't exist - co.kernel, err = operations.FindOrImportKernel(providers.Client, cf.VM.Spec.Kernel.OCIRef) + co.kernel, err = operations.FindOrImportKernel(providers.Client, cf.VM.Spec.Kernel.OCI) if err != nil { return nil, err } diff --git a/cmd/ignite/run/ps.go b/cmd/ignite/run/ps.go index de8314bad..f7629c1ec 100644 --- a/cmd/ignite/run/ps.go +++ b/cmd/ignite/run/ps.go @@ -30,7 +30,7 @@ func Ps(po *psOptions) error { o.Write("VM ID", "IMAGE", "KERNEL", "SIZE", "CPUS", "MEMORY", "CREATED", "STATUS", "IPS", "PORTS", "NAME") for _, vm := range po.allVMs { - o.Write(vm.GetUID(), vm.Spec.Image.OCIRef, vm.Spec.Kernel.OCIRef, + o.Write(vm.GetUID(), vm.Spec.Image.OCI, vm.Spec.Kernel.OCI, vm.Spec.DiskSize, vm.Spec.CPUs, vm.Spec.Memory, vm.GetCreated(), formatStatus(vm), vm.Status.IPAddresses, vm.Spec.Network.Ports, vm.GetName()) } diff --git a/docs/api/ignite_v1alpha1.md b/docs/api/ignite_v1alpha1.md index 361762a91..3e7e97637 100644 --- a/docs/api/ignite_v1alpha1.md +++ b/docs/api/ignite_v1alpha1.md @@ -25,6 +25,9 @@ Convert\_ignite\_OCIImageSource\_To\_v1alpha1\_OCIImageSource(in *ignite.OCIImageSource, out *OCIImageSource, s conversion.Scope) error](#Convert_ignite_OCIImageSource_To_v1alpha1_OCIImageSource) + - [func Convert\_ignite\_OCI\_To\_v1alpha1\_OCIClaim(in + *meta.OCIImageRef, out *OCIImageClaim) + error](#Convert_ignite_OCI_To_v1alpha1_OCIClaim) - [func Convert\_ignite\_VMImageSpec\_To\_v1alpha1\_VMImageSpec(in *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) error](#Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec) @@ -43,6 +46,9 @@ - [func Convert\_v1alpha1\_KernelSpec\_To\_ignite\_KernelSpec(in *KernelSpec, out *ignite.KernelSpec, s conversion.Scope) error](#Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec) + - [func Convert\_v1alpha1\_OCIClaim\_To\_ignite\_OCI(in + *OCIImageClaim, out *meta.OCIImageRef) + error](#Convert_v1alpha1_OCIClaim_To_ignite_OCI) - [func Convert\_v1alpha1\_OCIImageSource\_To\_ignite\_OCIImageSource(in *OCIImageSource, out *ignite.OCIImageSource, s conversion.Scope) @@ -148,7 +154,7 @@ var SchemeGroupVersion = schema.GroupVersion{ SchemeGroupVersion is group version used to register these objects -## func [Convert\_ignite\_ImageSpec\_To\_v1alpha1\_ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=3721:3836#L89) +## func [Convert\_ignite\_ImageSpec\_To\_v1alpha1\_ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=4265:4380#L107) ``` go func Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) error @@ -157,7 +163,7 @@ func Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in *ignite.ImageSpec, out *I Convert\_ignite\_ImageSpec\_To\_v1alpha1\_ImageSpec calls the autogenerated conversion function along with custom conversion logic -## func [Convert\_ignite\_KernelSpec\_To\_v1alpha1\_KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=4676:4795#L114) +## func [Convert\_ignite\_KernelSpec\_To\_v1alpha1\_KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=5121:5240#L125) ``` go func Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec(in *ignite.KernelSpec, out *KernelSpec, s conversion.Scope) error @@ -175,7 +181,13 @@ func Convert_ignite_OCIImageSource_To_v1alpha1_OCIImageSource(in *ignite.OCIImag Convert\_ignite\_OCIImageSource\_To\_v1alpha1\_OCIImageSource calls the autogenerated conversion function along with custom conversion logic -## func [Convert\_ignite\_VMImageSpec\_To\_v1alpha1\_VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=5647:5770#L139) +## func [Convert\_ignite\_OCI\_To\_v1alpha1\_OCIClaim](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=3825:3917#L96) + +``` go +func Convert_ignite_OCI_To_v1alpha1_OCIClaim(in *meta.OCIImageRef, out *OCIImageClaim) error +``` + +## func [Convert\_ignite\_VMImageSpec\_To\_v1alpha1\_VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=5993:6116#L143) ``` go func Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) error @@ -184,7 +196,7 @@ func Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in *ignite.VMImageSpec, Convert\_ignite\_VMImageSpec\_To\_v1alpha1\_VMImageSpec calls the autogenerated conversion function along with custom conversion logic -## func [Convert\_ignite\_VMKernelSpec\_To\_v1alpha1\_VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=6634:6761#L164) +## func [Convert\_ignite\_VMKernelSpec\_To\_v1alpha1\_VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=6881:7008#L161) ``` go func Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(in *ignite.VMKernelSpec, out *VMKernelSpec, s conversion.Scope) error @@ -211,7 +223,7 @@ func Convert_ignite_VMStatus_To_v1alpha1_VMStatus(in *ignite.VMStatus, out *VMSt Convert\_ignite\_VMStatus\_To\_v1alpha1\_VMStatus calls the autogenerated conversion function along with custom conversion logic -## func [Convert\_v1alpha1\_ImageSpec\_To\_ignite\_ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=4219:4334#L102) +## func [Convert\_v1alpha1\_ImageSpec\_To\_ignite\_ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=4692:4807#L116) ``` go func Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.ImageSpec, s conversion.Scope) error @@ -220,7 +232,7 @@ func Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.I Convert\_v1alpha1\_ImageSpec\_To\_ignite\_ImageSpec calls the autogenerated conversion function along with custom conversion logic -## func [Convert\_v1alpha1\_KernelSpec\_To\_ignite\_KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=5182:5301#L127) +## func [Convert\_v1alpha1\_KernelSpec\_To\_ignite\_KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=5556:5675#L134) ``` go func Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignite.KernelSpec, s conversion.Scope) error @@ -229,6 +241,12 @@ func Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignit Convert\_v1alpha1\_KernelSpec\_To\_ignite\_KernelSpec calls the autogenerated conversion function along with custom conversion logic +## func [Convert\_v1alpha1\_OCIClaim\_To\_ignite\_OCI](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=3592:3684#L88) + +``` go +func Convert_v1alpha1_OCIClaim_To_ignite_OCI(in *OCIImageClaim, out *meta.OCIImageRef) error +``` + ## func [Convert\_v1alpha1\_OCIImageSource\_To\_ignite\_OCIImageSource](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=2775:2916#L68) ``` go @@ -238,7 +256,7 @@ func Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(in *OCIImageSource Convert\_v1alpha1\_OCIImageSource\_To\_ignite\_OCIImageSource calls the autogenerated conversion function along with custom conversion logic -## func [Convert\_v1alpha1\_VMImageSpec\_To\_ignite\_VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=6161:6284#L152) +## func [Convert\_v1alpha1\_VMImageSpec\_To\_ignite\_VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=6436:6559#L152) ``` go func Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ignite.VMImageSpec, s conversion.Scope) error @@ -247,7 +265,7 @@ func Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ig Convert\_v1alpha1\_VMImageSpec\_To\_ignite\_VMImageSpec calls the autogenerated conversion function along with custom conversion logic -## func [Convert\_v1alpha1\_VMKernelSpec\_To\_ignite\_VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=7156:7283#L177) +## func [Convert\_v1alpha1\_VMKernelSpec\_To\_ignite\_VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=7332:7459#L170) ``` go func Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out *ignite.VMKernelSpec, s conversion.Scope) error diff --git a/docs/api/ignite_v1alpha2.md b/docs/api/ignite_v1alpha2.md index 687707943..59329d6b3 100644 --- a/docs/api/ignite_v1alpha2.md +++ b/docs/api/ignite_v1alpha2.md @@ -24,7 +24,6 @@ - [type BlockDeviceVolume](#BlockDeviceVolume) - [type FileMapping](#FileMapping) - [type Image](#Image) - - [type ImageSourceType](#ImageSourceType) - [type ImageSpec](#ImageSpec) - [type ImageStatus](#ImageStatus) - [type Kernel](#Kernel) @@ -114,7 +113,7 @@ func SetDefaults_PoolSpec(obj *PoolSpec) func SetDefaults_VMKernelSpec(obj *VMKernelSpec) ``` -## func [SetDefaults\_VMNetworkSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=1418:1468#L60) +## func [SetDefaults\_VMNetworkSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=1412:1462#L60) ``` go func SetDefaults_VMNetworkSpec(obj *VMNetworkSpec) @@ -126,7 +125,7 @@ func SetDefaults_VMNetworkSpec(obj *VMNetworkSpec) func SetDefaults_VMSpec(obj *VMSpec) ``` -## type [BlockDeviceVolume](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7306:7366#L201) +## type [BlockDeviceVolume](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7062:7122#L193) ``` go type BlockDeviceVolume struct { @@ -136,7 +135,7 @@ type BlockDeviceVolume struct { BlockDeviceVolume defines a block device on the host -## type [FileMapping](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7601:7696#L212) +## type [FileMapping](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7357:7452#L204) ``` go type FileMapping struct { @@ -165,32 +164,17 @@ type Image struct { Image represents a cached OCI image ready to be used with Ignite +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -## type [ImageSourceType](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=991:1018#L34) - -``` go -type ImageSourceType string -``` - -ImageSourceType is an enum of different supported Image Source Types - -``` go -const ( - // ImageSourceTypeDocker defines that the image is imported from Docker - ImageSourceTypeDocker ImageSourceType = "Docker" -) -``` - -## type [ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=854:917#L29) +## type [ImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=854:914#L29) ``` go type ImageSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` } ``` ImageSpec declares what the image contains -## type [ImageStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1540:1689#L51) +## type [ImageStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1302:1451#L43) ``` go type ImageStatus struct { @@ -201,7 +185,7 @@ type ImageStatus struct { ImageStatus defines the status of the image -## type [Kernel](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4068:4535#L115) +## type [Kernel](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=3830:4297#L107) ``` go type Kernel struct { @@ -221,17 +205,17 @@ kernels This file is stored in /var/lib/firecracker/kernels/{oci-image-digest}/metadata.json +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -## type [KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4588:4757#L127) +## type [KernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4350:4516#L119) ``` go type KernelSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` } ``` KernelSpec describes the properties of a kernel -## type [KernelStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4808:4924#L134) +## type [KernelStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4567:4683#L126) ``` go type KernelStatus struct { @@ -242,7 +226,7 @@ type KernelStatus struct { KernelStatus describes the status of a kernel -## type [NetworkMode](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8050:8073#L227) +## type [NetworkMode](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7806:7829#L219) ``` go type NetworkMode string @@ -259,13 +243,13 @@ const ( ) ``` -### func (NetworkMode) [String](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8113:8150#L231) +### func (NetworkMode) [String](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7869:7906#L223) ``` go func (nm NetworkMode) String() string ``` -## type [OCIImageSource](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1259:1491#L43) +## type [OCIImageSource](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1021:1253#L35) ``` go type OCIImageSource struct { @@ -279,7 +263,7 @@ type OCIImageSource struct { OCIImageSource specifies how the OCI image was imported. It is the status variant of OCIImageClaim -## type [Pool](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1964:2144#L60) +## type [Pool](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1726:1906#L52) ``` go type Pool struct { @@ -295,7 +279,7 @@ snapshotter part of Ignite, and the file (existing as a singleton) is present at /var/lib/firecracker/snapshotter/pool.json +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -## type [PoolDevice](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=3435:3825#L102) +## type [PoolDevice](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=3197:3587#L94) ``` go type PoolDevice struct { @@ -311,7 +295,7 @@ type PoolDevice struct { PoolDevice defines one device in the pool -## type [PoolDeviceType](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=3164:3190#L92) +## type [PoolDeviceType](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=2926:2952#L84) ``` go type PoolDeviceType string @@ -326,7 +310,7 @@ const ( ) ``` -## type [PoolSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=2191:2904#L70) +## type [PoolSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=1953:2666#L62) ``` go type PoolSpec struct { @@ -347,7 +331,7 @@ type PoolSpec struct { PoolSpec defines the Pool’s specification -## type [PoolStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=2954:3162#L86) +## type [PoolStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=2716:2924#L78) ``` go type PoolStatus struct { @@ -359,7 +343,7 @@ type PoolStatus struct { PoolStatus defines the Pool’s current status -## type [Runtime](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8546:8592#L244) +## type [Runtime](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8302:8348#L236) ``` go type Runtime struct { @@ -369,7 +353,7 @@ type Runtime struct { Runtime specifies the VM’s runtime information -## type [SSH](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7916:7993#L221) +## type [SSH](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7672:7749#L213) ``` go type SSH struct { @@ -394,7 +378,7 @@ func (s *SSH) MarshalJSON() ([]byte, error) func (s *SSH) UnmarshalJSON(b []byte) error ``` -## type [VM](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=5126:5581#L142) +## type [VM](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=4885:5340#L134) ``` go type VM struct { @@ -413,24 +397,24 @@ VM represents a virtual machine run by Firecracker These files are stored in /var/lib/firecracker/vm/{vm-id}/metadata.json +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -## type [VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6564:6629#L174) +## type [VMImageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6323:6385#L166) ``` go type VMImageSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` } ``` -## type [VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6631:6751#L178) +## type [VMKernelSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6387:6507#L170) ``` go type VMKernelSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` CmdLine string `json:"cmdLine,omitempty"` } ``` -## type [VMNetworkSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6753:6871#L183) +## type [VMNetworkSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6509:6627#L175) ``` go type VMNetworkSpec struct { @@ -439,7 +423,7 @@ type VMNetworkSpec struct { } ``` -## type [VMSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=5629:6562#L154) +## type [VMSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=5388:6321#L146) ``` go type VMSpec struct { @@ -465,7 +449,7 @@ type VMSpec struct { VMSpec describes the configuration of a VM -## type [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8633:8972#L249) +## type [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8389:8728#L241) ``` go type VMStatus struct { @@ -480,7 +464,7 @@ type VMStatus struct { VMStatus defines the status of a VM -## type [VMStorageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6932:7076#L189) +## type [VMStorageSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6688:6832#L181) ``` go type VMStorageSpec struct { @@ -491,7 +475,7 @@ type VMStorageSpec struct { VMStorageSpec defines the VM’s Volumes and VolumeMounts -## type [Volume](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7117:7248#L195) +## type [Volume](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=6873:7004#L187) ``` go type Volume struct { @@ -502,7 +486,7 @@ type Volume struct { Volume defines named storage volume -## type [VolumeMount](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7438:7534#L206) +## type [VolumeMount](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=7194:7290#L198) ``` go type VolumeMount struct { diff --git a/pkg/apis/ignite/helpers.go b/pkg/apis/ignite/helpers.go index ad77ee3cb..bc9bff321 100644 --- a/pkg/apis/ignite/helpers.go +++ b/pkg/apis/ignite/helpers.go @@ -14,22 +14,15 @@ func GetNetworkModes() []NetworkMode { } } -// GetImageSourceTypes gets the list of available network modes -func GetImageSourceTypes() []ImageSourceType { - return []ImageSourceType{ - ImageSourceTypeDocker, - } -} - // SetImage populates relevant fields to an Image on the VM object func (vm *VM) SetImage(image *Image) { - vm.Spec.Image.OCIRef = image.Spec.OCIRef + vm.Spec.Image.OCI = image.Spec.OCI vm.Status.Image = image.Status.OCISource } // SetKernel populates relevant fields to a Kernel on the VM object func (vm *VM) SetKernel(kernel *Kernel) { - vm.Spec.Kernel.OCIRef = kernel.Spec.OCIRef + vm.Spec.Kernel.OCI = kernel.Spec.OCI vm.Status.Kernel = kernel.Status.OCISource } diff --git a/pkg/apis/ignite/types.go b/pkg/apis/ignite/types.go index 3545ac492..3ef7b3b55 100644 --- a/pkg/apis/ignite/types.go +++ b/pkg/apis/ignite/types.go @@ -27,17 +27,9 @@ type Image struct { // ImageSpec declares what the image contains type ImageSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` } -// ImageSourceType is an enum of different supported Image Source Types -type ImageSourceType string - -const ( - // ImageSourceTypeDocker defines that the image is imported from Docker - ImageSourceTypeDocker ImageSourceType = "Docker" -) - // OCIImageSource specifies how the OCI image was imported. // It is the status variant of OCIImageClaim type OCIImageSource struct { @@ -125,7 +117,7 @@ type Kernel struct { // KernelSpec describes the properties of a kernel type KernelSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` // Optional future feature, support per-kernel specific default command lines // DefaultCmdLine string } @@ -172,11 +164,11 @@ type VMSpec struct { } type VMImageSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` } type VMKernelSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` CmdLine string `json:"cmdLine,omitempty"` } diff --git a/pkg/apis/ignite/v1alpha1/conversion.go b/pkg/apis/ignite/v1alpha1/conversion.go index 36943d5d9..f79be4ad3 100644 --- a/pkg/apis/ignite/v1alpha1/conversion.go +++ b/pkg/apis/ignite/v1alpha1/conversion.go @@ -85,17 +85,31 @@ func Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(in *OCIImageSource return } +func Convert_v1alpha1_OCIClaim_To_ignite_OCI(in *OCIImageClaim, out *meta.OCIImageRef) error { + // Convert the old OCIImageClaim format to meta.OCIImageRef + // by extracting in.Ref and ignoring in.Type + *out = in.Ref + + return nil +} + +func Convert_ignite_OCI_To_v1alpha1_OCIClaim(in *meta.OCIImageRef, out *OCIImageClaim) error { + // Convert meta.OCIImageRef to the old OCIImageClaim format, + // set out.Ref to the OCIImageRef and out.Type to the default + // ImageSourceTypeDocker + out.Ref = *in + out.Type = ImageSourceTypeDocker + + return nil +} + // Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec calls the autogenerated conversion function along with custom conversion logic func Convert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) error { if err := autoConvert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in, out, s); err != nil { return err } - // Convert between the old and new OCI reference format - out.OCIClaim.Ref = in.OCIRef - out.OCIClaim.Type = ImageSourceTypeDocker - - return nil + return Convert_ignite_OCI_To_v1alpha1_OCIClaim(&in.OCI, &out.OCIClaim) } // Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec calls the autogenerated conversion function along with custom conversion logic @@ -104,10 +118,7 @@ func Convert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.I return err } - // Convert between the old and new OCI reference format - out.OCIRef = in.OCIClaim.Ref - - return nil + return Convert_v1alpha1_OCIClaim_To_ignite_OCI(&in.OCIClaim, &out.OCI) } // Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec calls the autogenerated conversion function along with custom conversion logic @@ -116,11 +127,7 @@ func Convert_ignite_KernelSpec_To_v1alpha1_KernelSpec(in *ignite.KernelSpec, out return err } - // Convert between the old and new OCI reference format - out.OCIClaim.Ref = in.OCIRef - out.OCIClaim.Type = ImageSourceTypeDocker - - return nil + return Convert_ignite_OCI_To_v1alpha1_OCIClaim(&in.OCI, &out.OCIClaim) } // Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec calls the autogenerated conversion function along with custom conversion logic @@ -129,10 +136,7 @@ func Convert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignit return err } - // Convert between the old and new OCI reference format - out.OCIRef = in.OCIClaim.Ref - - return nil + return Convert_v1alpha1_OCIClaim_To_ignite_OCI(&in.OCIClaim, &out.OCI) } // Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec calls the autogenerated conversion function along with custom conversion logic @@ -141,11 +145,7 @@ func Convert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in *ignite.VMImageSpec, return err } - // Convert between the old and new OCI reference format - out.OCIClaim.Ref = in.OCIRef - out.OCIClaim.Type = ImageSourceTypeDocker - - return nil + return Convert_ignite_OCI_To_v1alpha1_OCIClaim(&in.OCI, &out.OCIClaim) } // Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec calls the autogenerated conversion function along with custom conversion logic @@ -154,10 +154,7 @@ func Convert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ig return err } - // Convert between the old and new OCI reference format - out.OCIRef = in.OCIClaim.Ref - - return nil + return Convert_v1alpha1_OCIClaim_To_ignite_OCI(&in.OCIClaim, &out.OCI) } // Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec calls the autogenerated conversion function along with custom conversion logic @@ -166,11 +163,7 @@ func Convert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(in *ignite.VMKernelSpe return err } - // Convert between the old and new OCI reference format - out.OCIClaim.Ref = in.OCIRef - out.OCIClaim.Type = ImageSourceTypeDocker - - return nil + return Convert_ignite_OCI_To_v1alpha1_OCIClaim(&in.OCI, &out.OCIClaim) } // Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec calls the autogenerated conversion function along with custom conversion logic @@ -179,8 +172,5 @@ func Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out return err } - // Convert between the old and new OCI reference format - out.OCIRef = in.OCIClaim.Ref - - return nil + return Convert_v1alpha1_OCIClaim_To_ignite_OCI(&in.OCIClaim, &out.OCI) } diff --git a/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go b/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go index b327bd733..34dec34d5 100644 --- a/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go @@ -345,7 +345,7 @@ func autoConvert_v1alpha1_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *igni } func autoConvert_ignite_ImageSpec_To_v1alpha1_ImageSpec(in *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) error { - // WARNING: in.OCIRef requires manual conversion: does not exist in peer-type + // WARNING: in.OCI requires manual conversion: does not exist in peer-type return nil } @@ -413,7 +413,7 @@ func autoConvert_v1alpha1_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *i } func autoConvert_ignite_KernelSpec_To_v1alpha1_KernelSpec(in *ignite.KernelSpec, out *KernelSpec, s conversion.Scope) error { - // WARNING: in.OCIRef requires manual conversion: does not exist in peer-type + // WARNING: in.OCI requires manual conversion: does not exist in peer-type return nil } @@ -624,7 +624,7 @@ func autoConvert_v1alpha1_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out } func autoConvert_ignite_VMImageSpec_To_v1alpha1_VMImageSpec(in *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) error { - // WARNING: in.OCIRef requires manual conversion: does not exist in peer-type + // WARNING: in.OCI requires manual conversion: does not exist in peer-type return nil } @@ -635,7 +635,7 @@ func autoConvert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, } func autoConvert_ignite_VMKernelSpec_To_v1alpha1_VMKernelSpec(in *ignite.VMKernelSpec, out *VMKernelSpec, s conversion.Scope) error { - // WARNING: in.OCIRef requires manual conversion: does not exist in peer-type + // WARNING: in.OCI requires manual conversion: does not exist in peer-type out.CmdLine = in.CmdLine return nil } diff --git a/pkg/apis/ignite/v1alpha2/defaults.go b/pkg/apis/ignite/v1alpha2/defaults.go index 39f36174a..590c2bad1 100644 --- a/pkg/apis/ignite/v1alpha2/defaults.go +++ b/pkg/apis/ignite/v1alpha2/defaults.go @@ -48,8 +48,8 @@ func SetDefaults_VMSpec(obj *VMSpec) { func SetDefaults_VMKernelSpec(obj *VMKernelSpec) { // Default the kernel image if unset - if len(obj.OCIRef) == 0 { - obj.OCIRef, _ = meta.NewOCIImageRef(constants.DEFAULT_KERNEL_IMAGE) + if len(obj.OCI) == 0 { + obj.OCI, _ = meta.NewOCIImageRef(constants.DEFAULT_KERNEL_IMAGE) } if len(obj.CmdLine) == 0 { diff --git a/pkg/apis/ignite/v1alpha2/types.go b/pkg/apis/ignite/v1alpha2/types.go index 91caa7dc1..42065b6b4 100644 --- a/pkg/apis/ignite/v1alpha2/types.go +++ b/pkg/apis/ignite/v1alpha2/types.go @@ -27,17 +27,9 @@ type Image struct { // ImageSpec declares what the image contains type ImageSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` } -// ImageSourceType is an enum of different supported Image Source Types -type ImageSourceType string - -const ( - // ImageSourceTypeDocker defines that the image is imported from Docker - ImageSourceTypeDocker ImageSourceType = "Docker" -) - // OCIImageSource specifies how the OCI image was imported. // It is the status variant of OCIImageClaim type OCIImageSource struct { @@ -125,7 +117,7 @@ type Kernel struct { // KernelSpec describes the properties of a kernel type KernelSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` // Optional future feature, support per-kernel specific default command lines // DefaultCmdLine string } @@ -172,11 +164,11 @@ type VMSpec struct { } type VMImageSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` } type VMKernelSpec struct { - OCIRef meta.OCIImageRef `json:"oci"` + OCI meta.OCIImageRef `json:"oci"` CmdLine string `json:"cmdLine,omitempty"` } diff --git a/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go b/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go index b3c717b69..ddc0c0dab 100644 --- a/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go +++ b/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go @@ -340,7 +340,7 @@ func Convert_ignite_Image_To_v1alpha2_Image(in *ignite.Image, out *Image, s conv } func autoConvert_v1alpha2_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.ImageSpec, s conversion.Scope) error { - out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) + out.OCI = v1alpha1.OCIImageRef(in.OCI) return nil } @@ -350,7 +350,7 @@ func Convert_v1alpha2_ImageSpec_To_ignite_ImageSpec(in *ImageSpec, out *ignite.I } func autoConvert_ignite_ImageSpec_To_v1alpha2_ImageSpec(in *ignite.ImageSpec, out *ImageSpec, s conversion.Scope) error { - out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) + out.OCI = v1alpha1.OCIImageRef(in.OCI) return nil } @@ -418,7 +418,7 @@ func Convert_ignite_Kernel_To_v1alpha2_Kernel(in *ignite.Kernel, out *Kernel, s } func autoConvert_v1alpha2_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignite.KernelSpec, s conversion.Scope) error { - out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) + out.OCI = v1alpha1.OCIImageRef(in.OCI) return nil } @@ -428,7 +428,7 @@ func Convert_v1alpha2_KernelSpec_To_ignite_KernelSpec(in *KernelSpec, out *ignit } func autoConvert_ignite_KernelSpec_To_v1alpha2_KernelSpec(in *ignite.KernelSpec, out *KernelSpec, s conversion.Scope) error { - out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) + out.OCI = v1alpha1.OCIImageRef(in.OCI) return nil } @@ -668,7 +668,7 @@ func Convert_ignite_VM_To_v1alpha2_VM(in *ignite.VM, out *VM, s conversion.Scope } func autoConvert_v1alpha2_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ignite.VMImageSpec, s conversion.Scope) error { - out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) + out.OCI = v1alpha1.OCIImageRef(in.OCI) return nil } @@ -678,7 +678,7 @@ func Convert_v1alpha2_VMImageSpec_To_ignite_VMImageSpec(in *VMImageSpec, out *ig } func autoConvert_ignite_VMImageSpec_To_v1alpha2_VMImageSpec(in *ignite.VMImageSpec, out *VMImageSpec, s conversion.Scope) error { - out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) + out.OCI = v1alpha1.OCIImageRef(in.OCI) return nil } @@ -688,7 +688,7 @@ func Convert_ignite_VMImageSpec_To_v1alpha2_VMImageSpec(in *ignite.VMImageSpec, } func autoConvert_v1alpha2_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out *ignite.VMKernelSpec, s conversion.Scope) error { - out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) + out.OCI = v1alpha1.OCIImageRef(in.OCI) out.CmdLine = in.CmdLine return nil } @@ -699,7 +699,7 @@ func Convert_v1alpha2_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out } func autoConvert_ignite_VMKernelSpec_To_v1alpha2_VMKernelSpec(in *ignite.VMKernelSpec, out *VMKernelSpec, s conversion.Scope) error { - out.OCIRef = v1alpha1.OCIImageRef(in.OCIRef) + out.OCI = v1alpha1.OCIImageRef(in.OCI) out.CmdLine = in.CmdLine return nil } diff --git a/pkg/apis/ignite/validation/validation.go b/pkg/apis/ignite/validation/validation.go index 49f7fa812..3b5c36730 100644 --- a/pkg/apis/ignite/validation/validation.go +++ b/pkg/apis/ignite/validation/validation.go @@ -13,8 +13,8 @@ import ( // ValidateVM validates a VM object and collects all encountered errors func ValidateVM(obj *api.VM) (allErrs field.ErrorList) { allErrs = append(allErrs, ValidateNetworkMode(obj.Spec.Network.Mode, field.NewPath(".spec.network.mode"))...) - allErrs = append(allErrs, RequireOCIImageRef(&obj.Spec.Image.OCIRef, field.NewPath(".spec.image.oci"))...) - allErrs = append(allErrs, RequireOCIImageRef(&obj.Spec.Kernel.OCIRef, field.NewPath(".spec.kernel.oci"))...) + allErrs = append(allErrs, RequireOCIImageRef(&obj.Spec.Image.OCI, field.NewPath(".spec.image.oci"))...) + allErrs = append(allErrs, RequireOCIImageRef(&obj.Spec.Kernel.OCI, field.NewPath(".spec.kernel.oci"))...) allErrs = append(allErrs, ValidateFileMappings(&obj.Spec.CopyFiles, field.NewPath(".spec.copyFiles"))...) allErrs = append(allErrs, ValidateVMStorage(&obj.Spec.Storage, field.NewPath(".spec.storage"))...) // TODO: Add vCPU, memory, disk max and min sizes @@ -76,20 +76,3 @@ func ValidateNetworkMode(mode api.NetworkMode, fldPath *field.Path) (allErrs fie return } - -// ValidateImageSourceType validates if an image source type is valid -func ValidateImageSourceType(t api.ImageSourceType, fldPath *field.Path) (allErrs field.ErrorList) { - found := false - types := api.GetImageSourceTypes() - for _, tt := range types { - if tt == t { - found = true - } - } - - if !found { - allErrs = append(allErrs, field.Invalid(fldPath, t, fmt.Sprintf("image source type must be one of %v", types))) - } - - return -} diff --git a/pkg/openapi/violations.txt b/pkg/openapi/violations.txt index abfa81023..3ba10b204 100644 --- a/pkg/openapi/violations.txt +++ b/pkg/openapi/violations.txt @@ -6,10 +6,6 @@ API rule violation: list_type_missing,github.com/weaveworks/ignite/pkg/apis/igni API rule violation: list_type_missing,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMStorageSpec,VolumeMounts API rule violation: list_type_missing,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMStorageSpec,Volumes API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha1,VMSpec,CPUs -API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,ImageSpec,OCIRef -API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,KernelSpec,OCIRef -API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMImageSpec,OCIRef -API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMKernelSpec,OCIRef API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2,VMSpec,CPUs API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/meta/v1alpha1,DMID,index API rule violation: names_match,github.com/weaveworks/ignite/pkg/apis/meta/v1alpha1,OCIContentID,digest diff --git a/pkg/operations/import.go b/pkg/operations/import.go index caec9aedf..bce11bc94 100644 --- a/pkg/operations/import.go +++ b/pkg/operations/import.go @@ -54,7 +54,7 @@ func importImage(c *client.Client, ociRef meta.OCIImageRef) (*api.Image, error) // Set the image name image.Name = ociRef.String() // Set the image's ociRef - image.Spec.OCIRef = ociRef + image.Spec.OCI = ociRef // Set the image's ociSource image.Status.OCISource = *src @@ -112,7 +112,7 @@ func importKernel(c *client.Client, ociRef meta.OCIImageRef) (*api.Kernel, error // Set the kernel name kernel.Name = ociRef.String() // Set the kernel's ociRef - kernel.Spec.OCIRef = ociRef + kernel.Spec.OCI = ociRef // Set the kernel's ociSource kernel.Status.OCISource = *src diff --git a/pkg/operations/lookup/lookup.go b/pkg/operations/lookup/lookup.go index 3fa24318f..207dbf998 100644 --- a/pkg/operations/lookup/lookup.go +++ b/pkg/operations/lookup/lookup.go @@ -8,7 +8,7 @@ import ( ) func ImageUIDForVM(vm *api.VM, c *client.Client) (meta.UID, error) { - image, err := c.Images().Find(filter.NewNameFilter(vm.Spec.Image.OCIRef.String())) + image, err := c.Images().Find(filter.NewNameFilter(vm.Spec.Image.OCI.String())) if err != nil { return "", err } @@ -17,7 +17,7 @@ func ImageUIDForVM(vm *api.VM, c *client.Client) (meta.UID, error) { } func KernelUIDForVM(vm *api.VM, c *client.Client) (meta.UID, error) { - kernel, err := c.Kernels().Find(filter.NewNameFilter(vm.Spec.Kernel.OCIRef.String())) + kernel, err := c.Kernels().Find(filter.NewNameFilter(vm.Spec.Kernel.OCI.String())) if err != nil { return "", err } diff --git a/pkg/operations/reconcile/reconcile.go b/pkg/operations/reconcile/reconcile.go index bb9c06a92..59502a3e0 100644 --- a/pkg/operations/reconcile/reconcile.go +++ b/pkg/operations/reconcile/reconcile.go @@ -114,7 +114,7 @@ func create(vm *api.VM) error { // ensureOCIImages imports the base/kernel OCI images if needed func ensureOCIImages(vm *api.VM) error { // Check if a image with this name already exists, or import it - image, err := operations.FindOrImportImage(c, vm.Spec.Image.OCIRef) + image, err := operations.FindOrImportImage(c, vm.Spec.Image.OCI) if err != nil { return err } @@ -123,7 +123,7 @@ func ensureOCIImages(vm *api.VM) error { vm.SetImage(image) // Check if a kernel with this name already exists, or import it - kernel, err := operations.FindOrImportKernel(c, vm.Spec.Kernel.OCIRef) + kernel, err := operations.FindOrImportKernel(c, vm.Spec.Kernel.OCI) if err != nil { return err }