From 7026a4ab41910a4c253a0bb528ea8d36b03121d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 29 Sep 2024 01:04:30 +0000 Subject: [PATCH] Bump github.com/vmware/govmomi from 0.42.0 to 0.43.0 Bumps [github.com/vmware/govmomi](https://github.com/vmware/govmomi) from 0.42.0 to 0.43.0. - [Release notes](https://github.com/vmware/govmomi/releases) - [Changelog](https://github.com/vmware/govmomi/blob/main/CHANGELOG.md) - [Commits](https://github.com/vmware/govmomi/compare/v0.42.0...v0.43.0) --- updated-dependencies: - dependency-name: github.com/vmware/govmomi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 +- go.sum | 8 +- .../govmomi/internal/version/version.go | 2 +- .../vmware/govmomi/object/datacenter.go | 12 ++- .../vmware/govmomi/object/virtual_machine.go | 25 +++++-- .../govmomi/vim25/json/discriminator.go | 6 +- .../vmware/govmomi/vim25/soap/error.go | 20 +++++ .../vmware/govmomi/vim25/types/fault.go | 12 +++ .../vmware/govmomi/vim25/types/helpers.go | 75 +++++++++++++++++++ vendor/modules.txt | 4 +- 10 files changed, 147 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index fc4d6bde..431de589 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/onsi/ginkgo/v2 v2.20.1 github.com/onsi/gomega v1.34.2 github.com/urfave/cli/v2 v2.27.4 - github.com/vmware/govmomi v0.42.0 + github.com/vmware/govmomi v0.43.0 golang.org/x/crypto v0.26.0 k8s.io/apimachinery v0.31.1 sigs.k8s.io/controller-runtime v0.19.0 @@ -51,7 +51,7 @@ require ( github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/tools v0.24.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index 48ac2f22..2c8341f6 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8= github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ= -github.com/vmware/govmomi v0.42.0 h1:MbvAlVfjNBE1mHMaQ7yOSop1KLB0/93x6VAGuCtjqtI= -github.com/vmware/govmomi v0.42.0/go.mod h1:1H5LWwsBif8HKZqbFp0FdoKTHyJE4FzL6ACequMKYQg= +github.com/vmware/govmomi v0.43.0 h1:7Kg3Bkdly+TrE67BYXzRq7ZrDnn7xqpKX95uEh2f9Go= +github.com/vmware/govmomi v0.43.0/go.mod h1:IOv5nTXCPqH9qVJAlRuAGffogaLsNs8aF+e7vLgsHJU= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= @@ -131,8 +131,8 @@ golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= diff --git a/vendor/github.com/vmware/govmomi/internal/version/version.go b/vendor/github.com/vmware/govmomi/internal/version/version.go index f0c027c6..fc0a6591 100644 --- a/vendor/github.com/vmware/govmomi/internal/version/version.go +++ b/vendor/github.com/vmware/govmomi/internal/version/version.go @@ -21,5 +21,5 @@ const ( ClientName = "govmomi" // ClientVersion is the version of this SDK - ClientVersion = "0.42.0" + ClientVersion = "0.43.0" ) diff --git a/vendor/github.com/vmware/govmomi/object/datacenter.go b/vendor/github.com/vmware/govmomi/object/datacenter.go index 41fa3526..8caea3eb 100644 --- a/vendor/github.com/vmware/govmomi/object/datacenter.go +++ b/vendor/github.com/vmware/govmomi/object/datacenter.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2015 VMware, Inc. All Rights Reserved. +Copyright (c) 2015-2024 VMware, Inc. All Rights Reserved. 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 +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, @@ -18,7 +18,7 @@ package object import ( "context" - "fmt" + "path" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/methods" @@ -69,8 +69,12 @@ func (d *Datacenter) Folders(ctx context.Context) (*DatacenterFolders, error) { {"network", &df.NetworkFolder.InventoryPath}, } + dcPath := d.InventoryPath + if dcPath == "" { + dcPath = "/" + md.Name + } for _, p := range paths { - *p.path = fmt.Sprintf("/%s/%s", md.Name, p.name) + *p.path = path.Join(dcPath, p.name) } return df, nil diff --git a/vendor/github.com/vmware/govmomi/object/virtual_machine.go b/vendor/github.com/vmware/govmomi/object/virtual_machine.go index 4665fcb7..3f8f6ebe 100644 --- a/vendor/github.com/vmware/govmomi/object/virtual_machine.go +++ b/vendor/github.com/vmware/govmomi/object/virtual_machine.go @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved. +Copyright (c) 2015-2024 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -500,7 +500,7 @@ func diskFileOperation(op types.VirtualDeviceConfigSpecOperation, fop types.Virt return "" } -func (v VirtualMachine) configureDevice(ctx context.Context, op types.VirtualDeviceConfigSpecOperation, fop types.VirtualDeviceConfigSpecFileOperation, devices ...types.BaseVirtualDevice) error { +func (v VirtualMachine) configureDevice(ctx context.Context, profile []types.BaseVirtualMachineProfileSpec, op types.VirtualDeviceConfigSpecOperation, fop types.VirtualDeviceConfigSpecFileOperation, devices ...types.BaseVirtualDevice) error { spec := types.VirtualMachineConfigSpec{} for _, device := range devices { @@ -508,6 +508,7 @@ func (v VirtualMachine) configureDevice(ctx context.Context, op types.VirtualDev Device: device, Operation: op, FileOperation: diskFileOperation(op, fop, device), + Profile: profile, } spec.DeviceChange = append(spec.DeviceChange, config) @@ -523,12 +524,22 @@ func (v VirtualMachine) configureDevice(ctx context.Context, op types.VirtualDev // AddDevice adds the given devices to the VirtualMachine func (v VirtualMachine) AddDevice(ctx context.Context, device ...types.BaseVirtualDevice) error { - return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationAdd, types.VirtualDeviceConfigSpecFileOperationCreate, device...) + return v.AddDeviceWithProfile(ctx, nil, device...) +} + +// AddDeviceWithProfile adds the given devices to the VirtualMachine with the given profile +func (v VirtualMachine) AddDeviceWithProfile(ctx context.Context, profile []types.BaseVirtualMachineProfileSpec, device ...types.BaseVirtualDevice) error { + return v.configureDevice(ctx, profile, types.VirtualDeviceConfigSpecOperationAdd, types.VirtualDeviceConfigSpecFileOperationCreate, device...) } // EditDevice edits the given (existing) devices on the VirtualMachine func (v VirtualMachine) EditDevice(ctx context.Context, device ...types.BaseVirtualDevice) error { - return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationEdit, types.VirtualDeviceConfigSpecFileOperationReplace, device...) + return v.EditDeviceWithProfile(ctx, nil, device...) +} + +// EditDeviceWithProfile edits the given (existing) devices on the VirtualMachine with the given profile +func (v VirtualMachine) EditDeviceWithProfile(ctx context.Context, profile []types.BaseVirtualMachineProfileSpec, device ...types.BaseVirtualDevice) error { + return v.configureDevice(ctx, profile, types.VirtualDeviceConfigSpecOperationEdit, types.VirtualDeviceConfigSpecFileOperationReplace, device...) } // RemoveDevice removes the given devices on the VirtualMachine @@ -537,17 +548,17 @@ func (v VirtualMachine) RemoveDevice(ctx context.Context, keepFiles bool, device if keepFiles { fop = "" } - return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationRemove, fop, device...) + return v.configureDevice(ctx, nil, types.VirtualDeviceConfigSpecOperationRemove, fop, device...) } // AttachDisk attaches the given disk to the VirtualMachine -func (v VirtualMachine) AttachDisk(ctx context.Context, id string, datastore *Datastore, controllerKey int32, unitNumber int32) error { +func (v VirtualMachine) AttachDisk(ctx context.Context, id string, datastore *Datastore, controllerKey int32, unitNumber *int32) error { req := types.AttachDisk_Task{ This: v.Reference(), DiskId: types.ID{Id: id}, Datastore: datastore.Reference(), ControllerKey: controllerKey, - UnitNumber: &unitNumber, + UnitNumber: unitNumber, } res, err := methods.AttachDisk_Task(ctx, v.c, &req) diff --git a/vendor/github.com/vmware/govmomi/vim25/json/discriminator.go b/vendor/github.com/vmware/govmomi/vim25/json/discriminator.go index ce315dd5..eed9a664 100644 --- a/vendor/github.com/vmware/govmomi/vim25/json/discriminator.go +++ b/vendor/github.com/vmware/govmomi/vim25/json/discriminator.go @@ -354,7 +354,11 @@ func discriminatorInterfaceEncode(e *encodeState, v reflect.Value, opts encOpts) e.discriminatorEncodeTypeName = true newStructEncoder(v.Type())(e, v, opts) case reflect.Ptr: - discriminatorInterfaceEncode(e, v, opts) + if v.IsZero() { + newPtrEncoder(v.Type())(e, v, opts) + } else { + discriminatorInterfaceEncode(e, v, opts) + } default: discriminatorValue := opts.discriminatorValueFn(v.Type()) if discriminatorValue == "" { diff --git a/vendor/github.com/vmware/govmomi/vim25/soap/error.go b/vendor/github.com/vmware/govmomi/vim25/soap/error.go index fd30e3ff..5d4fff45 100644 --- a/vendor/github.com/vmware/govmomi/vim25/soap/error.go +++ b/vendor/github.com/vmware/govmomi/vim25/soap/error.go @@ -62,6 +62,26 @@ func (s soapFaultError) MarshalJSON() ([]byte, error) { return json.Marshal(out) } +func (s soapFaultError) Fault() types.BaseMethodFault { + if s.fault != nil { + fault := s.fault.Detail.Fault + if fault == nil { + return nil + } + if f, ok := fault.(types.BaseMethodFault); ok { + return f + } + if val := reflect.ValueOf(fault); val.Kind() != reflect.Pointer { + ptrVal := reflect.New(val.Type()) + ptrVal.Elem().Set(val) + if f, ok := ptrVal.Interface().(types.BaseMethodFault); ok { + return f + } + } + } + return nil +} + type vimFaultError struct { fault types.BaseMethodFault } diff --git a/vendor/github.com/vmware/govmomi/vim25/types/fault.go b/vendor/github.com/vmware/govmomi/vim25/types/fault.go index 813ea9ec..8b0c1a8d 100644 --- a/vendor/github.com/vmware/govmomi/vim25/types/fault.go +++ b/vendor/github.com/vmware/govmomi/vim25/types/fault.go @@ -41,3 +41,15 @@ func IsAlreadyExists(err error) bool { return false } + +// HasLocalizedMethodFault is any type that has a LocalizedMethodFault. +type HasLocalizedMethodFault interface { + + // GetLocalizedMethodFault returns the LocalizedMethodFault instance. + GetLocalizedMethodFault() *LocalizedMethodFault +} + +// GetLocalizedMethodFault returns this LocalizedMethodFault. +func (f *LocalizedMethodFault) GetLocalizedMethodFault() *LocalizedMethodFault { + return f +} diff --git a/vendor/github.com/vmware/govmomi/vim25/types/helpers.go b/vendor/github.com/vmware/govmomi/vim25/types/helpers.go index 94fb50df..531b90d8 100644 --- a/vendor/github.com/vmware/govmomi/vim25/types/helpers.go +++ b/vendor/github.com/vmware/govmomi/vim25/types/helpers.go @@ -17,6 +17,9 @@ limitations under the License. package types import ( + "bytes" + "encoding/json" + "fmt" "net/url" "reflect" "strings" @@ -316,6 +319,78 @@ func (ci VirtualMachineConfigInfo) ToConfigSpec() VirtualMachineConfigSpec { return cs } +// ToString returns the string-ified version of the provided input value by +// first attempting to encode the value to JSON using the vimtype JSON encoder, +// and if that should fail, using the standard JSON encoder, and if that fails, +// returning the value formatted with Sprintf("%v"). +// +// Please note, this function is not intended to replace marshaling the data +// to JSON using the normal workflows. This function is for when a string-ified +// version of the data is needed for things like logging. +func ToString(in AnyType) (s string) { + if in == nil { + return "null" + } + + marshalWithSprintf := func() string { + return fmt.Sprintf("%v", in) + } + + defer func() { + if err := recover(); err != nil { + s = marshalWithSprintf() + } + }() + + rv := reflect.ValueOf(in) + switch rv.Kind() { + + case reflect.Bool, + reflect.Complex64, reflect.Complex128, + reflect.Float32, reflect.Float64: + + return fmt.Sprintf("%v", in) + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Uintptr: + + return fmt.Sprintf("%d", in) + + case reflect.String: + return in.(string) + + case reflect.Interface, reflect.Pointer: + if rv.IsZero() { + return "null" + } + return ToString(rv.Elem().Interface()) + } + + marshalWithStdlibJSONEncoder := func() string { + data, err := json.Marshal(in) + if err != nil { + return marshalWithSprintf() + } + return string(data) + } + + defer func() { + if err := recover(); err != nil { + s = marshalWithStdlibJSONEncoder() + } + }() + + var w bytes.Buffer + enc := NewJSONEncoder(&w) + if err := enc.Encode(in); err != nil { + return marshalWithStdlibJSONEncoder() + } + + // Do not include the newline character added by the vimtype JSON encoder. + return strings.TrimSuffix(w.String(), "\n") +} + func init() { // Known 6.5 issue where this event type is sent even though it is internal. // This workaround allows us to unmarshal and avoid NPEs. diff --git a/vendor/modules.txt b/vendor/modules.txt index a4480d84..fc24c5ed 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -208,7 +208,7 @@ github.com/russross/blackfriday/v2 # github.com/urfave/cli/v2 v2.27.4 ## explicit; go 1.18 github.com/urfave/cli/v2 -# github.com/vmware/govmomi v0.42.0 +# github.com/vmware/govmomi v0.43.0 ## explicit; go 1.21 github.com/vmware/govmomi github.com/vmware/govmomi/find @@ -263,7 +263,7 @@ golang.org/x/net/idna ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/unix -# golang.org/x/text v0.17.0 +# golang.org/x/text v0.18.0 ## explicit; go 1.18 golang.org/x/text/encoding golang.org/x/text/encoding/charmap