Skip to content

Commit

Permalink
Break import cycle
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed May 31, 2024
1 parent c6fcd28 commit 5663294
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 56 deletions.
51 changes: 24 additions & 27 deletions api/v1/conversion.go → api/v1/conversion/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1
package conversion

import (
"unsafe"

v1 "kmodules.xyz/offshoot-api/api/v1"
v2 "kmodules.xyz/offshoot-api/api/v2"

core "k8s.io/api/core/v1"
Expand All @@ -27,58 +28,54 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)

func init() {
localSchemeBuilder.Register(RegisterConversions)
}

// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(s *runtime.Scheme) error {
if err := s.AddGeneratedConversionFunc((*ObjectMeta)(nil), (*metav1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_ObjectMeta_To_metav1_ObjectMeta(a.(*ObjectMeta), b.(*metav1.ObjectMeta), scope)
if err := s.AddGeneratedConversionFunc((*v1.ObjectMeta)(nil), (*metav1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_ObjectMeta_To_metav1_ObjectMeta(a.(*v1.ObjectMeta), b.(*metav1.ObjectMeta), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*metav1.ObjectMeta)(nil), (*ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_metav1_ObjectMeta_To_v1_ObjectMeta(a.(*metav1.ObjectMeta), b.(*ObjectMeta), scope)
if err := s.AddGeneratedConversionFunc((*metav1.ObjectMeta)(nil), (*v1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_metav1_ObjectMeta_To_v1_ObjectMeta(a.(*metav1.ObjectMeta), b.(*v1.ObjectMeta), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*PodSpec)(nil), (*v2.PodSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_PodSpec_To_v2_PodSpec(a.(*PodSpec), b.(*v2.PodSpec), scope)
if err := s.AddGeneratedConversionFunc((*v1.PodSpec)(nil), (*v2.PodSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_PodSpec_To_v2_PodSpec(a.(*v1.PodSpec), b.(*v2.PodSpec), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v2.PodSpec)(nil), (*PodSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v2_PodSpec_To_v1_PodSpec(a.(*v2.PodSpec), b.(*PodSpec), scope)
if err := s.AddGeneratedConversionFunc((*v2.PodSpec)(nil), (*v1.PodSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v2_PodSpec_To_v1_PodSpec(a.(*v2.PodSpec), b.(*v1.PodSpec), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*PodTemplateSpec)(nil), (*v2.PodTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_PodTemplateSpec_To_v2_PodTemplateSpec(a.(*PodTemplateSpec), b.(*v2.PodTemplateSpec), scope)
if err := s.AddGeneratedConversionFunc((*v1.PodTemplateSpec)(nil), (*v2.PodTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_PodTemplateSpec_To_v2_PodTemplateSpec(a.(*v1.PodTemplateSpec), b.(*v2.PodTemplateSpec), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v2.PodTemplateSpec)(nil), (*PodTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v2_PodTemplateSpec_To_v1_PodTemplateSpec(a.(*v2.PodTemplateSpec), b.(*PodTemplateSpec), scope)
if err := s.AddGeneratedConversionFunc((*v2.PodTemplateSpec)(nil), (*v1.PodTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v2_PodTemplateSpec_To_v1_PodTemplateSpec(a.(*v2.PodTemplateSpec), b.(*v1.PodTemplateSpec), scope)
}); err != nil {
return err
}
return nil
}

func autoConvert_v1_ObjectMeta_To_metav1_ObjectMeta(in *ObjectMeta, out *metav1.ObjectMeta, s conversion.Scope) error {
func autoConvert_v1_ObjectMeta_To_metav1_ObjectMeta(in *v1.ObjectMeta, out *metav1.ObjectMeta, s conversion.Scope) error {

Check failure on line 67 in api/v1/conversion/conversion.go

View workflow job for this annotation

GitHub Actions / Build

`autoConvert_v1_ObjectMeta_To_metav1_ObjectMeta` - `s` is unused (unparam)
out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels))
out.Annotations = *(*map[string]string)(unsafe.Pointer(&in.Annotations))
return nil
}

// Convert_v1_ObjectMeta_To_v1_ObjectMeta is an autogenerated conversion function.
func Convert_v1_ObjectMeta_To_metav1_ObjectMeta(in *ObjectMeta, out *metav1.ObjectMeta, s conversion.Scope) error {
func Convert_v1_ObjectMeta_To_metav1_ObjectMeta(in *v1.ObjectMeta, out *metav1.ObjectMeta, s conversion.Scope) error {
return autoConvert_v1_ObjectMeta_To_metav1_ObjectMeta(in, out, s)
}

func autoConvert_metav1_ObjectMeta_To_v1_ObjectMeta(in *metav1.ObjectMeta, out *ObjectMeta, s conversion.Scope) error {
func autoConvert_metav1_ObjectMeta_To_v1_ObjectMeta(in *metav1.ObjectMeta, out *v1.ObjectMeta, s conversion.Scope) error {

Check failure on line 78 in api/v1/conversion/conversion.go

View workflow job for this annotation

GitHub Actions / Build

`autoConvert_metav1_ObjectMeta_To_v1_ObjectMeta` - `s` is unused (unparam)
// WARNING: in.Name requires manual conversion: does not exist in peer-type
// WARNING: in.GenerateName requires manual conversion: does not exist in peer-type
// WARNING: in.Namespace requires manual conversion: does not exist in peer-type
Expand All @@ -97,11 +94,11 @@ func autoConvert_metav1_ObjectMeta_To_v1_ObjectMeta(in *metav1.ObjectMeta, out *
return nil
}

func Convert_metav1_ObjectMeta_To_v1_ObjectMeta(in *metav1.ObjectMeta, out *ObjectMeta, s conversion.Scope) error {
func Convert_metav1_ObjectMeta_To_v1_ObjectMeta(in *metav1.ObjectMeta, out *v1.ObjectMeta, s conversion.Scope) error {
return autoConvert_metav1_ObjectMeta_To_v1_ObjectMeta(in, out, s)
}

func Convert_v1_PodSpec_To_v2_PodSpec(in *PodSpec, out *v2.PodSpec, s conversion.Scope) error {
func Convert_v1_PodSpec_To_v2_PodSpec(in *v1.PodSpec, out *v2.PodSpec, s conversion.Scope) error {
if in.Volumes != nil {
out.Volumes = in.Volumes
} else {
Expand Down Expand Up @@ -143,7 +140,7 @@ func Convert_v1_PodSpec_To_v2_PodSpec(in *PodSpec, out *v2.PodSpec, s conversion
return nil
}

func Convert_v2_PodSpec_To_v1_PodSpec(in *v2.PodSpec, out *PodSpec, s conversion.Scope) error {
func Convert_v2_PodSpec_To_v1_PodSpec(in *v2.PodSpec, out *v1.PodSpec, s conversion.Scope) error {
if in.Volumes != nil {
out.Volumes = in.Volumes
} else {
Expand Down Expand Up @@ -194,7 +191,7 @@ func Convert_v2_PodSpec_To_v1_PodSpec(in *v2.PodSpec, out *PodSpec, s conversion
return nil
}

func autoConvert_v1_PodTemplateSpec_To_v2_PodTemplateSpec(in *PodTemplateSpec, out *v2.PodTemplateSpec, s conversion.Scope) error {
func autoConvert_v1_PodTemplateSpec_To_v2_PodTemplateSpec(in *v1.PodTemplateSpec, out *v2.PodTemplateSpec, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.Controller = in.Controller
if err := Convert_v1_PodSpec_To_v2_PodSpec(&in.Spec, &out.Spec, s); err != nil {
Expand All @@ -204,11 +201,11 @@ func autoConvert_v1_PodTemplateSpec_To_v2_PodTemplateSpec(in *PodTemplateSpec, o
}

// Convert_v1_PodTemplateSpec_To_v2_PodTemplateSpec is an autogenerated conversion function.
func Convert_v1_PodTemplateSpec_To_v2_PodTemplateSpec(in *PodTemplateSpec, out *v2.PodTemplateSpec, s conversion.Scope) error {
func Convert_v1_PodTemplateSpec_To_v2_PodTemplateSpec(in *v1.PodTemplateSpec, out *v2.PodTemplateSpec, s conversion.Scope) error {
return autoConvert_v1_PodTemplateSpec_To_v2_PodTemplateSpec(in, out, s)
}

func autoConvert_v2_PodTemplateSpec_To_v1_PodTemplateSpec(in *v2.PodTemplateSpec, out *PodTemplateSpec, s conversion.Scope) error {
func autoConvert_v2_PodTemplateSpec_To_v1_PodTemplateSpec(in *v2.PodTemplateSpec, out *v1.PodTemplateSpec, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.Controller = in.Controller
if err := Convert_v2_PodSpec_To_v1_PodSpec(&in.Spec, &out.Spec, s); err != nil {
Expand All @@ -218,6 +215,6 @@ func autoConvert_v2_PodTemplateSpec_To_v1_PodTemplateSpec(in *v2.PodTemplateSpec
}

// Convert_v2_PodTemplateSpec_To_v1_PodTemplateSpec is an autogenerated conversion function.
func Convert_v2_PodTemplateSpec_To_v1_PodTemplateSpec(in *v2.PodTemplateSpec, out *PodTemplateSpec, s conversion.Scope) error {
func Convert_v2_PodTemplateSpec_To_v1_PodTemplateSpec(in *v2.PodTemplateSpec, out *v1.PodTemplateSpec, s conversion.Scope) error {
return autoConvert_v2_PodTemplateSpec_To_v1_PodTemplateSpec(in, out, s)
}
29 changes: 0 additions & 29 deletions api/v1/register.go

This file was deleted.

0 comments on commit 5663294

Please sign in to comment.