diff --git a/cmd/kubebuilder-gen/codegen/run/util.go b/cmd/kubebuilder-gen/codegen/run/util.go index 2f4508c59e..2a41ec211d 100644 --- a/cmd/kubebuilder-gen/codegen/run/util.go +++ b/cmd/kubebuilder-gen/codegen/run/util.go @@ -44,7 +44,7 @@ func generatorToPackage(pkg string, gen generator.Generator) generator.Package { // generatedGoHeader returns the header to preprend to generated go files func generatedGoHeader() []byte { - cr, err := ioutil.ReadFile("boilerplate.go.txt") + cr, err := ioutil.ReadFile(filepath.Join("hack", "boilerplate.go.txt")) if err != nil { return []byte{} } diff --git a/cmd/kubebuilder/create/util/util.go b/cmd/kubebuilder/create/util/util.go index 1f7650461f..b2c49b1795 100644 --- a/cmd/kubebuilder/create/util/util.go +++ b/cmd/kubebuilder/create/util/util.go @@ -25,6 +25,7 @@ import ( "github.com/spf13/cobra" "github.com/kubernetes-sigs/kubebuilder/cmd/kubebuilder/util" + "path/filepath" ) var ( @@ -71,5 +72,5 @@ func RegisterResourceFlags(cmd *cobra.Command) { } func RegisterCopyrightFlag(cmd *cobra.Command) { - cmd.Flags().StringVar(&Copyright, "copyright", "boilerplate.go.txt", "Location of copyright boilerplate file.") + cmd.Flags().StringVar(&Copyright, "copyright", filepath.Join("hack", "boilerplate.go.txt"), "Location of copyright boilerplate file.") } diff --git a/cmd/kubebuilder/initproject/init.go b/cmd/kubebuilder/initproject/init.go index c5155e6704..e37d6b123f 100644 --- a/cmd/kubebuilder/initproject/init.go +++ b/cmd/kubebuilder/initproject/init.go @@ -43,7 +43,7 @@ var bazel bool func AddInit(cmd *cobra.Command) { cmd.AddCommand(repoCmd) repoCmd.Flags().StringVar(&domain, "domain", "", "domain for the API groups") - repoCmd.Flags().StringVar(©right, "copyright", "boilerplate.go.txt", "Location of copyright boilerplate file.") + repoCmd.Flags().StringVar(©right, "copyright", filepath.Join("hack", "boilerplate.go.txt"), "Location of copyright boilerplate file.") repoCmd.Flags().BoolVar(&bazel, "bazel", false, "if true, setup Bazel workspace artifacts") } diff --git a/cmd/kubebuilder/util/util.go b/cmd/kubebuilder/util/util.go index e389129248..6c95c3fcc4 100644 --- a/cmd/kubebuilder/util/util.go +++ b/cmd/kubebuilder/util/util.go @@ -97,7 +97,7 @@ func WriteString(path, value string) { // if the file cannot be read, will return the empty string. func GetCopyright(file string) string { if len(file) == 0 { - file = "boilerplate.go.txt" + file = filepath.Join("hack", "boilerplate.go.txt") } cr, err := ioutil.ReadFile(file) if err != nil { diff --git a/samples/controller/controller.go b/samples/controller/controller.go index 7550a3d672..5198886f7e 100644 --- a/samples/controller/controller.go +++ b/samples/controller/controller.go @@ -69,6 +69,7 @@ func NewController(iargs args.InjectArgs) *controller.GenericController { samplescheme.AddToScheme(scheme.Scheme) c := &Controller{ + InjectArgs: iargs, recorder: iargs.CreateRecorder(controllerAgentName), }