Skip to content

Commit

Permalink
Merge pull request #3084 from sttts/sttts-cli-module
Browse files Browse the repository at this point in the history
✨ Move kubectl plugins into github.com/kcp-dev/kcp/cli module
  • Loading branch information
kcp-ci-bot authored Mar 8, 2024
2 parents d9dc3d0 + 133885c commit 6ea1cab
Show file tree
Hide file tree
Showing 36 changed files with 441 additions and 45 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ coverage.*
tools
build
vendor
goio.yaml

# JetBrains IDE files
.idea/
Expand All @@ -26,4 +27,4 @@ tmp
.prometheus-pid

go.work
go.work.sum
go.work.*
6 changes: 4 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ builds:
- CGO_ENABLED=0
- id: "kubectl-kcp"
main: ./cmd/kubectl-kcp
dir: cli
binary: bin/kubectl-kcp
ldflags:
- "{{ .Env.LDFLAGS }}"
Expand All @@ -38,6 +39,7 @@ builds:
- CGO_ENABLED=0
- id: "kubectl-workspace"
main: ./cmd/kubectl-workspace
dir: cli
binary: bin/kubectl-workspace
ldflags:
- "{{ .Env.LDFLAGS }}"
Expand All @@ -56,8 +58,8 @@ builds:
goarch: ppc64le
hooks:
post:
- ln -sfr bin/kubectl-workspace bin/kubectl-workspaces
- ln -sfr bin/kubectl-workspace bin/kubectl-ws
- ln -sf kubectl-workspace bin/kubectl-workspaces
- ln -sf kubectl-workspace bin/kubectl-ws
env:
- CGO_ENABLED=0
archives:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ COPY go.mod go.mod
COPY go.sum go.sum
COPY sdk/go.mod sdk/go.mod
COPY sdk/go.sum sdk/go.sum
COPY cli/go.mod cli/go.mod
COPY cli/go.sum cli/go.sum
USER 0

# Install kubectl.
Expand Down
2 changes: 1 addition & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ Shards in kcp represent a single apiserver and etcd/db instance. This is how kc

## Where can I get the kubectl workspace plugin?

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

14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ ldflags:
require-%:
@if ! command -v $* 1> /dev/null 2>&1; then echo "$* not found in ${PATH}"; exit 1; fi

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

install: WHAT ?= ./cmd/...
install: WHAT ?= ./cmd/... ./cli/cmd/...
install: require-jq require-go require-git verify-go-versions ## Install the project
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go install -ldflags="$(LDFLAGS)" $(WHAT)
set -x; for W in $(WHAT); do \
W=$$(echo "$${W}" | sed 's,^\./,github.com/kcp-dev/kcp/,') && \
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go install -ldflags="$(LDFLAGS)" $${W}; \
done
ln -sf $(INSTALL_GOBIN)/kubectl-workspace $(INSTALL_GOBIN)/kubectl-ws
ln -sf $(INSTALL_GOBIN)/kubectl-workspace $(INSTALL_GOBIN)/kubectl-workspaces
.PHONY: install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (
"k8s.io/component-base/version"
"k8s.io/klog/v2"

bindcmd "github.com/kcp-dev/kcp/pkg/cliplugins/bind/cmd"
claimscmd "github.com/kcp-dev/kcp/pkg/cliplugins/claims/cmd"
crdcmd "github.com/kcp-dev/kcp/pkg/cliplugins/crd/cmd"
workspacecmd "github.com/kcp-dev/kcp/pkg/cliplugins/workspace/cmd"
"github.com/kcp-dev/kcp/pkg/cmd/help"
bindcmd "github.com/kcp-dev/kcp/cli/pkg/bind/cmd"
claimscmd "github.com/kcp-dev/kcp/cli/pkg/claims/cmd"
crdcmd "github.com/kcp-dev/kcp/cli/pkg/crd/cmd"
"github.com/kcp-dev/kcp/cli/pkg/help"
workspacecmd "github.com/kcp-dev/kcp/cli/pkg/workspace/cmd"
)

func KubectlKcpCommand() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubectl-kcp/main.go → cli/cmd/kubectl-kcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/spf13/pflag"

"github.com/kcp-dev/kcp/cmd/kubectl-kcp/cmd"
"github.com/kcp-dev/kcp/cli/cmd/kubectl-kcp/cmd"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/klog/v2"

"github.com/kcp-dev/kcp/pkg/cliplugins/workspace/cmd"
"github.com/kcp-dev/kcp/cli/pkg/workspace/cmd"
)

func main() {
Expand Down
83 changes: 83 additions & 0 deletions cli/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
module github.com/kcp-dev/kcp/cli

go 1.20

require (
github.com/MakeNowJust/heredoc v1.0.0
github.com/google/go-cmp v0.6.0
github.com/kcp-dev/client-go v0.0.0-20230927101349-0416c830e3b1
github.com/kcp-dev/kcp/sdk v0.0.0-00010101000000-000000000000
github.com/kcp-dev/logicalcluster/v3 v3.0.4
github.com/muesli/reflow v0.3.0
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace
github.com/stretchr/testify v1.8.4
github.com/xlab/treeprint v1.2.0
k8s.io/apiextensions-apiserver v0.28.2
k8s.io/apimachinery v0.28.2
k8s.io/cli-runtime v0.28.2
k8s.io/client-go v0.28.2
k8s.io/component-base v0.28.2
k8s.io/klog/v2 v2.100.1
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kcp-dev/apimachinery/v2 v2.0.0-alpha.0.0.20230926071920-57d168bcbe34 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-runewidth v0.0.12 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/gomega v1.27.6 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.28.2 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/kcp-dev/kcp/sdk => ../sdk
Loading

0 comments on commit 6ea1cab

Please sign in to comment.