Skip to content

Commit 09486d4

Browse files
committed
fix review findings
Signed-off-by: sivchari <shibuuuu5@gmail.com>
1 parent c9f9f26 commit 09486d4

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

pkg/analysis/helpers/inspector/inspector.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ func (i *inspector) InspectFields(inspectField func(field *ast.Field, stack []as
108108

109109
markerSet := i.markers.FieldMarkers(field)
110110

111-
schemalessMarker := markerSet.Get(markersconsts.SchemaLessMarker)
112-
if len(schemalessMarker) > 0 {
111+
if isSchemalessType(markerSet) {
113112
// If the field is marked as schemaless, we don't need to inspect it.
114113
return false
115114
}
@@ -172,6 +171,12 @@ func isItemsType(structType *ast.StructType) bool {
172171
return true
173172
}
174173

174+
func isSchemalessType(markerSet markers.MarkerSet) bool {
175+
// Check if the field is marked as schemaless.
176+
schemalessMarker := markerSet.Get(markersconsts.KubebuilderSchemaLessMarker)
177+
return len(schemalessMarker) > 0
178+
}
179+
175180
// printDebugInfo prints debug information about the field that caused a panic during inspection.
176181
// This function is designed to allow us to help identify which fields are causing issues during inspection.
177182
func printDebugInfo(field *ast.Field) string {

pkg/markers/markers.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ const (
155155

156156
// KubebuilderListMapKeyMarker is the marker used to specify the key field for map-type lists.
157157
KubebuilderListMapKeyMarker = "listMapKey"
158+
159+
// KubebuilderSchemaLessMarker is the marker that indicates that a struct is schemaless.
160+
KubebuilderSchemaLessMarker = "kubebuilder:validation:Schemaless"
158161
)
159162

160163
const (
@@ -164,8 +167,3 @@ const (
164167
// K8sRequiredMarker is the marker that indicates that a field is required in k8s declarative validation.
165168
K8sRequiredMarker = "k8s:required"
166169
)
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)