Skip to content

Commit b041809

Browse files
committed
Update client-go version & improve test harness
1 parent 9514405 commit b041809

File tree

78 files changed

+574
-14348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+574
-14348
lines changed

Diff for: .github/workflows/test-one.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
- name: Install Go
2323
uses: actions/setup-go@v3
2424
with:
25-
go-version: "1.18.x"
26-
- name: Create k8s cluster (using kind)
27-
uses: helm/kind-action@v1.3.0
25+
go-version: "1.21.3"
26+
- name: Create test Kubernetes cluster (using kind)
27+
uses: helm/kind-action@v1.5.0
2828
with:
2929
node_image: kindest/node:v${{ inputs.k8s_cluster_ver }}
30-
- name: Run mini-program ${{ inputs.example_program }} on k8s v${{ inputs.k8s_cluster_ver }} using client-go ${{ inputs.k8s_package_ver }}
30+
- name: Run mini-program ${{ inputs.example_program }} on Kubernetes v${{ inputs.k8s_cluster_ver }} using client-go v${{ inputs.k8s_package_ver }}
3131
run: |
3232
cd ${{ inputs.example_program }}
3333
go mod edit -replace k8s.io/client-go=k8s.io/client-go@v${{ inputs.k8s_package_ver }}

Diff for: .github/workflows/test.yml

+37-18
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
outputs:
2323
dirs: ${{ steps.make-list.outputs.dirs }}
2424

25-
client_go_0_23:
25+
client_go_0_25:
2626
needs: prepare
2727
strategy:
2828
fail-fast: false
@@ -31,17 +31,17 @@ jobs:
3131
matrix:
3232
example_program: ${{ fromJson(needs.prepare.outputs.dirs) }}
3333
k8s_cluster_ver:
34-
- "1.22.15"
35-
- "1.23.12"
36-
- "1.24.6"
37-
- "1.25.2"
34+
- "1.25.11"
35+
- "1.26.6"
36+
- "1.27.3"
37+
- "1.28.0"
3838
uses: ./.github/workflows/test-one.yml
3939
with:
4040
example_program: ${{ matrix.example_program }}
4141
k8s_cluster_ver: ${{ matrix.k8s_cluster_ver }}
42-
k8s_package_ver: "0.23.1"
42+
k8s_package_ver: "0.25.15"
4343

44-
client_go_0_24:
44+
client_go_0_26:
4545
needs: prepare
4646
strategy:
4747
fail-fast: false
@@ -50,17 +50,36 @@ jobs:
5050
matrix:
5151
example_program: ${{ fromJson(needs.prepare.outputs.dirs) }}
5252
k8s_cluster_ver:
53-
- "1.22.15"
54-
- "1.23.12"
55-
- "1.24.6"
56-
- "1.25.2"
53+
- "1.25.11"
54+
- "1.26.6"
55+
- "1.27.3"
56+
- "1.28.0"
5757
uses: ./.github/workflows/test-one.yml
5858
with:
5959
example_program: ${{ matrix.example_program }}
6060
k8s_cluster_ver: ${{ matrix.k8s_cluster_ver }}
61-
k8s_package_ver: "0.24.7"
61+
k8s_package_ver: "0.26.10"
6262

63-
client_go_0_25:
63+
client_go_0_27:
64+
needs: prepare
65+
strategy:
66+
fail-fast: false
67+
# A matrix can produce no more than 256 elements,
68+
# so testing too many k8s versions is unfeasible.
69+
matrix:
70+
example_program: ${{ fromJson(needs.prepare.outputs.dirs) }}
71+
k8s_cluster_ver:
72+
- "1.25.11"
73+
- "1.26.6"
74+
- "1.27.3"
75+
- "1.28.0"
76+
uses: ./.github/workflows/test-one.yml
77+
with:
78+
example_program: ${{ matrix.example_program }}
79+
k8s_cluster_ver: ${{ matrix.k8s_cluster_ver }}
80+
k8s_package_ver: "0.27.7"
81+
82+
client_go_0_28:
6483
needs: prepare
6584
strategy:
6685
fail-fast: false
@@ -69,12 +88,12 @@ jobs:
6988
matrix:
7089
example_program: ${{ fromJson(needs.prepare.outputs.dirs) }}
7190
k8s_cluster_ver:
72-
- "1.22.15"
73-
- "1.23.12"
74-
- "1.24.6"
75-
- "1.25.2"
91+
- "1.25.11"
92+
- "1.26.6"
93+
- "1.27.3"
94+
- "1.28.0"
7695
uses: ./.github/workflows/test-one.yml
7796
with:
7897
example_program: ${{ matrix.example_program }}
7998
k8s_cluster_ver: ${{ matrix.k8s_cluster_ver }}
80-
k8s_package_ver: "0.25.3"
99+
k8s_package_ver: "0.28.3"

Diff for: Makefile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
CUR_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
2+
3+
MINI_PROGRAMS_DIRS := $(shell find $(CUR_DIR) -type f -name go.mod -exec dirname {} \; | xargs -n 1 basename | sort -u)
4+
5+
6+
.PHONY: test-%
7+
test-%:
8+
@echo "\033[0;32m-- Test $*\033[0m"
9+
@cd ${CUR_DIR}/$* && make test && echo "\t--- PASS" || echo "\t--- FAILED"
10+
11+
.PHONY: test-all
12+
test-all: $(addprefix test-, $(MINI_PROGRAMS_DIRS))
13+
@echo "\033[0;32mDone all!\033[0m"
14+
15+
.PHONY: go-mod-tidy-%
16+
go-mod-tidy-%:
17+
@cd ${CUR_DIR}/$* && make go-mod-tidy
18+
19+
.PHONY: go-mod-tidy-all
20+
go-mod-tidy-all: $(addprefix go-mod-tidy-, $(MINI_PROGRAMS_DIRS))
21+
@echo "\033[0;32mDone all!\033[0m"

Diff for: README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@
66

77
A collection of mini-programs demonstrating various [client-go](https://github.com/kubernetes/client-go) use cases augmented by a [preconfigured online development environment](https://labs.iximiuz.com/playgrounds/k8s-client-go/). Inspired by [client-go/examples](https://github.com/kubernetes/client-go/tree/master/examples).
88

9-
The intention (at least so far) is to test a (more or less) fresh version of Go and packages against a few latest
10-
Kubernetes versions.
9+
The intention is to test a (more or less) fresh version of Go and `k8s.io` packages against the [currently maintained Kubernetes release branches](https://kubernetes.io/releases/).
1110

1211
What is tested at the moment:
1312

14-
- `go 1.18`
15-
- `k8s.io/client-go v0.23.1 v0.24.7 v0.25.3`
16-
- `Kubernetes v1.22.15 1.23.12 v1.24.6 v1.25.2`
13+
- `go 1.21.3`
14+
- `k8s.io/client-go 0.25.15 0.26.10 0.27.7 0.28.3` (maintained release branches)
15+
- `Kubernetes 1.25.11 1.26.6 1.27.3 1.28.0` (best-effort match with versions supported by `kind`)
1716

1817
## Setup
1918

20-
Most examples expect `minikube` with at least two Kubernetes clusters - `shared1` and `shared2`.
19+
Most examples expect at least two Kubernetes clusters - `shared1` and `shared2`.
2120

2221
```bash
2322
curl -sLS https://get.arkade.dev | sudo sh
24-
arkade get minikube kubectl
23+
arkade get kind kubectl
2524

26-
minikube start --profile shared1
27-
minikube start --profile shared2
25+
kind create cluster --name shared1
26+
kind create cluster --name shared2
2827
```
2928

3029
## Run
@@ -33,7 +32,10 @@ Oversimplified (for now):
3332

3433
```bash
3534
cd <program>
36-
go run main.go
35+
make test
36+
37+
# or from the root folder:
38+
make test-all
3739
```
3840

3941
## TODO

Diff for: cli-runtime-flags/Makefile

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
test:
2-
go run main.go
1+
CUR_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
2+
3+
4+
.PHONY: test
5+
test: go-mod-tidy
6+
go run ${CUR_DIR}/main.go
7+
8+
.PHONY: go-mod-tidy
9+
go-mod-tidy:
10+
cd ${CUR_DIR} && go mod tidy

Diff for: cli-runtime-flags/go.mod

+2-63
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,7 @@
11
module github.com/iximiuz/client-go-examples/cli-runtime-flags
22

3-
go 1.18
3+
go 1.21.3
44

55
require (
6-
k8s.io/cli-runtime v0.23.1
7-
k8s.io/client-go v0.23.1 // indirect
8-
)
9-
10-
require github.com/spf13/cobra v1.2.1
11-
12-
require (
13-
github.com/PuerkitoBio/purell v1.1.1 // indirect
14-
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
15-
github.com/davecgh/go-spew v1.1.1 // indirect
16-
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
17-
github.com/go-errors/errors v1.0.1 // indirect
18-
github.com/go-logr/logr v1.2.0 // indirect
19-
github.com/go-openapi/jsonpointer v0.19.5 // indirect
20-
github.com/go-openapi/jsonreference v0.19.5 // indirect
21-
github.com/go-openapi/swag v0.19.14 // indirect
22-
github.com/gogo/protobuf v1.3.2 // indirect
23-
github.com/golang/protobuf v1.5.2 // indirect
24-
github.com/google/btree v1.0.1 // indirect
25-
github.com/google/go-cmp v0.5.5 // indirect
26-
github.com/google/gofuzz v1.1.0 // indirect
27-
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
28-
github.com/google/uuid v1.1.2 // indirect
29-
github.com/googleapis/gnostic v0.5.5 // indirect
30-
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
31-
github.com/imdario/mergo v0.3.5 // indirect
32-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
33-
github.com/josharian/intern v1.0.0 // indirect
34-
github.com/json-iterator/go v1.1.12 // indirect
35-
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
36-
github.com/mailru/easyjson v0.7.6 // indirect
37-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
38-
github.com/modern-go/reflect2 v1.0.2 // indirect
39-
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
40-
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
41-
github.com/pkg/errors v0.9.1 // indirect
42-
github.com/pmezard/go-difflib v1.0.0 // indirect
43-
github.com/spf13/pflag v1.0.5 // indirect
44-
github.com/stretchr/testify v1.7.0 // indirect
45-
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
46-
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
47-
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
48-
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
49-
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e // indirect
50-
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
51-
golang.org/x/text v0.3.7 // indirect
52-
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
53-
google.golang.org/appengine v1.6.7 // indirect
54-
google.golang.org/protobuf v1.27.1 // indirect
55-
gopkg.in/inf.v0 v0.9.1 // indirect
56-
gopkg.in/yaml.v2 v2.4.0 // indirect
57-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
58-
k8s.io/api v0.23.1 // indirect
59-
k8s.io/apimachinery v0.23.1 // indirect
60-
k8s.io/klog/v2 v2.30.0 // indirect
61-
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
62-
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect
63-
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
64-
sigs.k8s.io/kustomize/api v0.10.1 // indirect
65-
sigs.k8s.io/kustomize/kyaml v0.13.0 // indirect
66-
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
67-
sigs.k8s.io/yaml v1.2.0 // indirect
6+
k8s.io/cli-runtime v0.28.3
687
)

0 commit comments

Comments
 (0)