Skip to content

Commit 15ba0d6

Browse files
committed
update branch, add test, fix lint
1 parent 956ac71 commit 15ba0d6

File tree

72 files changed

+5917
-3230
lines changed

Some content is hidden

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

72 files changed

+5917
-3230
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
.golangci.yml
66
bin/
77
**/*.yaml
8-
hack/
98
out/
109
docs/
1110
packaging/

.github/workflows/cover.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Harden Runner
15-
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
15+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
1616
with:
1717
egress-policy: audit
1818

1919
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
2020
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
2121
with:
22-
go-version: '1.21'
22+
go-version: '1.22'
2323
- run: "PATH=/usr/local/go/bin:$PATH make test-cover"
2424
# Retry codecov upload. It is flaky due to a known issue https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
2525
- uses: Wandalen/wretry.action@6feedb7dedadeb826de0f45ff482b53b379a7844 # v3.5.0

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
run:
22
timeout: 10m
3-
go: "1.21"
3+
go: "1.22"
44
skip-files:
55
- "zz_generated.*\\.go$"
66
- "_conversion\\.go$"

Makefile

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ SHELL:=/usr/bin/env bash
2323
#
2424
# Go.
2525
#
26-
GO_VERSION ?= 1.21.9
26+
GO_VERSION ?= 1.22.4
2727
GO_CONTAINER_IMAGE ?= docker.io/library/golang:$(GO_VERSION)
28-
GO_DIRECTIVE_VERSION ?= 1.21.0
28+
GO_DIRECTIVE_VERSION ?= 1.22.0
2929

3030
# Use GOPROXY environment variable if set
3131
GOPROXY := $(shell go env GOPROXY)
@@ -68,13 +68,6 @@ GO_TOOLS_BUILD := ./hack/go-tools-build.sh
6868

6969
export PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH)
7070

71-
# Set --output-base for conversion-gen if we are not within GOPATH
72-
ifneq ($(abspath $(ROOT_DIR)),$(shell go env GOPATH)/src/sigs.k8s.io/cluster-api-provider-vsphere)
73-
CONVERSION_GEN_OUTPUT_BASE := --output-base=$(ROOT_DIR)
74-
else
75-
export GOPATH := $(shell go env GOPATH)
76-
endif
77-
7871
#
7972
# Ginkgo configuration.
8073
#
@@ -84,7 +77,7 @@ GINKGO_NODES ?= 1
8477
GINKGO_TIMEOUT ?= 3h
8578
E2E_CONF_FILE ?= $(abspath test/e2e/config/vsphere.yaml)
8679
E2E_CONF_OVERRIDE_FILE ?= $(abspath test/e2e/config/config-overrides.yaml)
87-
E2E_IPAM_KUBECONFIG ?=
80+
E2E_VSPHERE_IP_POOL ?=
8881
E2E_TEMPLATE_DIR := $(abspath test/e2e/data/)
8982
E2E_GOVMOMI_TEMPLATE_DIR := $(E2E_TEMPLATE_DIR)/infrastructure-vsphere-govmomi
9083
E2E_SUPERVISOR_TEMPLATE_DIR := $(E2E_TEMPLATE_DIR)/infrastructure-vsphere-supervisor
@@ -119,7 +112,7 @@ SETUP_ENVTEST_BIN := setup-envtest
119112
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
120113
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
121114

122-
CONTROLLER_GEN_VER := v0.13.0
115+
CONTROLLER_GEN_VER := v0.15.0
123116
CONTROLLER_GEN_BIN := controller-gen
124117
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))
125118
CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
@@ -129,7 +122,7 @@ GOTESTSUM_BIN := gotestsum
129122
GOTESTSUM := $(abspath $(TOOLS_BIN_DIR)/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER))
130123
GOTESTSUM_PKG := gotest.tools/gotestsum
131124

132-
CONVERSION_GEN_VER := v0.28.0
125+
CONVERSION_GEN_VER := v0.30.0
133126
CONVERSION_GEN_BIN := conversion-gen
134127
# We are intentionally using the binary without version suffix, to avoid the version
135128
# in generated files.
@@ -193,6 +186,9 @@ IMPORT_BOSS_PKG := k8s.io/code-generator/cmd/import-boss
193186

194187
CAPI_HACK_TOOLS_VER := ef04465b2ba76214eea570e27e8146c96412e32a # Note: this is the commit ID of CAPI v1.7.1
195188

189+
BOSKOSCTL_BIN := boskosctl
190+
BOSKOSCTL := $(abspath $(TOOLS_BIN_DIR)/$(BOSKOSCTL_BIN))
191+
196192
CONVERSION_VERIFIER_VER := $(CAPI_HACK_TOOLS_VER)
197193
CONVERSION_VERIFIER_BIN := conversion-verifier
198194
CONVERSION_VERIFIER := $(abspath $(TOOLS_BIN_DIR)/$(CONVERSION_VERIFIER_BIN)-$(CONVERSION_VERIFIER_VER))
@@ -237,6 +233,14 @@ VM_OPERATOR_ALL_ARCH = amd64 arm64
237233
NET_OPERATOR_IMAGE_NAME ?= cluster-api-net-operator
238234
NET_OPERATOR_IMG ?= $(STAGING_REGISTRY)/$(NET_OPERATOR_IMAGE_NAME)
239235

236+
# boskosctl
237+
BOSKOSCTL_IMG ?= gcr.io/k8s-staging-capi-vsphere/extra/boskosctl
238+
BOSKOSCTL_IMG_TAG ?= $(shell git describe --always --dirty)
239+
240+
# openvpn
241+
OPENVPN_IMG ?= gcr.io/k8s-staging-capi-vsphere/extra/openvpn
242+
OPENVPN_IMG_TAG ?= $(shell git describe --always --dirty)
243+
240244
# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
241245

242246
TAG ?= dev
@@ -341,11 +345,10 @@ generate-go-deepcopy: $(CONTROLLER_GEN) ## Generate deepcopy go code for core
341345
generate-go-conversions: $(CONTROLLER_GEN) $(CONVERSION_GEN) ## Runs Go related generate targets
342346
$(MAKE) clean-generated-conversions SRC_DIRS="./apis/v1alpha3,./apis/v1alpha4"
343347
$(CONVERSION_GEN) \
344-
--input-dirs=./apis/v1alpha3 \
345-
--input-dirs=./apis/v1alpha4 \
346-
--build-tag=ignore_autogenerated \
347-
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
348-
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
348+
--output-file=zz_generated.conversion.go \
349+
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
350+
./apis/v1alpha3 \
351+
./apis/v1alpha4
349352

350353
.PHONY: generate-modules
351354
generate-modules: ## Run go mod tidy to ensure modules are up to date
@@ -568,6 +571,28 @@ docker-build-net-operator: docker-pull-prerequisites ## Build the docker image f
568571
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./$(NETOP_DIR)/config/default/manager_pull_policy.yaml"; \
569572
fi
570573

574+
.PHONY: docker-build-boskosctl
575+
docker-build-boskosctl:
576+
cat hack/tools/boskosctl/Dockerfile | DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) . -t $(BOSKOSCTL_IMG):$(BOSKOSCTL_IMG_TAG) --file -
577+
docker tag $(BOSKOSCTL_IMG):$(BOSKOSCTL_IMG_TAG) $(BOSKOSCTL_IMG):latest
578+
.PHONY: build
579+
580+
.PHONY: docker-push-boskosctl
581+
docker-push-boskosctl:
582+
docker push $(BOSKOSCTL_IMG):$(BOSKOSCTL_IMG_TAG)
583+
docker push $(BOSKOSCTL_IMG):latest
584+
585+
.PHONY: docker-build-openvpn
586+
docker-build-openvpn:
587+
cat hack/tools/openvpn/Dockerfile | DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) . -t $(OPENVPN_IMG):$(OPENVPN_IMG_TAG) --file -
588+
docker tag $(OPENVPN_IMG):$(OPENVPN_IMG_TAG) $(OPENVPN_IMG):latest
589+
.PHONY: build
590+
591+
.PHONY: docker-push-openvpn
592+
docker-push-openvpn:
593+
docker push $(OPENVPN_IMG):$(OPENVPN_IMG_TAG)
594+
docker push $(OPENVPN_IMG):latest
595+
571596
## --------------------------------------
572597
## Testing
573598
## --------------------------------------
@@ -592,6 +617,8 @@ test-verbose: ## Run unit tests with verbose flag
592617

593618
.PHONY: test-junit
594619
test-junit: $(SETUP_ENVTEST) $(GOTESTSUM) $(GOVC) ## Run unit tests
620+
# Note: running ensure.go to make sure tests run with the correct kube-kins image in CI
621+
hack/ensure-go.sh
595622
# Note: ARTIFACTS must be set so the ginkgo suites write junit reports to the ARTIFACTS folder
596623
set +o errexit; (ARTIFACTS=$(ARTIFACTS) KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" GOVC_BIN_PATH=$(GOVC) go test -json ./apis/... ./controllers/... ./pkg/... ./internal/... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit.exitcode) | tee $(ARTIFACTS)/junit.stdout
597624
$(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.xml --raw-command cat $(ARTIFACTS)/junit.stdout
@@ -627,7 +654,7 @@ e2e: $(GINKGO) $(KUSTOMIZE) $(KIND) $(GOVC) ## Run e2e tests
627654
--e2e.artifacts-folder="$(ARTIFACTS)" \
628655
--e2e.skip-resource-cleanup=$(SKIP_RESOURCE_CLEANUP) \
629656
--e2e.use-existing-cluster="$(USE_EXISTING_CLUSTER)" \
630-
--e2e.ipam-kubeconfig="$(E2E_IPAM_KUBECONFIG)"
657+
--e2e.ip-pool='$(E2E_VSPHERE_IP_POOL)'
631658

632659
## --------------------------------------
633660
## Release
@@ -958,6 +985,9 @@ $(CONVERSION_GEN_BIN): $(CONVERSION_GEN) ## Build a local copy of conversion-gen
958985
.PHONY: $(PROWJOB_GEN_BIN)
959986
$(PROWJOB_GEN_BIN): $(PROWJOB_GEN) ## Build a local copy of prowjob-gen.
960987

988+
.PHONY: $(BOSKOSCTL_BIN)
989+
$(BOSKOSCTL_BIN): $(BOSKOSCTL) ## Build a local copy of boskosctl.
990+
961991
.PHONY: $(CONVERSION_VERIFIER_BIN)
962992
$(CONVERSION_VERIFIER_BIN): $(CONVERSION_VERIFIER) ## Build a local copy of conversion-verifier.
963993

@@ -1012,6 +1042,9 @@ $(CONTROLLER_GEN): # Build controller-gen.
10121042
$(CONVERSION_GEN): # Build conversion-gen.
10131043
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(CONVERSION_GEN_PKG) $(CONVERSION_GEN_BIN) $(CONVERSION_GEN_VER)
10141044

1045+
$(BOSKOSCTL): # Build boskosctl from tools folder.
1046+
go build -o $(TOOLS_BIN_DIR)/$(BOSKOSCTL_BIN) ./hack/tools/boskosctl
1047+
10151048
$(CONVERSION_VERIFIER): # Build conversion-verifier.
10161049
GOBIN=$(TOOLS_BIN_DIR) $(GO_TOOLS_BUILD) $(CONVERSION_VERIFIER_PKG) $(CONVERSION_VERIFIER_BIN) $(CONVERSION_VERIFIER_VER)
10171050

apis/v1beta1/vspherefailuredomain_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type VSphereFailureDomainSpec struct {
5050
VMTemplate VirtualMachineTemplate `json:"vmTemplate"`
5151
}
5252

53-
// VirtualMachineTemplate defines parameters for VM
53+
// VirtualMachineTemplate defines parameters for VM.
5454
type VirtualMachineTemplate struct {
5555
// Template defines the name or inventory path of the template used to clone
5656
// the virtual machine

cloudbuild-nightly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ options:
55
substitution_option: ALLOW_LOOSE
66
machineType: 'E2_HIGHCPU_8'
77
steps:
8-
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20230522-312425ae46'
8+
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud@sha256:de53ba7cd20326776a00adb065430a8bb51beaf24876ffcbd4e8f71b74dbc22d' # v20240210-29014a6e3a
99
entrypoint: make
1010
env:
1111
- DOCKER_CLI_EXPERIMENTAL=enabled

cloudbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ options:
55
substitution_option: ALLOW_LOOSE
66
machineType: 'E2_HIGHCPU_8'
77
steps:
8-
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20230522-312425ae46'
8+
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud@sha256:de53ba7cd20326776a00adb065430a8bb51beaf24876ffcbd4e8f71b74dbc22d' # v20240210-29014a6e3a
99
entrypoint: make
1010
env:
1111
- DOCKER_CLI_EXPERIMENTAL=enabled

0 commit comments

Comments
 (0)