Skip to content

Commit fec135b

Browse files
Merge pull request #107 from carlory/webhook
fix wrong field path in the openmodel webhook
2 parents 9c77c38 + e7717f7 commit fec135b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/webhook/openmodel_webhook.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,24 @@ func (w *OpenModelWebhook) ValidateDelete(ctx context.Context, obj runtime.Objec
8989
// /mnt/models/<model-namespace>/ is allowed.
9090
func (w *OpenModelWebhook) generateValidate(obj runtime.Object) field.ErrorList {
9191
model := obj.(*coreapi.OpenModel)
92-
dataSourcePath := field.NewPath("spec", "dataSource")
92+
sourcePath := field.NewPath("spec", "source")
9393

9494
var allErrs field.ErrorList
9595
if model.Spec.Source.ModelHub == nil && model.Spec.Source.URI == nil {
96-
allErrs = append(allErrs, field.Forbidden(dataSourcePath, "data source can't be all null"))
96+
allErrs = append(allErrs, field.Forbidden(sourcePath, "Source can't be all null"))
9797
}
9898

9999
if model.Spec.Source.URI != nil {
100100
if protocol, address, err := util.ParseURI(string(*model.Spec.Source.URI)); err != nil {
101-
allErrs = append(allErrs, field.Invalid(dataSourcePath.Child("uri"), *model.Spec.Source.URI, "URI with wrong format"))
101+
allErrs = append(allErrs, field.Invalid(sourcePath.Child("uri"), *model.Spec.Source.URI, "URI with wrong format"))
102102
} else {
103103
if _, ok := SUPPORTED_OBJ_STORES[protocol]; !ok {
104-
allErrs = append(allErrs, field.Invalid(dataSourcePath.Child("uri"), *model.Spec.Source.URI, "URI with unsupported protocol"))
104+
allErrs = append(allErrs, field.Invalid(sourcePath.Child("uri"), *model.Spec.Source.URI, "URI with unsupported protocol"))
105105
} else {
106106
switch protocol {
107107
case modelSource.OSS:
108108
if _, _, _, err := util.ParseOSS(address); err != nil {
109-
allErrs = append(allErrs, field.Invalid(dataSourcePath.Child("uri"), *model.Spec.Source.URI, "URI with wrong address"))
109+
allErrs = append(allErrs, field.Invalid(sourcePath.Child("uri"), *model.Spec.Source.URI, "URI with wrong address"))
110110
}
111111
}
112112
}
@@ -115,7 +115,7 @@ func (w *OpenModelWebhook) generateValidate(obj runtime.Object) field.ErrorList
115115

116116
if model.Spec.Source.ModelHub != nil {
117117
if model.Spec.Source.ModelHub.Filename != nil && model.Spec.Source.ModelHub.Name != nil && *model.Spec.Source.ModelHub.Name == coreapi.MODEL_SCOPE {
118-
allErrs = append(allErrs, field.Invalid(dataSourcePath.Child("modelHub.filename"), *model.Spec.Source.ModelHub.Filename, "Filename can only set once modeHub is Huggingface"))
118+
allErrs = append(allErrs, field.Invalid(sourcePath.Child("modelHub.filename"), *model.Spec.Source.ModelHub.Filename, "Filename can only set once modeHub is Huggingface"))
119119
}
120120
}
121121
return allErrs

0 commit comments

Comments
 (0)