Skip to content

Commit a7a3d58

Browse files
josefkarasekestroz
authored andcommitted
Add validation for Kind and APIVersion (openshift#152)
* Add validation for Kind and APIVersion Signed-off-by: Josef Karasek <[email protected]> * Update pkg/validation/internal/csv.go Co-authored-by: Eric Stroczynski <[email protected]> Co-authored-by: Eric Stroczynski <[email protected]> Upstream-repository: api Upstream-commit: c9b1e7ef82b8081a3eb52c48d0ca9039f2e3a27e
1 parent 2d9e1d7 commit a7a3d58

File tree

2 files changed

+28
-0
lines changed
  • staging/api/pkg/validation/internal
  • vendor/github.com/operator-framework/api/pkg/validation/internal

2 files changed

+28
-0
lines changed

staging/api/pkg/validation/internal/csv.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func validateCSV(csv *v1alpha1.ClusterServiceVersion) errors.ManifestResult {
4848
result.Add(checkFields(*csv)...)
4949
// validate case sensitive annotation names
5050
result.Add(ValidateAnnotationNames(csv.GetAnnotations(), csv.GetName())...)
51+
// validate Version and Kind
52+
result.Add(validateVersionKind(csv)...)
5153
return result
5254
}
5355

@@ -194,3 +196,15 @@ func validateInstallModes(csv *v1alpha1.ClusterServiceVersion) (errs []errors.Er
194196
}
195197
return errs
196198
}
199+
200+
// validateVersionKind checks presence of GroupVersionKind.Version and GroupVersionKind.Kind
201+
func validateVersionKind(csv *v1alpha1.ClusterServiceVersion) (errs []errors.Error) {
202+
gvk := csv.GroupVersionKind()
203+
if gvk.Version == "" {
204+
errs = append(errs, errors.ErrInvalidCSV("'apiVersion' is missing", csv.GetName()))
205+
}
206+
if gvk.Kind == "" {
207+
errs = append(errs, errors.ErrInvalidCSV("'kind' is missing", csv.GetName()))
208+
}
209+
return
210+
}

vendor/github.com/operator-framework/api/pkg/validation/internal/csv.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)