mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-08 18:14:14 +00:00
Step into the API package for generating CRDs and code
`controller-gen` does not work across package boundaries. Run it from inside the API package directory to work around this. Signed-off-by: Matthias Rampke <matthias@rampke.de>
This commit is contained in:
parent
2a67feba74
commit
8d876ff138
2 changed files with 14 additions and 5 deletions
4
Makefile
4
Makefile
|
@ -71,8 +71,8 @@ po-lint:
|
|||
|
||||
DEEPCOPY_TARGET := pkg/apis/monitoring/v1/zz_generated.deepcopy.go
|
||||
$(DEEPCOPY_TARGET): $(CONTROLLER_GEN_BINARY)
|
||||
$(CONTROLLER_GEN_BINARY) object:headerFile=./.header \
|
||||
paths=./pkg/apis/monitoring/v1
|
||||
cd ./pkg/apis/monitoring/v1 && $(CONTROLLER_GEN_BINARY) object:headerFile=$(CURDIR)/.header \
|
||||
paths=.
|
||||
|
||||
CLIENT_TARGET := pkg/client/versioned/clientset.go
|
||||
$(CLIENT_TARGET): $(K8S_GEN_DEPS)
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
@ -65,12 +66,20 @@ var (
|
|||
)
|
||||
|
||||
func (generator crdGenerator) generateYAMLManifests() error {
|
||||
outputDir, err := filepath.Abs(generator.YAMLDir)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "absolute CRD output path %s", generator.YAMLDir)
|
||||
}
|
||||
cmd := exec.Command(controllergen,
|
||||
generator.ControllerGenOpts,
|
||||
"paths="+controllerPath,
|
||||
"output:crd:dir="+generator.YAMLDir,
|
||||
"paths=.",
|
||||
"output:crd:dir="+outputDir,
|
||||
)
|
||||
err := cmd.Run()
|
||||
cmd.Dir, err = filepath.Abs(controllerPath)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "absolute controller path %s", controllerPath)
|
||||
}
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "running %s", cmd)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue