Skip to content

Commit e86462c

Browse files
authored
Merge pull request #53 from mjudeikis/update.generation.kcp.example
🐛 fix kcp example generation
2 parents d9d2080 + e172110 commit e86462c

File tree

5 files changed

+343
-2
lines changed

5 files changed

+343
-2
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ modules: ## Runs go mod to ensure modules are up to date.
106106
.PHONY: generate
107107
generate: $(CONTROLLER_GEN) ## Runs controller-gen for internal types for config file
108108
$(CONTROLLER_GEN) object paths="./pkg/config/v1alpha1/...;./examples/configfile/custom/v1alpha1/...;./examples/kcp/..."
109+
cd examples/kcp && make generate
109110

110111
## --------------------------------------
111112
## Cleanup / Verification

examples/kcp/Makefile

+16-2
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@ SHELL := /bin/bash
44
help: ## Display this help.
55
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
66

7-
87
GO_INSTALL = ./hack/go-install.sh
98

109
LOCALBIN ?= $(shell pwd)/bin
10+
TOOLS_DIR=hack/tools
11+
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin)
1112
ARTIFACT_DIR ?= .test
1213

1314
KCP ?= $(LOCALBIN)/kcp
1415
KUBECTL_KCP ?= $(LOCALBIN)/kubectl-kcp
1516

1617
KCP_VERSION ?= 0.23.0
18+
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
19+
export CONTROLLER_GEN # so hack scripts can use it
20+
21+
KCP_APIGEN_VER := v0.21.0
22+
KCP_APIGEN_BIN := apigen
23+
KCP_APIGEN_GEN := $(TOOLS_BIN_DIR)/$(KCP_APIGEN_BIN)-$(KCP_APIGEN_VER)
24+
export KCP_APIGEN_GEN # so hack scripts can use it
1725

1826
OS ?= $(shell go env GOOS )
1927
ARCH ?= $(shell go env GOARCH )
@@ -27,6 +35,12 @@ $(KUBECTL_KCP): ## Download kcp kubectl plugins locally if necessary.
2735
curl -L -s -o - https://github.com/kcp-dev/kcp/releases/download/v$(KCP_VERSION)/kubectl-kcp-plugin_$(KCP_VERSION)_$(OS)_$(ARCH).tar.gz | tar --directory $(LOCALBIN)/../ -xvzf - bin
2836
touch $(KUBECTL_KCP) # we download an "old" file, so make will re-download to refresh it unless we make it newer than the owning dir
2937

38+
$(KCP_APIGEN_GEN):
39+
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/kcp-dev/kcp/sdk/cmd/apigen $(KCP_APIGEN_BIN) $(KCP_APIGEN_VER)
40+
41+
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
42+
cd $(TOOLS_DIR) && go build -tags=tools -o bin/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
43+
3044
build: $(KCP) $(KUBECTL_KCP) build-controller
3145

3246
ifeq (,$(shell go env GOBIN))
@@ -66,7 +80,7 @@ test-cleanup: ## Clean up processes and directories from an end-to-end test run.
6680
$(ARTIFACT_DIR)/kcp: ## Create a directory for the kcp server data.
6781
mkdir -p $(ARTIFACT_DIR)/kcp
6882

69-
generate: build # Generate code
83+
generate: build $(CONTROLLER_GEN) $(KCP_APIGEN_GEN) # Generate code
7084
./hack/update-codegen-crds.sh
7185

7286
run-local: build-controller kcp-bootstrap

examples/kcp/hack/tools/go.mod

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
module sigs.k8s.io/controller-runtime/hack/tools
2+
3+
go 1.21
4+
5+
toolchain go1.21.5
6+
7+
require (
8+
github.com/joelanford/go-apidiff v0.8.2
9+
sigs.k8s.io/controller-tools v0.14.0
10+
)
11+
12+
require (
13+
dario.cat/mergo v1.0.0 // indirect
14+
github.com/Microsoft/go-winio v0.6.1 // indirect
15+
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
16+
github.com/cloudflare/circl v1.3.7 // indirect
17+
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
18+
github.com/emirpasic/gods v1.18.1 // indirect
19+
github.com/fatih/color v1.16.0 // indirect
20+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
21+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
22+
github.com/go-git/go-git/v5 v5.11.0 // indirect
23+
github.com/go-logr/logr v1.3.0 // indirect
24+
github.com/gobuffalo/flect v1.0.2 // indirect
25+
github.com/gogo/protobuf v1.3.2 // indirect
26+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
27+
github.com/google/gofuzz v1.2.0 // indirect
28+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
29+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
30+
github.com/json-iterator/go v1.1.12 // indirect
31+
github.com/kevinburke/ssh_config v1.2.0 // indirect
32+
github.com/mattn/go-colorable v0.1.13 // indirect
33+
github.com/mattn/go-isatty v0.0.20 // indirect
34+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
35+
github.com/modern-go/reflect2 v1.0.2 // indirect
36+
github.com/pjbgf/sha1cd v0.3.0 // indirect
37+
github.com/sergi/go-diff v1.1.0 // indirect
38+
github.com/skeema/knownhosts v1.2.1 // indirect
39+
github.com/spf13/cobra v1.8.0 // indirect
40+
github.com/spf13/pflag v1.0.5 // indirect
41+
github.com/xanzy/ssh-agent v0.3.3 // indirect
42+
golang.org/x/crypto v0.18.0 // indirect
43+
golang.org/x/exp v0.0.0-20230811145653-3b0b5b66b5f1 // indirect
44+
golang.org/x/mod v0.14.0 // indirect
45+
golang.org/x/net v0.20.0 // indirect
46+
golang.org/x/sys v0.16.0 // indirect
47+
golang.org/x/text v0.14.0 // indirect
48+
golang.org/x/tools v0.17.0 // indirect
49+
gopkg.in/inf.v0 v0.9.1 // indirect
50+
gopkg.in/warnings.v0 v0.1.2 // indirect
51+
gopkg.in/yaml.v2 v2.4.0 // indirect
52+
gopkg.in/yaml.v3 v3.0.1 // indirect
53+
k8s.io/api v0.29.0 // indirect
54+
k8s.io/apiextensions-apiserver v0.29.0 // indirect
55+
k8s.io/apimachinery v0.29.0 // indirect
56+
k8s.io/klog/v2 v2.110.1 // indirect
57+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
58+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
59+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
60+
sigs.k8s.io/yaml v1.4.0 // indirect
61+
)

0 commit comments

Comments
 (0)