Skip to content

Commit 6ea1cab

Browse files
authored
Merge pull request #3084 from sttts/sttts-cli-module
✨ Move kubectl plugins into github.com/kcp-dev/kcp/cli module
2 parents d9dc3d0 + 133885c commit 6ea1cab

File tree

36 files changed

+441
-45
lines changed

36 files changed

+441
-45
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ coverage.*
66
tools
77
build
88
vendor
9+
goio.yaml
910

1011
# JetBrains IDE files
1112
.idea/
@@ -26,4 +27,4 @@ tmp
2627
.prometheus-pid
2728

2829
go.work
29-
go.work.sum
30+
go.work.*

.goreleaser.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ builds:
1818
- CGO_ENABLED=0
1919
- id: "kubectl-kcp"
2020
main: ./cmd/kubectl-kcp
21+
dir: cli
2122
binary: bin/kubectl-kcp
2223
ldflags:
2324
- "{{ .Env.LDFLAGS }}"
@@ -38,6 +39,7 @@ builds:
3839
- CGO_ENABLED=0
3940
- id: "kubectl-workspace"
4041
main: ./cmd/kubectl-workspace
42+
dir: cli
4143
binary: bin/kubectl-workspace
4244
ldflags:
4345
- "{{ .Env.LDFLAGS }}"
@@ -56,8 +58,8 @@ builds:
5658
goarch: ppc64le
5759
hooks:
5860
post:
59-
- ln -sfr bin/kubectl-workspace bin/kubectl-workspaces
60-
- ln -sfr bin/kubectl-workspace bin/kubectl-ws
61+
- ln -sf kubectl-workspace bin/kubectl-workspaces
62+
- ln -sf kubectl-workspace bin/kubectl-ws
6163
env:
6264
- CGO_ENABLED=0
6365
archives:

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ COPY go.mod go.mod
3030
COPY go.sum go.sum
3131
COPY sdk/go.mod sdk/go.mod
3232
COPY sdk/go.sum sdk/go.sum
33+
COPY cli/go.mod cli/go.mod
34+
COPY cli/go.sum cli/go.sum
3335
USER 0
3436

3537
# Install kubectl.

FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ Shards in kcp represent a single apiserver and etcd/db instance. This is how kc
6767

6868
## Where can I get the kubectl workspace plugin?
6969

70-
You're in the right place. Clone this repo and run `make install WHAT=./cmd/kubectl-kcp`.
70+
You're in the right place. Clone this repo and run `make install WHAT=./cli/cmd/kubectl-kcp`.
7171

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ ldflags:
115115
require-%:
116116
@if ! command -v $* 1> /dev/null 2>&1; then echo "$* not found in ${PATH}"; exit 1; fi
117117

118-
build: WHAT ?= ./cmd/...
118+
build: WHAT ?= ./cmd/... ./cli/cmd/...
119119
build: require-jq require-go require-git verify-go-versions ## Build the project
120-
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build $(BUILDFLAGS) -ldflags="$(LDFLAGS)" -o bin $(WHAT)
120+
set -x; for W in $(WHAT); do \
121+
W=$$(echo "$${W}" | sed 's,^\./,github.com/kcp-dev/kcp/,') && \
122+
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build $(BUILDFLAGS) -ldflags="$(LDFLAGS)" -o bin $${W}; \
123+
done
121124
ln -sf kubectl-workspace bin/kubectl-workspaces
122125
ln -sf kubectl-workspace bin/kubectl-ws
123126
.PHONY: build
@@ -126,9 +129,12 @@ build: require-jq require-go require-git verify-go-versions ## Build the project
126129
build-all:
127130
GOOS=$(OS) GOARCH=$(ARCH) $(MAKE) build WHAT='./cmd/...'
128131

129-
install: WHAT ?= ./cmd/...
132+
install: WHAT ?= ./cmd/... ./cli/cmd/...
130133
install: require-jq require-go require-git verify-go-versions ## Install the project
131-
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go install -ldflags="$(LDFLAGS)" $(WHAT)
134+
set -x; for W in $(WHAT); do \
135+
W=$$(echo "$${W}" | sed 's,^\./,github.com/kcp-dev/kcp/,') && \
136+
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go install -ldflags="$(LDFLAGS)" $${W}; \
137+
done
132138
ln -sf $(INSTALL_GOBIN)/kubectl-workspace $(INSTALL_GOBIN)/kubectl-ws
133139
ln -sf $(INSTALL_GOBIN)/kubectl-workspace $(INSTALL_GOBIN)/kubectl-workspaces
134140
.PHONY: install

cmd/kubectl-kcp/cmd/kubectlKcp.go renamed to cli/cmd/kubectl-kcp/cmd/kubectlKcp.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import (
2727
"k8s.io/component-base/version"
2828
"k8s.io/klog/v2"
2929

30-
bindcmd "github.com/kcp-dev/kcp/pkg/cliplugins/bind/cmd"
31-
claimscmd "github.com/kcp-dev/kcp/pkg/cliplugins/claims/cmd"
32-
crdcmd "github.com/kcp-dev/kcp/pkg/cliplugins/crd/cmd"
33-
workspacecmd "github.com/kcp-dev/kcp/pkg/cliplugins/workspace/cmd"
34-
"github.com/kcp-dev/kcp/pkg/cmd/help"
30+
bindcmd "github.com/kcp-dev/kcp/cli/pkg/bind/cmd"
31+
claimscmd "github.com/kcp-dev/kcp/cli/pkg/claims/cmd"
32+
crdcmd "github.com/kcp-dev/kcp/cli/pkg/crd/cmd"
33+
"github.com/kcp-dev/kcp/cli/pkg/help"
34+
workspacecmd "github.com/kcp-dev/kcp/cli/pkg/workspace/cmd"
3535
)
3636

3737
func KubectlKcpCommand() *cobra.Command {

cmd/kubectl-kcp/main.go renamed to cli/cmd/kubectl-kcp/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
"github.com/spf13/pflag"
2424

25-
"github.com/kcp-dev/kcp/cmd/kubectl-kcp/cmd"
25+
"github.com/kcp-dev/kcp/cli/cmd/kubectl-kcp/cmd"
2626
)
2727

2828
func main() {

cmd/kubectl-workspace/main.go renamed to cli/cmd/kubectl-workspace/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"k8s.io/cli-runtime/pkg/genericclioptions"
2727
"k8s.io/klog/v2"
2828

29-
"github.com/kcp-dev/kcp/pkg/cliplugins/workspace/cmd"
29+
"github.com/kcp-dev/kcp/cli/pkg/workspace/cmd"
3030
)
3131

3232
func main() {

cli/go.mod

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
module github.com/kcp-dev/kcp/cli
2+
3+
go 1.20
4+
5+
require (
6+
github.com/MakeNowJust/heredoc v1.0.0
7+
github.com/google/go-cmp v0.6.0
8+
github.com/kcp-dev/client-go v0.0.0-20230927101349-0416c830e3b1
9+
github.com/kcp-dev/kcp/sdk v0.0.0-00010101000000-000000000000
10+
github.com/kcp-dev/logicalcluster/v3 v3.0.4
11+
github.com/muesli/reflow v0.3.0
12+
github.com/spf13/cobra v1.7.0
13+
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace
14+
github.com/stretchr/testify v1.8.4
15+
github.com/xlab/treeprint v1.2.0
16+
k8s.io/apiextensions-apiserver v0.28.2
17+
k8s.io/apimachinery v0.28.2
18+
k8s.io/cli-runtime v0.28.2
19+
k8s.io/client-go v0.28.2
20+
k8s.io/component-base v0.28.2
21+
k8s.io/klog/v2 v2.100.1
22+
)
23+
24+
require (
25+
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
26+
github.com/davecgh/go-spew v1.1.1 // indirect
27+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
28+
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
29+
github.com/go-errors/errors v1.4.2 // indirect
30+
github.com/go-logr/logr v1.3.0 // indirect
31+
github.com/go-openapi/jsonpointer v0.19.6 // indirect
32+
github.com/go-openapi/jsonreference v0.20.2 // indirect
33+
github.com/go-openapi/swag v0.22.3 // indirect
34+
github.com/gogo/protobuf v1.3.2 // indirect
35+
github.com/golang/protobuf v1.5.3 // indirect
36+
github.com/google/btree v1.0.1 // indirect
37+
github.com/google/gnostic-models v0.6.8 // indirect
38+
github.com/google/gofuzz v1.2.0 // indirect
39+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
40+
github.com/google/uuid v1.3.1 // indirect
41+
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
42+
github.com/imdario/mergo v0.3.12 // indirect
43+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
44+
github.com/josharian/intern v1.0.0 // indirect
45+
github.com/json-iterator/go v1.1.12 // indirect
46+
github.com/kcp-dev/apimachinery/v2 v2.0.0-alpha.0.0.20230926071920-57d168bcbe34 // indirect
47+
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
48+
github.com/mailru/easyjson v0.7.7 // indirect
49+
github.com/mattn/go-runewidth v0.0.12 // indirect
50+
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
51+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
52+
github.com/modern-go/reflect2 v1.0.2 // indirect
53+
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
54+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
55+
github.com/onsi/gomega v1.27.6 // indirect
56+
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
57+
github.com/pkg/errors v0.9.1 // indirect
58+
github.com/pmezard/go-difflib v1.0.0 // indirect
59+
github.com/rivo/uniseg v0.2.0 // indirect
60+
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
61+
golang.org/x/net v0.17.0 // indirect
62+
golang.org/x/oauth2 v0.13.0 // indirect
63+
golang.org/x/sync v0.4.0 // indirect
64+
golang.org/x/sys v0.16.0 // indirect
65+
golang.org/x/term v0.16.0 // indirect
66+
golang.org/x/text v0.14.0 // indirect
67+
golang.org/x/time v0.3.0 // indirect
68+
google.golang.org/appengine v1.6.7 // indirect
69+
google.golang.org/protobuf v1.31.0 // indirect
70+
gopkg.in/inf.v0 v0.9.1 // indirect
71+
gopkg.in/yaml.v2 v2.4.0 // indirect
72+
gopkg.in/yaml.v3 v3.0.1 // indirect
73+
k8s.io/api v0.28.2 // indirect
74+
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
75+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
76+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
77+
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
78+
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect
79+
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
80+
sigs.k8s.io/yaml v1.3.0 // indirect
81+
)
82+
83+
replace github.com/kcp-dev/kcp/sdk => ../sdk

0 commit comments

Comments
 (0)