Skip to content

Commit a64782a

Browse files
Adding hostpath check in the webhook
Signed-off-by: Vishesh Tanksale <vtanksale@nvidia.com>
1 parent 57015c3 commit a64782a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

internal/webhook/apps/v1alpha1/nimservice_webhook_validation_helper.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ func validateServiceStorageConfiguration(storage *appsv1alpha1.NIMServiceStorage
182182
// Check if EmptyDir is defined (non-empty)
183183
emptyDirDefined := storage.EmptyDir != nil
184184

185+
// Check if HostPath is defined (non-empty)
186+
hostPathDefined := storage.HostPath != nil && *storage.HostPath != ""
187+
185188
// Count how many are defined
186189
definedCount := 0
187190
if nimCacheDefined {
@@ -193,12 +196,15 @@ func validateServiceStorageConfiguration(storage *appsv1alpha1.NIMServiceStorage
193196
if emptyDirDefined {
194197
definedCount++
195198
}
199+
if hostPathDefined {
200+
definedCount++
201+
}
196202

197203
// Ensure only one of nimCache, PVC, or EmptyDir is defined
198204
if definedCount == 0 {
199-
errList = append(errList, field.Required(fldPath, fmt.Sprintf("one of %s, %s or %s, must be defined", fldPath.Child("nimCache"), fldPath.Child("pvc"), fldPath.Child("emptyDir"))))
205+
errList = append(errList, field.Required(fldPath, fmt.Sprintf("one of %s, %s, %s or %s, must be defined", fldPath.Child("nimCache"), fldPath.Child("pvc"), fldPath.Child("emptyDir"), fldPath.Child("hostPath"))))
200206
} else if definedCount > 1 {
201-
errList = append(errList, field.Invalid(fldPath, "multiple storage sources defined", fmt.Sprintf("only one of %s, %s or %s must be defined", fldPath.Child("nimCache"), fldPath.Child("pvc"), fldPath.Child("emptyDir"))))
207+
errList = append(errList, field.Invalid(fldPath, "multiple storage sources defined", fmt.Sprintf("only one of %s, %s, %s or %s must be defined", fldPath.Child("nimCache"), fldPath.Child("pvc"), fldPath.Child("emptyDir"), fldPath.Child("hostPath"))))
202208
}
203209

204210
// If NIMCache is non-nil, NIMCache.Name must not be empty

0 commit comments

Comments
 (0)