From ce7c0e1c4a4cf6f724249ad2b98fe549e038f9fe Mon Sep 17 00:00:00 2001 From: Phillip Wittrock Date: Wed, 21 Mar 2018 08:40:19 -0700 Subject: [PATCH 1/2] Fix issue where creation commands didn't find the boilerplate.go.txt --- cmd/kubebuilder-gen/codegen/run/util.go | 2 +- cmd/kubebuilder/create/util/util.go | 3 ++- cmd/kubebuilder/initproject/init.go | 2 +- cmd/kubebuilder/util/util.go | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) 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 { From 21ce3b59a4ba41490cddc909b58a29a4c0f92ba0 Mon Sep 17 00:00:00 2001 From: Phillip Wittrock Date: Wed, 21 Mar 2018 09:29:53 -0700 Subject: [PATCH 2/2] Fix bug in sample where iargs wasn't set --- samples/controller/controller.go | 1 + 1 file changed, 1 insertion(+) 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), }