Skip to content

Commit f8d9625

Browse files
Merge pull request #331 from shiftstack/sync-main-martin
OCPBUGS-43892: manual rebase on upstream release-0.11
2 parents d856cc3 + 44509be commit f8d9625

File tree

27,711 files changed

+7417396
-337611
lines changed

Some content is hidden

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

27,711 files changed

+7417396
-337611
lines changed

.github/dependabot.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Please see the documentation for all configuration options: https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
2+
3+
version: 2
4+
updates:
5+
6+
# github-actions
7+
- directory: "/"
8+
package-ecosystem: "github-actions"
9+
open-pull-requests-limit: 5
10+
schedule:
11+
interval: "weekly"
12+
day: "monday"
13+
groups:
14+
all-github-actions:
15+
patterns: [ "*" ]
16+
commit-message:
17+
prefix: ":seedling: chore(deps): bump"
18+
include: scope
19+
labels:
20+
- "area/dependency"
21+
- "ok-to-test"
22+
23+
# Go directories
24+
- directories:
25+
- "/"
26+
- "/hack/tools"
27+
- "/orc"
28+
package-ecosystem: "gomod"
29+
open-pull-requests-limit: 5
30+
schedule:
31+
interval: "weekly"
32+
day: "monday"
33+
## group all dependencies with a k8s.io prefix into a single PR.
34+
groups:
35+
all-go-mod-patch-and-minor:
36+
patterns: [ "*" ]
37+
update-types: [ "patch", "minor" ]
38+
commit-message:
39+
prefix: ":seedling: chore(deps): bump"
40+
include: scope
41+
ignore:
42+
# Ignore controller-runtime as its upgraded manually.
43+
- dependency-name: "sigs.k8s.io/controller-runtime"
44+
update-types: [ "version-update:semver-major", "version-update:semver-minor" ]
45+
# Ignore k8s and its transitives modules as they are upgraded manually together with controller-runtime.
46+
- dependency-name: "k8s.io/*"
47+
update-types: [ "version-update:semver-major", "version-update:semver-minor" ]
48+
- dependency-name: "github.com/prometheus/*"
49+
update-types: [ "version-update:semver-major", "version-update:semver-minor" ]
50+
- dependency-name: "sigs.k8s.io/cluster-api-provider-openstack"
51+
labels:
52+
- "area/dependency"
53+
- "ok-to-test"

.github/workflows/pr-dependabot.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: PR dependabot code generation and go modules fix
2+
3+
# This action runs on other PRs opened by dependabot. It updates modules and generated code on PRs opened by dependabot.
4+
on:
5+
pull_request:
6+
branches:
7+
- dependabot/**
8+
push:
9+
branches:
10+
- dependabot/**
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: write # Allow to update the PR.
15+
16+
jobs:
17+
build:
18+
name: Build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check out code into the Go module directory
22+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
23+
- name: Calculate go version
24+
id: vars
25+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
26+
- name: Set up Go
27+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # tag=v5.1.0
28+
with:
29+
go-version: ${{ steps.vars.outputs.go_version }}
30+
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # tag=v4.1.2
31+
name: Restore go cache
32+
with:
33+
path: |
34+
~/.cache/go-build
35+
~/go/pkg/mod
36+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
37+
restore-keys: |
38+
${{ runner.os }}-go-
39+
- name: Update all modules
40+
run: make modules
41+
- name: Update generated code
42+
run: make generate
43+
- uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # tag=v9.1.4
44+
name: Commit changes
45+
with:
46+
author_name: dependabot[bot]
47+
author_email: 49699333+dependabot[bot]@users.noreply.github.com
48+
default_author: github_actor
49+
message: 'Update generated code'

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ kubernetes.tar.gz
146146
# generated files in any directory
147147
# TODO(thockin): uncomment this when we stop committing the generated files.
148148
#zz_generated.*
149-
zz_generated.openapi.go
149+
#zz_generated.openapi.go
150150

151151
# make-related metadata
152152
/.make/
@@ -183,8 +183,8 @@ docs/book/book/
183183

184184
# Don't ignore anything in vendor directories
185185
!/vendor/**
186+
!/orc/vendor/**
186187
!/hack/tools/vendor/**
187-
188-
# Ignore go workspaces
189-
go.work
190-
go.work.sum
188+
# TODO Drop the codegen vendoring after 0.11
189+
!/orc/hack/codegen/vendor/**
190+
!/hack/codegen/vendor/**

.golangci.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ linters:
55
- asciicheck
66
- bidichk
77
- bodyclose
8+
- copyloopvar
89
- cyclop
9-
# - depguard
1010
- dogsled
1111
- dupword
1212
- durationcheck
1313
- errcheck
14-
- exportloopref
1514
- forbidigo
1615
- gci
1716
- goconst
@@ -56,7 +55,11 @@ linters-settings:
5655
# TODO(sbuerin) fix remaining findings and set to 20 afterwards
5756
max-complexity: 30
5857
gci:
59-
local-prefixes: sigs.k8s.io/cluster-api-provider-openstack
58+
sections:
59+
- standard
60+
- default
61+
- prefix(github.com/k-orc/openstack-resource-controller)
62+
- prefix(sigs.k8s.io/cluster-api-provider-openstack)
6063
gocritic:
6164
enabled-tags:
6265
- diagnostic
@@ -96,8 +99,8 @@ linters-settings:
9699
- pkg: sigs.k8s.io/controller-runtime
97100
alias: ctrl
98101
# CAPO
99-
- pkg: sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha5
100-
alias: infrav1alpha5
102+
- pkg: sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha1
103+
alias: infrav1alpha1
101104
- pkg: sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha6
102105
alias: infrav1alpha6
103106
- pkg: sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7
@@ -127,14 +130,13 @@ linters-settings:
127130
alias: controlplanev1alpha4
128131
- pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1
129132
alias: controlplanev1
133+
# ORC
134+
- pkg: github.com/k-orc/openstack-resource-controller/api/v1alpha1
135+
alias: orcv1alpha1
130136

131137
nolintlint:
132138
# https://github.com/golangci/golangci-lint/issues/3228
133139
allow-unused: true
134-
staticcheck:
135-
go: "1.20"
136-
stylecheck:
137-
go: "1.20"
138140
nestif:
139141
# minimal complexity of if statements to report, 5 by default
140142
# TODO(sbuerin) fix remaining findings and set to 5 after:
@@ -176,12 +178,13 @@ issues:
176178
- stylecheck
177179
text: "ST1003: should not use underscores in Go names;"
178180
path: pkg/utils/conversioncommon/.*.go
181+
exclude-files:
182+
- "zz_generated.*\\.go$"
179183

180184
run:
185+
go: "1.22"
181186
timeout: 10m
182187
build-tags:
183188
- e2e
184189

185-
skip-files:
186-
- "zz_generated.*\\.go$"
187190
allow-parallel-runners: true

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ ARG goproxy=https://proxy.golang.org
2121
ENV GOPROXY=$goproxy
2222

2323
# Copy the Go Modules manifests
24+
RUN mkdir orc
2425
COPY go.mod go.mod
2526
COPY go.sum go.sum
27+
COPY orc/go.mod orc/go.mod
28+
COPY orc/go.sum orc/go.sum
2629

2730
# Cache deps before building and copying source so that we don't need to re-download as much
2831
# and so that source changes don't invalidate our downloaded layer

Makefile

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,25 @@ KUBETEST_CONF_PATH ?= $(abspath $(E2E_DATA_DIR)/kubetest/conformance.yaml)
4141
KUBETEST_FAST_CONF_PATH ?= $(abspath $(E2E_DATA_DIR)/kubetest/conformance-fast.yaml)
4242
GO_INSTALL := ./scripts/go_install.sh
4343

44+
# go-apidiff
45+
GO_APIDIFF_VER := v0.8.2
46+
GO_APIDIFF_BIN := go-apidiff
47+
GO_APIDIFF_PKG := github.com/joelanford/go-apidiff
48+
4449
# Binaries.
4550
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
4651
CONVERSION_GEN := $(TOOLS_BIN_DIR)/conversion-gen
4752
ENVSUBST := $(TOOLS_BIN_DIR)/envsubst
4853
GINKGO := $(TOOLS_BIN_DIR)/ginkgo
4954
GOJQ := $(TOOLS_BIN_DIR)/gojq
5055
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
56+
GOTESTSUM := $(TOOLS_BIN_DIR)/gotestsum
5157
KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize
5258
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
5359
RELEASE_NOTES := $(TOOLS_BIN_DIR)/release-notes
5460
SETUP_ENVTEST := $(TOOLS_BIN_DIR)/setup-envtest
5561
GEN_CRD_API_REFERENCE_DOCS := $(TOOLS_BIN_DIR)/gen-crd-api-reference-docs
62+
GO_APIDIFF := $(TOOLS_BIN_DIR)/$(GO_APIDIFF_BIN)-$(GO_APIDIFF_VER)
5663

5764
# Kubebuilder
5865
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.28.0
@@ -140,8 +147,16 @@ kubebuilder_assets: $(SETUP_ENVTEST)
140147

141148
.PHONY: test
142149
TEST_PATHS ?= ./...
143-
test: kubebuilder_assets
144-
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -v $(TEST_PATHS) $(TEST_ARGS)
150+
test: test-capo test-orc
151+
152+
.PHONY: test-capo
153+
test-capo: $(ARTIFACTS) $(GOTESTSUM) kubebuilder_assets
154+
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" $(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.test.xml --junitfile-hide-empty-pkg --jsonfile $(ARTIFACTS)/test-output.log -- \
155+
-v $(TEST_PATHS) $(TEST_ARGS)
156+
157+
.PHONY: test-orc
158+
test-orc:
159+
$(MAKE) -C $(REPO_ROOT)/orc test
145160

146161
E2E_TEMPLATES_DIR=test/e2e/data/infrastructure-openstack
147162
E2E_KUSTOMIZE_DIR=test/e2e/data/kustomize
@@ -151,7 +166,6 @@ E2E_NO_ARTIFACT_TEMPLATES_DIR=test/e2e/data/infrastructure-openstack-no-artifact
151166
.PHONY: e2e-templates
152167
e2e-templates: ## Generate cluster templates for e2e tests
153168
e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
154-
cluster-template-v1alpha6.yaml \
155169
cluster-template-v1alpha7.yaml \
156170
cluster-template-md-remediation.yaml \
157171
cluster-template-kcp-remediation.yaml \
@@ -209,6 +223,11 @@ test-conformance: $(GINKGO) e2e-prerequisites ## Run clusterctl based conformanc
209223
test-conformance-fast: ## Run clusterctl based conformance test on workload cluster (requires Docker) using a subset of the conformance suite in parallel.
210224
$(MAKE) test-conformance CONFORMANCE_E2E_ARGS="-kubetest.config-file=$(KUBETEST_FAST_CONF_PATH) -kubetest.ginkgo-nodes=5 $(E2E_ARGS)"
211225

226+
APIDIFF_OLD_COMMIT ?= $(shell git rev-parse origin/main)
227+
228+
.PHONY: apidiff
229+
apidiff: $(GO_APIDIFF) ## Check for API differences.
230+
$(GO_APIDIFF) $(APIDIFF_OLD_COMMIT)
212231

213232
## --------------------------------------
214233
##@ Binaries
@@ -225,17 +244,25 @@ managers:
225244
manager-openstack-infrastructure: ## Build manager binary.
226245
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR)/manager .
227246

247+
.PHONY: $(GO_APIDIFF_BIN)
248+
$(GO_APIDIFF_BIN): $(GO_APIDIFF)
249+
250+
$(GO_APIDIFF): # Build go-apidiff.
251+
GOBIN=$(abspath $(TOOLS_BIN_DIR)) $(GO_INSTALL) $(GO_APIDIFF_PKG) $(GO_APIDIFF_BIN) $(GO_APIDIFF_VER)
252+
228253
## --------------------------------------
229254
##@ Linting
230255
## --------------------------------------
231256

232257
.PHONY: lint
233258
lint: $(GOLANGCI_LINT) ## Lint codebase
234259
$(GOLANGCI_LINT) run -v --fast=false
260+
$(MAKE) -C $(REPO_ROOT)/orc lint
235261

236262
.PHONY: lint-update
237263
lint-update: $(GOLANGCI_LINT) ## Lint codebase
238264
$(GOLANGCI_LINT) run -v --fast=false --fix
265+
$(MAKE) -C $(REPO_ROOT)/orc lint-fix
239266

240267
lint-fast: $(GOLANGCI_LINT) ## Run only faster linters to detect possible issues
241268
$(GOLANGCI_LINT) run -v --fast=true
@@ -246,11 +273,13 @@ lint-fast: $(GOLANGCI_LINT) ## Run only faster linters to detect possible issues
246273

247274
.PHONY: modules
248275
modules: ## Runs go mod to ensure proper vendoring.
276+
$(MAKE) -C $(REPO_ROOT)/orc modules
249277
go mod tidy
250278
cd $(TOOLS_DIR); go mod tidy
279+
cd $(REPO_ROOT)/hack/codegen; go work sync; go mod tidy
251280

252281
.PHONY: generate
253-
generate: templates generate-controller-gen generate-conversion-gen generate-go generate-manifests generate-api-docs ## Generate all generated code
282+
generate: templates generate-orc generate-controller-gen generate-codegen generate-conversion-gen generate-go generate-manifests generate-api-docs ## Generate all generated code
254283

255284
.PHONY: generate-go
256285
generate-go: $(MOCKGEN)
@@ -262,18 +291,22 @@ generate-controller-gen: $(CONTROLLER_GEN)
262291
paths=./api/... \
263292
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt
264293

294+
.PHONY: generate-codegen
295+
generate-codegen: generate-controller-gen
296+
./hack/update-codegen.sh
297+
298+
.PHONY: generate-orc
299+
generate-orc:
300+
$(MAKE) -C $(REPO_ROOT)/orc generate
301+
265302
.PHONY: generate-conversion-gen
266-
capo_module := sigs.k8s.io/cluster-api-provider-openstack
267303
generate-conversion-gen: $(CONVERSION_GEN)
268304
$(CONVERSION_GEN) \
269-
--input-dirs=$(capo_module)/api/v1alpha5 \
270-
--input-dirs=$(capo_module)/api/v1alpha6 \
271-
--input-dirs=$(capo_module)/api/v1alpha7 \
272-
--extra-dirs=$(capo_module)/pkg/utils/optional \
273-
--extra-dirs=$(capo_module)/pkg/utils/conversioncommon \
274-
--output-file-base=zz_generated.conversion \
275-
--trim-path-prefix=$(capo_module)/ \
276-
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
305+
--extra-peer-dirs=./pkg/utils/optional \
306+
--extra-peer-dirs=./pkg/utils/conversioncommon \
307+
--output-file=zz_generated.conversion.go \
308+
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
309+
./api/v1alpha6 ./api/v1alpha7
277310

278311
.PHONY: generate-manifests
279312
generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
@@ -288,6 +321,7 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
288321
$(CONTROLLER_GEN) \
289322
paths=./ \
290323
paths=./controllers/... \
324+
paths=./internal/controllers/... \
291325
output:rbac:dir=$(RBAC_ROOT) \
292326
rbac:roleName=manager-role
293327

@@ -506,25 +540,30 @@ clean-release: ## Remove the release folder
506540
rm -rf $(RELEASE_DIR)
507541

508542
.PHONY: verify
509-
verify: verify-boilerplate verify-modules verify-gen
543+
verify: verify-boilerplate verify-modules verify-gen verify-orc
510544

511545
.PHONY: verify-boilerplate
512546
verify-boilerplate:
513547
./hack/verify-boilerplate.sh
514548

515549
.PHONY: verify-modules
516550
verify-modules: modules
517-
@if !(git diff --quiet HEAD -- go.sum go.mod hack/tools/go.mod hack/tools/go.sum); then \
551+
@if !(git diff --quiet HEAD -- go.* hack/tools/go.* hack/codegen/go.*); then \
518552
git diff; \
519553
echo "go module files are out of date"; exit 1; \
520554
fi
521555

556+
.PHONY: verify-gen
522557
verify-gen: generate
523558
@if !(git diff --quiet HEAD); then \
524559
git diff; \
525560
echo "generated files are out of date, run make generate"; exit 1; \
526561
fi
527562

563+
.PHONY: verify-orc
564+
verify-orc:
565+
$(MAKE) -C $(REPO_ROOT)/orc verify-generated
566+
528567
.PHONY: vendor verify-vendoring
529568
vendor:
530569
go mod vendor

0 commit comments

Comments
 (0)