code-generator icon indicating copy to clipboard operation
code-generator copied to clipboard

Bug Report: Missing Package Imports in zz_generated.register.go File

Open hugtale opened this issue 1 year ago • 4 comments

Description

When using register-gen from the code-generator package to automatically generate the zz_generated.register.go file, the generated file is missing the import statements for the following packages:

  • k8s.io/apimachinery/pkg/runtime
  • k8s.io/apimachinery/pkg/runtime/schema

This issue causes compilation errors because these packages are required for the generated GroupVersion and SchemeBuilder code to function correctly.

Steps to Reproduce

  1. Use register-gen to generate a zz_generated.register.go file.
  2. Attempt to compile the project.
  3. Observe that the generated file is missing the necessary import statements.

Expected Behavior

The generated zz_generated.register.go file should include the following imports by default:

import (
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/runtime/schema"
)

This ensures that the generated code compiles without requiring manual modification.

Environment

  • code-generator version: 1.32
  • Go version: 1.23.4

Thank you for your attention to this issue. Please let me know if further details are required.

hugtale avatar Dec 28 '24 13:12 hugtale