Skip to content

Commit 963fbe1

Browse files
committed
Bump govmomi to v0.45.0
1 parent 57259aa commit 963fbe1

File tree

6 files changed

+66
-8
lines changed

6 files changed

+66
-8
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
// The version of vm-operator should be kept in sync with the manifests at: config/deployments/integration-tests
1313
github.com/vmware-tanzu/vm-operator/api v1.8.6
1414
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505
15-
github.com/vmware/govmomi v0.43.0
15+
github.com/vmware/govmomi v0.45.1
1616
)
1717

1818
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ github.com/vmware-tanzu/vm-operator/api v1.8.6 h1:NIndORjcnSmIlQsCMIewpIwg/ocRVD
244244
github.com/vmware-tanzu/vm-operator/api v1.8.6/go.mod h1:HHA2SNI9B5Yqtyp5t+Gt9WTWBi/fIkM6+MukDDSf11A=
245245
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505 h1:y4wXx1FUFqqSgJ/xUOEM1DLS2Uu0KaeLADWpzpioGTU=
246246
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505/go.mod h1:5rqRJ9zGR+KnKbkGx373WgN8xJpvAj99kHnfoDYRO5I=
247-
github.com/vmware/govmomi v0.43.0 h1:7Kg3Bkdly+TrE67BYXzRq7ZrDnn7xqpKX95uEh2f9Go=
248-
github.com/vmware/govmomi v0.43.0/go.mod h1:IOv5nTXCPqH9qVJAlRuAGffogaLsNs8aF+e7vLgsHJU=
247+
github.com/vmware/govmomi v0.45.1 h1:pmMmSUNIw/kePaCRFaUOpDh7IxDfhDi9M4Qh+DRlBV4=
248+
github.com/vmware/govmomi v0.45.1/go.mod h1:uoLVU9zlXC4p4GmLVG+ZJmBC0Gn3Q7mytOJvi39OhxA=
249249
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
250250
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
251251
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=

internal/test/helpers/vcsim/builder.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,24 @@ limitations under the License.
1717
package vcsim
1818

1919
import (
20+
"crypto/rand"
2021
"crypto/tls"
22+
"crypto/x509"
23+
"crypto/x509/pkix"
2124
"fmt"
25+
"math/big"
26+
"net"
2227
"net/url"
2328
"os"
2429
"os/exec"
2530
"strings"
31+
"time"
2632

2733
"github.com/onsi/gomega/gbytes"
34+
"github.com/pkg/errors"
2835
"github.com/vmware/govmomi/simulator"
2936
_ "github.com/vmware/govmomi/vapi/cluster/simulator" // import this to register cluster module service test endpoint
37+
"sigs.k8s.io/cluster-api/util/certs"
3038
)
3139

3240
// Builder helps in creating a vcsim simulator.
@@ -81,6 +89,12 @@ func (b *Builder) Build() (*Simulator, error) {
8189
}
8290

8391
b.model.Service.TLS = new(tls.Config)
92+
keyPair, err := generateTLSKeyPair()
93+
if err != nil {
94+
return nil, err
95+
}
96+
97+
b.model.Service.TLS.Certificates = append(b.model.Service.TLS.Certificates, keyPair)
8498
b.model.Service.RegisterEndpoints = true
8599
server := b.model.Service.NewServer()
86100
simr := &Simulator{
@@ -119,3 +133,47 @@ func govcCommand(govcURL, commandStr string, buffers ...*gbytes.Buffer) *exec.Cm
119133
}
120134
return cmd
121135
}
136+
137+
// generateTLSKeyPair generates a self-signed certificatge keypair similar to the
138+
// hardcoded values in github.com/vmware/govmomi/simulator/internal but adds the
139+
// POD_IP to the IP Addresses of the certificate.
140+
func generateTLSKeyPair() (tls.Certificate, error) {
141+
privateKey, err := certs.NewPrivateKey()
142+
if err != nil {
143+
return tls.Certificate{}, err
144+
}
145+
146+
template := x509.Certificate{
147+
SerialNumber: new(big.Int).SetInt64(0),
148+
Subject: pkix.Name{
149+
Organization: []string{"CAPV vcsim"},
150+
},
151+
NotBefore: time.Now().Add(time.Minute * -5),
152+
NotAfter: time.Now().Add(time.Hour * 24 * 365),
153+
154+
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageCertSign,
155+
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
156+
BasicConstraintsValid: true,
157+
IsCA: true,
158+
IPAddresses: []net.IP{
159+
net.ParseIP("127.0.0.1"),
160+
net.ParseIP("::1"),
161+
},
162+
}
163+
164+
if ip := os.Getenv("POD_IP"); ip != "" {
165+
template.IPAddresses = append(template.IPAddresses, net.ParseIP(ip))
166+
}
167+
168+
b, err := x509.CreateCertificate(rand.Reader, &template, &template, &privateKey.PublicKey, privateKey)
169+
if err != nil {
170+
return tls.Certificate{}, errors.Wrap(err, "failed to create certificate")
171+
}
172+
173+
cert, err := x509.ParseCertificate(b)
174+
if err != nil {
175+
return tls.Certificate{}, errors.Wrap(err, "failed to parse certificate")
176+
}
177+
178+
return tls.X509KeyPair(certs.EncodeCertPEM(cert), certs.EncodePrivateKeyPEM(privateKey))
179+
}

packaging/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ github.com/vmware-tanzu/vm-operator/api v1.8.6 h1:NIndORjcnSmIlQsCMIewpIwg/ocRVD
135135
github.com/vmware-tanzu/vm-operator/api v1.8.6/go.mod h1:HHA2SNI9B5Yqtyp5t+Gt9WTWBi/fIkM6+MukDDSf11A=
136136
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505 h1:y4wXx1FUFqqSgJ/xUOEM1DLS2Uu0KaeLADWpzpioGTU=
137137
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505/go.mod h1:5rqRJ9zGR+KnKbkGx373WgN8xJpvAj99kHnfoDYRO5I=
138-
github.com/vmware/govmomi v0.43.0 h1:7Kg3Bkdly+TrE67BYXzRq7ZrDnn7xqpKX95uEh2f9Go=
139-
github.com/vmware/govmomi v0.43.0/go.mod h1:IOv5nTXCPqH9qVJAlRuAGffogaLsNs8aF+e7vLgsHJU=
138+
github.com/vmware/govmomi v0.45.1 h1:pmMmSUNIw/kePaCRFaUOpDh7IxDfhDi9M4Qh+DRlBV4=
139+
github.com/vmware/govmomi v0.45.1/go.mod h1:uoLVU9zlXC4p4GmLVG+ZJmBC0Gn3Q7mytOJvi39OhxA=
140140
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
141141
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
142142
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=

test/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/vmware-tanzu/net-operator-api v0.0.0-20240326163340-1f32d6bf7f9d
1515
// The version of vm-operator should be kept in sync with the manifests at: config/deployments/integration-tests
1616
github.com/vmware-tanzu/vm-operator/api v1.8.6
17-
github.com/vmware/govmomi v0.43.0
17+
github.com/vmware/govmomi v0.45.1
1818
)
1919

2020
require (

test/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ github.com/vmware-tanzu/vm-operator/api v1.8.6 h1:NIndORjcnSmIlQsCMIewpIwg/ocRVD
323323
github.com/vmware-tanzu/vm-operator/api v1.8.6/go.mod h1:HHA2SNI9B5Yqtyp5t+Gt9WTWBi/fIkM6+MukDDSf11A=
324324
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505 h1:y4wXx1FUFqqSgJ/xUOEM1DLS2Uu0KaeLADWpzpioGTU=
325325
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505/go.mod h1:5rqRJ9zGR+KnKbkGx373WgN8xJpvAj99kHnfoDYRO5I=
326-
github.com/vmware/govmomi v0.43.0 h1:7Kg3Bkdly+TrE67BYXzRq7ZrDnn7xqpKX95uEh2f9Go=
327-
github.com/vmware/govmomi v0.43.0/go.mod h1:IOv5nTXCPqH9qVJAlRuAGffogaLsNs8aF+e7vLgsHJU=
326+
github.com/vmware/govmomi v0.45.1 h1:pmMmSUNIw/kePaCRFaUOpDh7IxDfhDi9M4Qh+DRlBV4=
327+
github.com/vmware/govmomi v0.45.1/go.mod h1:uoLVU9zlXC4p4GmLVG+ZJmBC0Gn3Q7mytOJvi39OhxA=
328328
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
329329
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
330330
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=

0 commit comments

Comments
 (0)