Skip to content

Commit cdeec0c

Browse files
committed
Allow non user-configurable properties in VM deployment
Currently, VM operator ignores any vApp properties that are not user configurable when patching with values specified in the bootstrap resources (VM metadata ConfigMap/Secret). There are some valid use-cases where users might want to patch hidden properties defined in an image. This change fixes this behavior. Fixes vmware-tanzu#181.
1 parent a95f788 commit cdeec0c

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

pkg/vmprovider/providers/vsphere/session/session_util.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ func MergeExtraConfig(extraConfig []vimTypes.BaseOptionValue, newMap map[string]
4949
func GetMergedvAppConfigSpec(inProps map[string]string, vmProps []vimTypes.VAppPropertyInfo) *vimTypes.VmConfigSpec {
5050
outProps := make([]vimTypes.VAppPropertySpec, 0)
5151

52+
// Update any vApp properties if they have been specified in VM metadata.
5253
for _, vmProp := range vmProps {
53-
if vmProp.UserConfigurable == nil || !*vmProp.UserConfigurable {
54-
continue
55-
}
56-
5754
inPropValue, found := inProps[vmProp.Id]
5855
if !found || vmProp.Value == inPropValue {
5956
continue

pkg/vmprovider/providers/vsphere/session/session_util_test.go

+5-13
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,16 @@ var _ = Describe("Test Session Utils", func() {
4141
[]vimTypes.VAppPropertyInfo{},
4242
nil,
4343
),
44-
Entry("return nil for non UserConfigurable vm props",
45-
map[string]string{
46-
"one-id": "one-override-value",
47-
"two-id": "two-override-value",
48-
},
49-
[]vimTypes.VAppPropertyInfo{
50-
{Key: 1, Id: "one-id", Value: "one-value"},
51-
{Key: 2, Id: "two-id", Value: "two-value", UserConfigurable: &falseVar},
52-
},
53-
nil,
54-
),
55-
Entry("return nil for UserConfigurable vm props but no input props",
44+
Entry("return nil for vm props but no input props",
5645
map[string]string{},
5746
[]vimTypes.VAppPropertyInfo{
5847
{Key: 1, Id: "one-id", Value: "one-value"},
5948
{Key: 2, Id: "two-id", Value: "two-value", UserConfigurable: &trueVar},
49+
{Key: 2, Id: "three-id", Value: "three-value", UserConfigurable: &falseVar},
6050
},
6151
nil,
6252
),
63-
Entry("return valid vAppConfigSpec for setting mixed UserConfigurable props",
53+
Entry("return valid vAppConfigSpec for setting mixed props",
6454
map[string]string{
6555
"one-id": "one-override-value",
6656
"two-id": "two-override-value",
@@ -73,7 +63,9 @@ var _ = Describe("Test Session Utils", func() {
7363
},
7464
&vimTypes.VmConfigSpec{
7565
Property: []vimTypes.VAppPropertySpec{
66+
{Info: &vimTypes.VAppPropertyInfo{Key: 1, Id: "one-id", Value: "one-override-value"}},
7667
{Info: &vimTypes.VAppPropertyInfo{Key: 2, Id: "two-id", Value: "two-override-value"}},
68+
{Info: &vimTypes.VAppPropertyInfo{Key: 3, Id: "three-id", Value: "three-override-value"}},
7769
},
7870
},
7971
),

0 commit comments

Comments
 (0)