Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Allow non user-configurable properties in VM deployment #217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions pkg/vmprovider/providers/vsphere/session/session_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ func MergeExtraConfig(extraConfig []vimTypes.BaseOptionValue, newMap map[string]
func GetMergedvAppConfigSpec(inProps map[string]string, vmProps []vimTypes.VAppPropertyInfo) *vimTypes.VmConfigSpec {
outProps := make([]vimTypes.VAppPropertySpec, 0)

// Update any vApp properties if they have been specified in VM metadata.
for _, vmProp := range vmProps {
if vmProp.UserConfigurable == nil || !*vmProp.UserConfigurable {
continue
}

inPropValue, found := inProps[vmProp.Id]
if !found || vmProp.Value == inPropValue {
continue
Expand Down
18 changes: 5 additions & 13 deletions pkg/vmprovider/providers/vsphere/session/session_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,16 @@ var _ = Describe("Test Session Utils", func() {
[]vimTypes.VAppPropertyInfo{},
nil,
),
Entry("return nil for non UserConfigurable vm props",
map[string]string{
"one-id": "one-override-value",
"two-id": "two-override-value",
},
[]vimTypes.VAppPropertyInfo{
{Key: 1, Id: "one-id", Value: "one-value"},
{Key: 2, Id: "two-id", Value: "two-value", UserConfigurable: &falseVar},
},
nil,
),
Entry("return nil for UserConfigurable vm props but no input props",
Entry("return nil for vm props but no input props",
map[string]string{},
[]vimTypes.VAppPropertyInfo{
{Key: 1, Id: "one-id", Value: "one-value"},
{Key: 2, Id: "two-id", Value: "two-value", UserConfigurable: &trueVar},
{Key: 2, Id: "three-id", Value: "three-value", UserConfigurable: &falseVar},
},
nil,
),
Entry("return valid vAppConfigSpec for setting mixed UserConfigurable props",
Entry("return valid vAppConfigSpec for setting mixed props",
map[string]string{
"one-id": "one-override-value",
"two-id": "two-override-value",
Expand All @@ -73,7 +63,9 @@ var _ = Describe("Test Session Utils", func() {
},
&vimTypes.VmConfigSpec{
Property: []vimTypes.VAppPropertySpec{
{Info: &vimTypes.VAppPropertyInfo{Key: 1, Id: "one-id", Value: "one-override-value"}},
{Info: &vimTypes.VAppPropertyInfo{Key: 2, Id: "two-id", Value: "two-override-value"}},
{Info: &vimTypes.VAppPropertyInfo{Key: 3, Id: "three-id", Value: "three-override-value"}},
},
},
),
Expand Down