Skip to content

Commit 15757ba

Browse files
authored
Merge pull request #1470 from brito-rafa/brito-rafa/brito-rafa/kubebuilder-markers-for-sysprep
🌱 Enforce non-empty validation to sysprep fullname and orgname
2 parents 8a25d31 + f75f2f8 commit 15757ba

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

api/v1alpha5/sysprep/sysprep.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,15 @@ type LicenseFilePrintData struct {
223223
// personal data pertaining to the owner of the virtual machine.
224224
type UserData struct {
225225

226+
// +required
227+
// +kubebuilder:validation:MinLength=1
228+
226229
// FullName is the user's full name.
227230
FullName string `json:"fullName"`
228231

232+
// +required
233+
// +kubebuilder:validation:MinLength=1
234+
229235
// OrgName is the name of the user's organization.
230236
OrgName string `json:"orgName"`
231237

config/crd/bases/vmoperator.vmware.com_virtualmachinereplicasets.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6058,10 +6058,12 @@ spec:
60586058
properties:
60596059
fullName:
60606060
description: FullName is the user's full name.
6061+
minLength: 1
60616062
type: string
60626063
orgName:
60636064
description: OrgName is the name of the user's
60646065
organization.
6066+
minLength: 1
60656067
type: string
60666068
productID:
60676069
description: |-

config/crd/bases/vmoperator.vmware.com_virtualmachines.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10752,9 +10752,11 @@ spec:
1075210752
properties:
1075310753
fullName:
1075410754
description: FullName is the user's full name.
10755+
minLength: 1
1075510756
type: string
1075610757
orgName:
1075710758
description: OrgName is the name of the user's organization.
10759+
minLength: 1
1075810760
type: string
1075910761
productID:
1076010762
description: |-

pkg/providers/vsphere/vmlifecycle/bootstrap_sysprep.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,14 @@ func convertTo(
129129
}
130130

131131
sysprepCustomization.UserData = vimtypes.CustomizationUserData{
132-
// This is a mandatory field
132+
// These are mandatory fields
133+
FullName: from.UserData.FullName,
134+
OrgName: from.UserData.OrgName,
133135
ComputerName: &vimtypes.CustomizationFixedName{
134136
Name: bsArgs.HostName,
135137
},
136138
}
137-
sysprepCustomization.UserData.FullName = from.UserData.FullName
138-
sysprepCustomization.UserData.OrgName = from.UserData.OrgName
139+
139140
// In the case of a VMI with volume license key, this might not be set.
140141
// Hence, add a check to see if the productID is set to empty.
141142
if bootstrapData.Sysprep != nil && bootstrapData.Sysprep.ProductID != "" {

0 commit comments

Comments
 (0)