|
1 | 1 | package v3 |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "slices" |
4 | 5 | "strings" |
5 | 6 |
|
6 | 7 | sharedValidation "github.com/pdok/smooth-operator/pkg/validation" |
@@ -69,4 +70,64 @@ func ValidateWFS(wfs *WFS, warnings *[]string, allErrs *field.ErrorList) { |
69 | 70 |
|
70 | 71 | podSpecPatch := wfs.Spec.PodSpecPatch |
71 | 72 | ValidateEphemeralStorage(podSpecPatch, allErrs) |
| 73 | + |
| 74 | + ValidateFeatureTypes(wfs, warnings, allErrs) |
| 75 | +} |
| 76 | + |
| 77 | +func ValidateFeatureTypes(wfs *WFS, warnings *[]string, allErrs *field.ErrorList) { |
| 78 | + names := []string{} |
| 79 | + path := field.NewPath("spec").Child("service").Child("featureTypes") |
| 80 | + for index, featureType := range wfs.Spec.Service.FeatureTypes { |
| 81 | + if slices.Contains(names, featureType.Name) { |
| 82 | + *allErrs = append(*allErrs, field.Duplicate( |
| 83 | + path.Index(index).Child("name"), |
| 84 | + featureType.Name, |
| 85 | + )) |
| 86 | + } else { |
| 87 | + names = append(names, featureType.Name) |
| 88 | + } |
| 89 | + |
| 90 | + if wfs.Spec.Service.Mapfile != nil && featureType.Bbox != nil && featureType.Bbox.DefaultCRS != nil { |
| 91 | + sharedValidation.AddWarning( |
| 92 | + warnings, |
| 93 | + *path.Index(index).Child("bbox").Child("defaultCrs"), |
| 94 | + "is not used when service.mapfile is configured", |
| 95 | + wfs.GroupVersionKind(), |
| 96 | + wfs.GetName(), |
| 97 | + ) |
| 98 | + } |
| 99 | + |
| 100 | + if tif := featureType.Data.TIF; tif != nil { |
| 101 | + if tif.Resample != "NEAREST" { |
| 102 | + sharedValidation.AddWarning( |
| 103 | + warnings, |
| 104 | + *path.Index(index).Child("data").Child("tif").Child("resample"), |
| 105 | + "is not used when service.mapfile is configured", |
| 106 | + wfs.GroupVersionKind(), |
| 107 | + wfs.GetName(), |
| 108 | + ) |
| 109 | + } |
| 110 | + |
| 111 | + if tif.Offsite != nil { |
| 112 | + sharedValidation.AddWarning( |
| 113 | + warnings, |
| 114 | + *path.Index(index).Child("data").Child("tif").Child("offsite"), |
| 115 | + "is not used when service.mapfile is configured", |
| 116 | + wfs.GroupVersionKind(), |
| 117 | + wfs.GetName(), |
| 118 | + ) |
| 119 | + } |
| 120 | + |
| 121 | + if tif.GetFeatureInfoIncludesClass { |
| 122 | + sharedValidation.AddWarning( |
| 123 | + warnings, |
| 124 | + *path.Index(index).Child("data").Child("tif").Child("getFeatureInfoIncludesClass"), |
| 125 | + "is not used when service.mapfile is configured", |
| 126 | + wfs.GroupVersionKind(), |
| 127 | + wfs.GetName(), |
| 128 | + ) |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + } |
72 | 133 | } |
0 commit comments