|
| 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 | +` |
0 commit comments