Skip to content

Commit

Permalink
makefile: run go mod tidy during make generate
Browse files Browse the repository at this point in the history
We have multiple go.mod files, this does not seem to agree with operator-sdk.
operator-sdk will generate files and call `make generate`. However, that will then
fail because we didn't call `go mod tidy` for api/ directory.

Note that compared to sriov-network-operator, in dpu-operator we have
several go.mod files. That does not seem to agree with operator-sdk, or
at least, something is not hooked up right.

Hack `make generate` to call `go mod tidy` first.

Otherwise:

  $ git checkout -B C origin/main && \
    git reset --hard HEAD && \
    git clean -fdx && \
    make operator-sdk && \
    ./bin/operator-sdk create webhook --group config --version v1 --kind DpuOperatorConfig --defaulting --programmatic-validation
  branch 'C' set up to track 'origin/main'.
  Reset branch 'C'
  Your branch is up to date with 'origin/main'.
  HEAD is now at e58a9c9 Merge pull request #194 from thom311/th/hack-scripts-cleanup
  INFO[0000] Writing kustomize manifests for you to edit...
  ERRO[0000] Unable to find the target #- path: manager_webhook_patch.yaml to uncomment in the file config/default/kustomization.yaml.
  INFO[0000] Writing scaffold for you to edit...
  INFO[0000] api/v1/dpuoperatorconfig_webhook.go
  INFO[0000] api/v1/dpuoperatorconfig_webhook_test.go
  INFO[0000] api/v1/webhook_suite_test.go
  INFO[0000] Update dependencies:
  $ go mod tidy
  INFO[0000] Running make:
  $ make generate
  test -s /data/src/dpu-operator/bin/controller-gen && /data/src/dpu-operator/bin/controller-gen --version | grep -q v0.15.0 || \
  GOBIN=/data/src/dpu-operator/bin GOFLAGS='' go install sigs.k8s.io/controller-tools/cmd/[email protected]
  GOFLAGS='' /data/src/dpu-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
  Error: load packages in root "/data/src/dpu-operator/api": err: exit status 1: stderr: go: updates to go.mod needed; to update it:
          go mod tidy
  • Loading branch information
thom311 committed Nov 5, 2024
1 parent e58a9c9 commit 23e2c38
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,14 @@ prow-ci-manifests-check: manifests
exit 1; \
fi

.PHONY: vendor
vendor:
for d in . dpu-api api tools ; do \
(cd $$d; go mod tidy) || exit $$? ; \
done

.PHONY: generate
generate: vendor
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
GOFLAGS='' $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

Expand Down

0 comments on commit 23e2c38

Please sign in to comment.