Skip to content

Commit 83156c1

Browse files
author
Phillip Wittrock
authored
Merge pull request #248 from pwittrock/imports
Link project deps from hack/imports.go
2 parents 8a31fe0 + f1142fd commit 83156c1

File tree

3 files changed

+54
-29
lines changed

3 files changed

+54
-29
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package initproject
18+
19+
import (
20+
"path/filepath"
21+
22+
"github.com/kubernetes-sigs/kubebuilder/cmd/kubebuilder/util"
23+
)
24+
25+
func doImports(boilerplate string) bool {
26+
args := installImportsArgs{
27+
BoilerPlate: boilerplate,
28+
}
29+
controller := util.WriteIfNotFound(filepath.Join("hack", "imports.go"), "imports-template", installImportsTemplate, args)
30+
return controller
31+
}
32+
33+
type installImportsArgs struct {
34+
BoilerPlate string
35+
}
36+
37+
var installImportsTemplate = `{{.BoilerPlate}}
38+
39+
package hack
40+
41+
/*
42+
Package imports imports dependencies required for "dep ensure" to fetch all of the go package dependencies needed
43+
by kubebuilder commands to work without rerunning "dep ensure".
44+
45+
Example: make sure the testing libraries and apimachinery libraries are fetched by "dep ensure" so that
46+
dep ensure doesn't need to be rerun after "kubebuilder create resource".
47+
48+
This is necessary for subsequent commands - such as building docs, tests, etc - to work without rerunning "dep ensure"
49+
afterward.
50+
*/
51+
import _ "github.com/kubernetes-sigs/kubebuilder/pkg/imports"
52+
`

cmd/kubebuilder/initproject/vendor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ var builderCommit string
5252
var Update bool
5353

5454
func RunVendorInstall(cmd *cobra.Command, args []string) {
55+
cr := util.GetCopyright(copyright)
56+
doImports(cr)
5557
if !depExists() {
5658
log.Fatalf("Dep is not installed. Follow steps at: https://golang.github.io/dep/docs/installation.html")
5759
}

pkg/signals/dummy_imports.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)