kcp-dev / kcp

Kubernetes-like control planes for form-factors and use-cases beyond Kubernetes and container workloads.
https://kcp.io
Apache License 2.0
2.39k stars 383 forks source link

šŸ› Fix 'make install' to respect plugin go module #3174

Closed marckhouzam closed 2 months ago

marckhouzam commented 2 months ago

Summary

Now that plugins have their own go module, the Makefile must change to that module's directory before running go commands on that module. Currently, make install does not do this and therefore plugins don't get installed as expected.

This PR updates make install following the pattern of make build to fix this.

Before this PR, notice the last line go: warning: "github.com/kcp-dev/kcp/cli/cmd/..." matched no packages, and the plugins don't get installed in $GOPATH/bin:

$ make install
hack/verify-go-versions.sh
set -x; for W in ./cmd/... ./cli/cmd/...; do \
        W=$(echo "${W}" | sed 's,^\./,github.com/kcp-dev/kcp/,') && \
        GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go install -ldflags="-X k8s.io/client-go/pkg/version.gitCommit=c1ff50b3 -X k8s.io/client-go/pkg/version.gitTreeState=clean -X k8s.io/client-go/pkg/version.gitVersion=v1.30.3+kcp-v0.20.0-391-gc1ff50b3671d5d -X k8s.io/client-go/pkg/version.gitMajor=1 -X k8s.io/client-go/pkg/version.gitMinor=30 -X k8s.io/client-go/pkg/version.buildDate=2024-09-20T14:42:59Z -X k8s.io/component-base/version.gitCommit=c1ff50b3 -X k8s.io/component-base/version.gitTreeState=clean -X k8s.io/component-base/version.gitVersion=v1.30.3+kcp-v0.20.0-391-gc1ff50b3671d5d -X k8s.io/component-base/version.gitMajor=1 -X k8s.io/component-base/version.gitMinor=30 -X k8s.io/component-base/version.buildDate=2024-09-20T14:42:59Z -extldflags '-static'" ${W}; \
    done
+ for W in ./cmd/... ./cli/cmd/...
++ echo ./cmd/...
++ sed 's,^\./,github.com/kcp-dev/kcp/,'
+ W=github.com/kcp-dev/kcp/cmd/...
+ GOOS=darwin
+ GOARCH=arm64
+ CGO_ENABLED=0
+ go install '-ldflags=-X k8s.io/client-go/pkg/version.gitCommit=c1ff50b3 -X k8s.io/client-go/pkg/version.gitTreeState=clean -X k8s.io/client-go/pkg/version.gitVersion=v1.30.3+kcp-v0.20.0-391-gc1ff50b3671d5d -X k8s.io/client-go/pkg/version.gitMajor=1 -X k8s.io/client-go/pkg/version.gitMinor=30 -X k8s.io/client-go/pkg/version.buildDate=2024-09-20T14:42:59Z -X k8s.io/component-base/version.gitCommit=c1ff50b3 -X k8s.io/component-base/version.gitTreeState=clean -X k8s.io/component-base/version.gitVersion=v1.30.3+kcp-v0.20.0-391-gc1ff50b3671d5d -X k8s.io/component-base/version.gitMajor=1 -X k8s.io/component-base/version.gitMinor=30 -X k8s.io/component-base/version.buildDate=2024-09-20T14:42:59Z -extldflags '\''-static'\''' github.com/kcp-dev/kcp/cmd/...
+ for W in ./cmd/... ./cli/cmd/...
++ echo ./cli/cmd/...
++ sed 's,^\./,github.com/kcp-dev/kcp/,'
+ W=github.com/kcp-dev/kcp/cli/cmd/...
+ GOOS=darwin
+ GOARCH=arm64
+ CGO_ENABLED=0
+ go install '-ldflags=-X k8s.io/client-go/pkg/version.gitCommit=c1ff50b3 -X k8s.io/client-go/pkg/version.gitTreeState=clean -X k8s.io/client-go/pkg/version.gitVersion=v1.30.3+kcp-v0.20.0-391-gc1ff50b3671d5d -X k8s.io/client-go/pkg/version.gitMajor=1 -X k8s.io/client-go/pkg/version.gitMinor=30 -X k8s.io/client-go/pkg/version.buildDate=2024-09-20T14:42:59Z -X k8s.io/component-base/version.gitCommit=c1ff50b3 -X k8s.io/component-base/version.gitTreeState=clean -X k8s.io/component-base/version.gitVersion=v1.30.3+kcp-v0.20.0-391-gc1ff50b3671d5d -X k8s.io/component-base/version.gitMajor=1 -X k8s.io/component-base/version.gitMinor=30 -X k8s.io/component-base/version.buildDate=2024-09-20T14:42:59Z -extldflags '\''-static'\''' github.com/kcp-dev/kcp/cli/cmd/...
go: warning: "github.com/kcp-dev/kcp/cli/cmd/..." matched no packages

With this PR the plugins (as well as the other binaries) get properly installed in $GOPATH/bin:

$ find $GOPATH/bin -cmin -5
/Users/kmarc/go/bin
/Users/kmarc/go/bin/compat
/Users/kmarc/go/bin/sharded-test-server
/Users/kmarc/go/bin/kubectl-kcp
/Users/kmarc/go/bin/kubectl-create-workspace
/Users/kmarc/go/bin/virtual-workspaces
/Users/kmarc/go/bin/kubectl-ws
/Users/kmarc/go/bin/kcp-front-proxy
/Users/kmarc/go/bin/test-server
/Users/kmarc/go/bin/cache-server
/Users/kmarc/go/bin/kcp
/Users/kmarc/go/bin/crd-puller

Related issue(s)

Fixes # N/A

Release Notes

NONE
kcp-ci-bot commented 2 months ago

Hi @marckhouzam. Thanks for your PR.

I'm waiting for a kcp-dev member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
embik commented 2 months ago

/ok-to-test

mjudeikis commented 2 months ago

/lgtm /approve

kcp-ci-bot commented 2 months ago

LGTM label has been added.

Git tree hash: 0e88128f1acd77a6d4266898cb06cda0d3fa920f

kcp-ci-bot commented 2 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjudeikis

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kcp-dev/kcp/blob/main/OWNERS)~~ [mjudeikis] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment