Skip to content

Commit 76b71cf

Browse files
committed
ignore when the field has schemaless marker
Signed-off-by: sivchari <shibuuuu5@gmail.com>
1 parent 6469492 commit 76b71cf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/analysis/helpers/inspector/inspector.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"sigs.k8s.io/kube-api-linter/pkg/analysis/helpers/extractjsontags"
2525
"sigs.k8s.io/kube-api-linter/pkg/analysis/helpers/markers"
2626
"sigs.k8s.io/kube-api-linter/pkg/analysis/utils"
27+
markersconsts "sigs.k8s.io/kube-api-linter/pkg/markers"
2728
)
2829

2930
// Inspector is an interface that allows for the inspection of fields in structs.
@@ -105,6 +106,14 @@ func (i *inspector) InspectFields(inspectField func(field *ast.Field, stack []as
105106
return false
106107
}
107108

109+
markerSet := i.markers.FieldMarkers(field)
110+
111+
schemalessMarker := markerSet.Get(markersconsts.SchemaLessMarker)
112+
if len(schemalessMarker) > 0 {
113+
// If the field is marked as schemaless, we don't need to inspect it.
114+
return false
115+
}
116+
108117
defer func() {
109118
if r := recover(); r != nil {
110119
// If the inspectField function panics, we recover and log information that will help identify the issue.

pkg/markers/markers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,8 @@ const (
164164
// K8sRequiredMarker is the marker that indicates that a field is required in k8s declarative validation.
165165
K8sRequiredMarker = "k8s:required"
166166
)
167+
168+
const (
169+
// SchemaLessMarker is the marker that indicates that a struct is schemaless.
170+
SchemaLessMarker = "kubebuilder:validation:Schemaless"
171+
)

0 commit comments

Comments
 (0)