From 24586152c131f1b918d109dd065e6d386f623f79 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Tue, 11 Jul 2023 11:43:09 +0200 Subject: [PATCH 1/2] Makefile: refactor how govc is built to workaround dependency issues building govc --- Makefile | 16 ++++++++++++++-- hack/go-install.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ hack/tools/Makefile | 5 ----- hack/tools/go.mod | 4 ---- hack/tools/go.sum | 8 -------- hack/tools/tools.go | 2 -- 6 files changed, 59 insertions(+), 21 deletions(-) create mode 100755 hack/go-install.sh diff --git a/Makefile b/Makefile index a5663cf92b..11850b8250 100644 --- a/Makefile +++ b/Makefile @@ -54,18 +54,24 @@ MANAGER := $(BIN_DIR)/manager CLUSTERCTL := $(BIN_DIR)/clusterctl # Tooling binaries +GO_INSTALL := ./hack/go-install.sh + +GOVC_VER := $(shell cat go.mod | grep "github.com/vmware/govmomi" | awk '{print $$NF}') +GOVC_BIN := govc +GOVC := $(abspath $(TOOLS_BIN_DIR)/$(GOVC_BIN)-$(GOVC_VER)) +GOVC_PKG := github.com/vmware/govmomi/govc + CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/controller-gen) CONVERSION_GEN := $(TOOLS_BIN_DIR)/conversion-gen GINKGO := $(TOOLS_BIN_DIR)/ginkgo GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint -GOVC := $(TOOLS_BIN_DIR)/govc KIND := $(TOOLS_BIN_DIR)/kind KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/setup-envtest) CONVERSION_VERIFIER := $(abspath $(TOOLS_BIN_DIR)/conversion-verifier) GO_APIDIFF := $(TOOLS_BIN_DIR)/go-apidiff RELEASE_NOTES := $(TOOLS_BIN_DIR)/release-notes -TOOLING_BINARIES := $(CONTROLLER_GEN) $(CONVERSION_GEN) $(GINKGO) $(GOLANGCI_LINT) $(GOVC) $(KIND) $(KUSTOMIZE) $(CONVERSION_VERIFIER) $(GO_APIDIFF) $(RELEASE_NOTES) +TOOLING_BINARIES := $(CONTROLLER_GEN) $(CONVERSION_GEN) $(GINKGO) $(GOLANGCI_LINT) $(KIND) $(KUSTOMIZE) $(CONVERSION_VERIFIER) $(GO_APIDIFF) $(RELEASE_NOTES) ARTIFACTS ?= $(ROOT_DIR)/_artifacts # Set --output-base for conversion-gen if we are not within GOPATH @@ -219,6 +225,12 @@ tools: $(TOOLING_BINARIES) ## Build tooling binaries $(TOOLING_BINARIES): make -C $(TOOLS_DIR) $(@F) +$(GOVC): # Build GOVC from tools folder. + CGO_ENABLED=0 GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOVC_PKG) $(GOVC_BIN) $(GOVC_VER) + +.PHONY: $(GOVC_BIN) +$(GOVC_BIN): $(GOVC) ## Build a local copy of kustomize. + ## -------------------------------------- ## Linting and fixing linter errors ## -------------------------------------- diff --git a/hack/go-install.sh b/hack/go-install.sh new file mode 100755 index 0000000000..a07b8e0f11 --- /dev/null +++ b/hack/go-install.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Copyright 2021 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +if [ -z "${1}" ]; then + echo "must provide module as first parameter" + exit 1 +fi + +if [ -z "${2}" ]; then + echo "must provide binary name as second parameter" + exit 1 +fi + +if [ -z "${3}" ]; then + echo "must provide version as third parameter" + exit 1 +fi + +if [ -z "${GOBIN}" ]; then + echo "GOBIN is not set. Must set GOBIN to install the bin in a specified directory." + exit 1 +fi + +rm -f "${GOBIN}/${2}"* || true + +# install the golang module specified as the first argument +go install "${1}@${3}" +mv "${GOBIN}/${2}" "${GOBIN}/${2}-${3}" +ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}" diff --git a/hack/tools/Makefile b/hack/tools/Makefile index e0b8dad66a..4c9cac16ae 100644 --- a/hack/tools/Makefile +++ b/hack/tools/Makefile @@ -40,7 +40,6 @@ GOLANGCI_LINT := $(BIN_DIR)/golangci-lint KUSTOMIZE := $(BIN_DIR)/kustomize CONVERSION_GEN := $(BIN_DIR)/conversion-gen KIND := $(BIN_DIR)/kind -GOVC := $(BIN_DIR)/govc GINKGO := $(BIN_DIR)/ginkgo CONVERSION_VERIFIER := $(BIN_DIR)/conversion-verifier APIDIFF := $(BIN_DIR)/go-apidiff @@ -73,10 +72,6 @@ golangci-lint: $(GOLANGCI_LINT) $(SRCS) ## Build golangci-lint $(GOLANGCI_LINT): go.mod go build -tags=tools -o $@ github.com/golangci/golangci-lint/cmd/golangci-lint -govc: $(GOVC) $(SRCS) -$(GOVC): go.mod - go build -tags=tools -o $@ github.com/vmware/govmomi/govc - kind: $(KIND) $(SRCS) $(KIND): go.mod go build -tags=tools -o $@ sigs.k8s.io/kind diff --git a/hack/tools/go.mod b/hack/tools/go.mod index 851c985fed..fbb20f8fa2 100644 --- a/hack/tools/go.mod +++ b/hack/tools/go.mod @@ -6,7 +6,6 @@ require ( github.com/golangci/golangci-lint v1.50.0 github.com/joelanford/go-apidiff v0.1.0 github.com/onsi/ginkgo/v2 v2.8.3 - github.com/vmware/govmomi v0.23.1 k8s.io/code-generator v0.25.0 sigs.k8s.io/cluster-api/hack/tools v0.0.0-20211104153216-fb1f86267fed sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20221201045826-d9912251cd81 @@ -125,8 +124,6 @@ require ( github.com/kisielk/errcheck v1.6.2 // indirect github.com/kisielk/gotool v1.0.0 // indirect github.com/kkHAIKE/contextcheck v1.1.2 // indirect - github.com/kr/pretty v0.3.0 // indirect - github.com/kr/text v0.2.0 // indirect github.com/kulti/thelper v0.6.3 // indirect github.com/kunwardeep/paralleltest v1.0.6 // indirect github.com/kyoh86/exportloopref v0.1.8 // indirect @@ -174,7 +171,6 @@ require ( github.com/quasilyte/gogrep v0.0.0-20220828223005-86e4605de09f // indirect github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/ryancurrah/gomodguard v1.2.4 // indirect github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect github.com/sanposhiho/wastedassign/v2 v2.0.6 // indirect diff --git a/hack/tools/go.sum b/hack/tools/go.sum index 75e72e639f..5fac4b8236 100644 --- a/hack/tools/go.sum +++ b/hack/tools/go.sum @@ -196,7 +196,6 @@ github.com/daixiang0/gci v0.8.0/go.mod h1:EpVfrztufwVgQRXjnX4zuNinEpLj5OmMjtu/+M github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892/go.mod h1:CTDl0pzVzE5DEzZhPfvhY/9sPFMQIxaJ9VAMs9AagrE= github.com/denis-tingaikin/go-header v0.4.3 h1:tEaZKAlqql6SKCY++utLmkPLd6K8IBM20Ha7UVm+mtU= github.com/denis-tingaikin/go-header v0.4.3/go.mod h1:0wOCWuN71D5qIgE2nz9KrKmuYBAC2Mra5RassOIQ2/c= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -440,7 +439,6 @@ github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 h1:SJ+NtwL6QaZ21U+ github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2/go.mod h1:Tv1PlzqC9t8wNnpPdctvtSUOPUUg4SHeE6vR1Ir2hmg= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= -github.com/google/uuid v0.0.0-20170306145142-6a5e28554805/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -577,7 +575,6 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -820,9 +817,7 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.21.0/go.mod h1:ZPhntP/xmq1nnND05hhpAh2QMhSsA4UN3MGZ6O2J3hM= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -967,9 +962,6 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/uudashr/gocognit v1.0.6 h1:2Cgi6MweCsdB6kpcVQp7EW4U23iBFQWfTXiWlyp842Y= github.com/uudashr/gocognit v1.0.6/go.mod h1:nAIUuVBnYU7pcninia3BHOvQkpQCeO76Uscky5BOwcY= -github.com/vmware/govmomi v0.23.1 h1:vU09hxnNR/I7e+4zCJvW+5vHu5dO64Aoe2Lw7Yi/KRg= -github.com/vmware/govmomi v0.23.1/go.mod h1:Y+Wq4lst78L85Ge/F8+ORXIWiKYqaro1vhAulACy9Lc= -github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= diff --git a/hack/tools/tools.go b/hack/tools/tools.go index ec65b570b5..965d25e0c9 100644 --- a/hack/tools/tools.go +++ b/hack/tools/tools.go @@ -24,8 +24,6 @@ import ( _ "github.com/golangci/golangci-lint/cmd/golangci-lint" _ "github.com/joelanford/go-apidiff" _ "github.com/onsi/ginkgo/v2/ginkgo" - _ "github.com/vmware/govmomi" - _ "github.com/vmware/govmomi/govc/flags" _ "k8s.io/code-generator/cmd/conversion-gen" _ "sigs.k8s.io/cluster-api/hack/tools" _ "sigs.k8s.io/controller-runtime/tools/setup-envtest" From 987cce7b9ca5de89e8592e1a93ca49fbb33fb668 Mon Sep 17 00:00:00 2001 From: Sagar Muchhal Date: Wed, 5 Apr 2023 08:47:12 -0700 Subject: [PATCH 2/2] Introduces the thumbprint value in CI yaml The value gets used to run the CI e2e tests. The value in the vsphere-dev.yaml is a placeholder which needs to be updated when running the tests locally. Signed-off-by: Sagar Muchhal --- test/e2e/config/vsphere-ci.yaml | 1 + test/e2e/config/vsphere-dev.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/test/e2e/config/vsphere-ci.yaml b/test/e2e/config/vsphere-ci.yaml index 5bead4fc92..8dd3809ec2 100644 --- a/test/e2e/config/vsphere-ci.yaml +++ b/test/e2e/config/vsphere-ci.yaml @@ -137,6 +137,7 @@ variables: WORKER_MACHINE_COUNT: 1 IP_FAMILY: "IPv4" CLUSTER_CLASS_NAME: "quick-start" + VSPHERE_TLS_THUMBPRINT: "18:EC:35:60:54:68:92:F6:F8:92:3E:4D:11:A1:0D:13:9C:E9:3E:B6" VSPHERE_DATACENTER: "SDDC-Datacenter" VSPHERE_FOLDER: "clusterapi" VSPHERE_RESOURCE_POOL: "clusterapi" diff --git a/test/e2e/config/vsphere-dev.yaml b/test/e2e/config/vsphere-dev.yaml index eebebc42f6..6e954a36e9 100644 --- a/test/e2e/config/vsphere-dev.yaml +++ b/test/e2e/config/vsphere-dev.yaml @@ -144,6 +144,7 @@ variables: IP_FAMILY: "IPv4" CLUSTER_CLASS_NAME: "quick-start" # Following CAPV variables should be set before testing + VSPHERE_TLS_THUMBPRINT: "10:CD:E8:AA:E5:67:8F:1B:6E:38:B3:60:58:06:9B:D2:A2:31:A3:85" VSPHERE_SERVER: "vcenter.vmware.com" VSPHERE_DATACENTER: "SDDC-Datacenter" VSPHERE_DATASTORE: "WorkloadDatastore"