Skip to content

Commit f960bad

Browse files
authored
Merge branch 'kubernetes-sigs:main' into main
2 parents 2153ac9 + e6c3d13 commit f960bad

File tree

123 files changed

+4837
-3435
lines changed

Some content is hidden

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

123 files changed

+4837
-3435
lines changed

.github/dependabot.yml

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,18 @@
1-
# To get started with Dependabot version updates, you'll need to specify which
2-
# package ecosystems to update and where the package manifests are located.
31
# Please see the documentation for all configuration options:
42
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5-
63
version: 2
74
updates:
8-
9-
# Maintain dependencies for GitHub Actions
10-
- package-ecosystem: "github-actions"
11-
# Workflow files stored in the
12-
# default location of `.github/workflows`
13-
directory: "/"
14-
schedule:
15-
interval: "weekly"
16-
commit-message:
17-
prefix: ":seedling:"
18-
labels:
19-
- "ok-to-test"
20-
21-
# Maintain dependencies for go
22-
- package-ecosystem: "gomod"
23-
directory: "/"
24-
schedule:
25-
interval: "weekly"
26-
commit-message:
27-
prefix: ":seedling:"
28-
# Ignore K8 packages as these are done manually
29-
ignore:
30-
- dependency-name: "k8s.io/api"
31-
- dependency-name: "k8s.io/apiextensions-apiserver"
32-
- dependency-name: "k8s.io/apimachinery"
33-
- dependency-name: "k8s.io/client-go"
34-
- dependency-name: "k8s.io/component-base"
35-
labels:
36-
- "ok-to-test"
5+
# GitHub Actions
6+
- package-ecosystem: "github-actions"
7+
# Workflow files stored in the
8+
# default location of `.github/workflows`
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
groups:
13+
all-github-actions:
14+
patterns: [ "*" ]
15+
commit-message:
16+
prefix: ":seedling:"
17+
labels:
18+
- "ok-to-test"

.github/workflows/golangci-lint.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ jobs:
2323
- ""
2424
- tools/setup-envtest
2525
steps:
26+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag=v4.1.7
27+
- name: Calculate go version
28+
id: vars
29+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
2630
- name: Set up Go
27-
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v5.0.0
31+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # tag=v5.0.2
2832
with:
29-
go-version: "1.22"
30-
cache: false
31-
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v4.1.2
33+
go-version: ${{ steps.vars.outputs.go_version }}
3234
- name: golangci-lint
33-
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # tag=v4.0.0
35+
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # tag=v6.1.0
3436
with:
3537
version: v1.57.2
3638
args: --out-format=colored-line-number

.github/workflows/ossf-scorecard.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jobs:
2626

2727
steps:
2828
- name: "Checkout code"
29-
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v4.1.2
29+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag=v4.1.7
3030
with:
3131
persist-credentials: false
3232

3333
- name: "Run analysis"
34-
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # tag=v2.3.1
34+
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # tag=v2.4.0
3535
with:
3636
results_file: results.sarif
3737
results_format: sarif
@@ -43,7 +43,7 @@ jobs:
4343

4444
# Upload the results as artifacts.
4545
- name: "Upload artifact"
46-
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # tag=v4.3.1
46+
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # tag=v4.3.6
4747
with:
4848
name: SARIF file
4949
path: results.sarif

.github/workflows/pr-dependabot.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Check out code
22-
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v4.1.2
22+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag=v4.1.7
23+
- name: Calculate go version
24+
id: vars
25+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
2326
- name: Set up Go
24-
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v5.0.0
27+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # tag=v5.0.2
2528
with:
26-
go-version: '1.22'
29+
go-version: ${{ steps.vars.outputs.go_version }}
2730
- name: Update all modules
2831
run: make modules
2932
- uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # tag=v9.1.4
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: PR approve GH Workflows
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- edited
7+
- labeled
8+
- reopened
9+
- synchronize
10+
11+
permissions: {}
12+
13+
jobs:
14+
approve:
15+
name: Approve ok-to-test
16+
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test')
17+
runs-on: ubuntu-latest
18+
permissions:
19+
actions: write
20+
steps:
21+
- name: Update PR
22+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
23+
continue-on-error: true
24+
with:
25+
github-token: ${{ secrets.GITHUB_TOKEN }}
26+
script: |
27+
const result = await github.rest.actions.listWorkflowRunsForRepo({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
event: "pull_request",
31+
status: "action_required",
32+
head_sha: context.payload.pull_request.head.sha,
33+
per_page: 100
34+
});
35+
36+
for (var run of result.data.workflow_runs) {
37+
await github.rest.actions.approveWorkflowRun({
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
run_id: run.id
41+
});
42+
}

.github/workflows/release.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Upload binaries to release
2+
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
name: Upload binaries to release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out code
18+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag=v4.1.7
19+
- name: Calculate go version
20+
id: vars
21+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
22+
- name: Set up Go
23+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # tag=v5.0.2
24+
with:
25+
go-version: ${{ steps.vars.outputs.go_version }}
26+
- name: Generate release binaries
27+
run: |
28+
make release
29+
- name: Release
30+
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # tag=v2.0.8
31+
with:
32+
draft: false
33+
files: tools/setup-envtest/out/*

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@
2323
# Tools binaries.
2424
hack/tools/bin
2525

26+
# Release artifacts
27+
tools/setup-envtest/out
28+
2629
junit-report.xml
27-
/artifacts
30+
/artifacts

.gomodcheck.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
upstreamRefs:
2+
- k8s.io/api
3+
- k8s.io/apiextensions-apiserver
4+
- k8s.io/apimachinery
5+
- k8s.io/apiserver
6+
- k8s.io/client-go
7+
- k8s.io/component-base
8+
# k8s.io/klog/v2 -> conflicts with k/k deps
9+
# k8s.io/utils -> conflicts with k/k deps
10+
11+
excludedModules:
12+
# --- test dependencies:
13+
- github.com/onsi/ginkgo/v2
14+
- github.com/onsi/gomega

Makefile

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
SHELL:=/usr/bin/env bash
2525
.DEFAULT_GOAL:=help
2626

27+
#
28+
# Go.
29+
#
30+
GO_VERSION ?= 1.22.5
31+
2732
# Use GOPROXY environment variable if set
2833
GOPROXY := $(shell go env GOPROXY)
2934
ifeq ($(GOPROXY),)
@@ -34,6 +39,13 @@ export GOPROXY
3439
# Active module mode, as we use go modules to manage dependencies
3540
export GO111MODULE=on
3641

42+
# Hosts running SELinux need :z added to volume mounts
43+
SELINUX_ENABLED := $(shell cat /sys/fs/selinux/enforce 2> /dev/null || echo 0)
44+
45+
ifeq ($(SELINUX_ENABLED),1)
46+
DOCKER_VOL_OPTS?=:z
47+
endif
48+
3749
# Tools.
3850
TOOLS_DIR := hack/tools
3951
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin)
@@ -92,6 +104,13 @@ GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
92104
$(GOLANGCI_LINT): # Build golangci-lint from tools folder.
93105
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOLANGCI_LINT_PKG) $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
94106

107+
GO_MOD_CHECK_DIR := $(abspath ./hack/tools/cmd/gomodcheck)
108+
GO_MOD_CHECK := $(abspath $(TOOLS_BIN_DIR)/gomodcheck)
109+
GO_MOD_CHECK_IGNORE := $(abspath .gomodcheck.yaml)
110+
.PHONY: $(GO_MOD_CHECK)
111+
$(GO_MOD_CHECK): # Build gomodcheck
112+
go build -C $(GO_MOD_CHECK_DIR) -o $(GO_MOD_CHECK)
113+
95114
## --------------------------------------
96115
## Linting
97116
## --------------------------------------
@@ -116,9 +135,47 @@ modules: ## Runs go mod to ensure modules are up to date.
116135
cd $(ENVTEST_DIR); go mod tidy
117136
cd $(SCRATCH_ENV_DIR); go mod tidy
118137

119-
.PHONY: generate
120-
generate: $(CONTROLLER_GEN) ## Runs controller-gen for internal types for config file
121-
$(CONTROLLER_GEN) object paths="./pkg/config/v1alpha1/...;./examples/configfile/custom/v1alpha1/..."
138+
## --------------------------------------
139+
## Release
140+
## --------------------------------------
141+
142+
RELEASE_DIR := tools/setup-envtest/out
143+
144+
.PHONY: $(RELEASE_DIR)
145+
$(RELEASE_DIR):
146+
mkdir -p $(RELEASE_DIR)/
147+
148+
.PHONY: release
149+
release: clean-release $(RELEASE_DIR) ## Build release.
150+
@if ! [ -z "$$(git status --porcelain)" ]; then echo "Your local git repository contains uncommitted changes, use git clean before proceeding."; exit 1; fi
151+
152+
# Build binaries first.
153+
$(MAKE) release-binaries
154+
155+
.PHONY: release-binaries
156+
release-binaries: ## Build release binaries.
157+
RELEASE_BINARY=setup-envtest-linux-amd64 GOOS=linux GOARCH=amd64 $(MAKE) release-binary
158+
RELEASE_BINARY=setup-envtest-linux-arm64 GOOS=linux GOARCH=arm64 $(MAKE) release-binary
159+
RELEASE_BINARY=setup-envtest-linux-ppc64le GOOS=linux GOARCH=ppc64le $(MAKE) release-binary
160+
RELEASE_BINARY=setup-envtest-linux-s390x GOOS=linux GOARCH=s390x $(MAKE) release-binary
161+
RELEASE_BINARY=setup-envtest-darwin-amd64 GOOS=darwin GOARCH=amd64 $(MAKE) release-binary
162+
RELEASE_BINARY=setup-envtest-darwin-arm64 GOOS=darwin GOARCH=arm64 $(MAKE) release-binary
163+
RELEASE_BINARY=setup-envtest-windows-amd64.exe GOOS=windows GOARCH=amd64 $(MAKE) release-binary
164+
165+
.PHONY: release-binary
166+
release-binary: $(RELEASE_DIR)
167+
docker run \
168+
--rm \
169+
-e CGO_ENABLED=0 \
170+
-e GOOS=$(GOOS) \
171+
-e GOARCH=$(GOARCH) \
172+
-e GOCACHE=/tmp/ \
173+
--user $$(id -u):$$(id -g) \
174+
-v "$$(pwd):/workspace$(DOCKER_VOL_OPTS)" \
175+
-w /workspace/tools/setup-envtest \
176+
golang:$(GO_VERSION) \
177+
go build -a -trimpath -ldflags "-extldflags '-static'" \
178+
-o ./out/$(RELEASE_BINARY) ./
122179

123180
## --------------------------------------
124181
## Cleanup / Verification
@@ -133,22 +190,29 @@ clean: ## Cleanup.
133190
clean-bin: ## Remove all generated binaries.
134191
rm -rf hack/tools/bin
135192

193+
.PHONY: clean-release
194+
clean-release: ## Remove the release folder
195+
rm -rf $(RELEASE_DIR)
196+
136197
.PHONY: verify-modules
137-
verify-modules: modules ## Verify go modules are up to date
198+
verify-modules: modules $(GO_MOD_CHECK) ## Verify go modules are up to date
138199
@if !(git diff --quiet HEAD -- go.sum go.mod $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/go.sum $(ENVTEST_DIR)/go.mod $(ENVTEST_DIR)/go.sum $(SCRATCH_ENV_DIR)/go.sum); then \
139200
git diff; \
140201
echo "go module files are out of date, please run 'make modules'"; exit 1; \
141202
fi
203+
$(GO_MOD_CHECK) $(GO_MOD_CHECK_IGNORE)
142204

143205
APIDIFF_OLD_COMMIT ?= $(shell git rev-parse origin/main)
144206

145207
.PHONY: apidiff
146208
verify-apidiff: $(GO_APIDIFF) ## Check for API differences
147209
$(GO_APIDIFF) $(APIDIFF_OLD_COMMIT) --print-compatible
148210

149-
.PHONY: verify-generate
150-
verify-generate: generate ## Verify generated files are up to date
151-
@if !(git diff --quiet HEAD); then \
152-
git diff; \
153-
echo "generated files are out of date, run make generate"; exit 1; \
154-
fi
211+
## --------------------------------------
212+
## Helpers
213+
## --------------------------------------
214+
215+
##@ helpers:
216+
217+
go-version: ## Print the go version we use to compile our binaries and images
218+
@echo $(GO_VERSION)

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ Contributors:
4040
* [Documentation Changes](/.github/PULL_REQUEST_TEMPLATE/docs.md)
4141
* [Test/Build/Other Changes](/.github/PULL_REQUEST_TEMPLATE/other.md)
4242

43+
## Compatibility
44+
45+
Every minor version of controller-runtime has been tested with a specific minor version of client-go. A controller-runtime minor version *may* be compatible with
46+
other client-go minor versions, but this is by chance and neither supported nor tested. In general, we create one minor version of controller-runtime
47+
for each minor version of client-go and other k8s.io/* dependencies.
48+
49+
The minimum Go version of controller-runtime is the highest minimum Go version of our Go dependencies. Usually, this will
50+
be identical to the minimum Go version of the corresponding k8s.io/* dependencies.
51+
52+
Compatible k8s.io/*, client-go and minimum Go versions can be looked up in our [go.mod](go.mod) file.
53+
54+
| | k8s.io/*, client-go | minimum Go version |
55+
|----------|:-------------------:|:------------------:|
56+
| CR v0.19 | v0.31 | 1.22 |
57+
| CR v0.18 | v0.30 | 1.22 |
58+
| CR v0.17 | v0.29 | 1.21 |
59+
| CR v0.16 | v0.28 | 1.20 |
60+
| CR v0.15 | v0.27 | 1.20 |
61+
4362
## FAQ
4463

4564
See [FAQ.md](FAQ.md)
@@ -57,6 +76,7 @@ You can reach the maintainers of this project at:
5776
- Google Group: [kubebuilder@googlegroups.com](https://groups.google.com/forum/#!forum/kubebuilder)
5877

5978
## Contributing
79+
6080
Contributions are greatly appreciated. The maintainers actively manage the issues list, and try to highlight issues suitable for newcomers.
6181
The project follows the typical GitHub pull request model. See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
6282
Before starting any work, please either comment on an existing issue, or file a new one.

0 commit comments

Comments
 (0)