Skip to content

Commit 29a2235

Browse files
fix checks
1 parent bf87b31 commit 29a2235

File tree

3 files changed

+38
-26
lines changed

3 files changed

+38
-26
lines changed

cmd/schemagen/internal/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func ReadConfig() (*Config, error) {
103103
switch class {
104104
case "receiver", "processor", "exporter", "connector", "extension":
105105
mode = Component
106-
case "pkg":
106+
case "", "pkg":
107107
mode = Package
108108
default:
109109
return nil, fmt.Errorf("schema generation for class '%s' is not supported", md.Status.Class)

cmd/schemagen/internal/parser.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,5 +433,7 @@ func (p *Parser) parseOptional(indexExpr *ast.IndexExpr) (SchemaElement, error)
433433
return element, err
434434
}
435435

436-
return nil, fmt.Errorf("unrecognized generic type: %s", wrapperTypeName)
436+
fmt.Printf("Warning: unrecognized generic type: %s\n", wrapperTypeName)
437+
438+
return nil, nil
437439
}

cmd/schemagen/run_schemagen_dir.sh

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@
55

66
# 1. Parse CLI arguments
77
usage() {
8-
echo "Usage: $0 [-v] [-i dir1,dir2,...] <target_directory>"
8+
echo "Usage: $0 [-v] [-m] [-i dir1,dir2,...] <target_directory>"
99
echo " -i Comma-separated directory basenames to ignore (recursion prunes them)"
10-
echo " -v Recursively process directories containing *.schema.yaml files"
10+
echo " -m After successful run also run schemagen in internal/metadata"
11+
echo " -v Validation mode - process only directories containing *.schema.yaml files"
1112
}
1213

1314
IGNORED_DIRS=()
1415
RECURSIVE_MODE=false
15-
while getopts ":i:hv" opt; do
16+
METADATA_MODE=false
17+
while getopts ":i:hmv" opt; do
1618
case $opt in
1719
i)
1820
if [ -n "$OPTARG" ]; then
1921
IFS=',' read -r -a tmp <<< "$OPTARG"
2022
IGNORED_DIRS+=("${tmp[@]}")
2123
fi
2224
;;
25+
m)
26+
METADATA_MODE=true
27+
;;
2328
h)
2429
usage
2530
exit 0
@@ -47,6 +52,11 @@ FAILED_DIRS=() # Array to keep track of failures
4752
EXEC_DIR=$(pwd)
4853
dirs_to_process=()
4954

55+
run_schemagen_for_dir() {
56+
local dir_path=$1
57+
(cd "$EXEC_DIR" && make schemagen SRC="$dir_path")
58+
}
59+
5060
dir_already_scheduled() {
5161
local candidate=$1
5262
for existing_dir in "${dirs_to_process[@]}"; do
@@ -132,35 +142,35 @@ for dir in "${dirs_to_process[@]}"; do
132142

133143
echo "Run on: $dir_display"
134144

135-
if ! (cd "$dir" && "$EXEC_DIR/.tools/schemagen"); then
145+
if ! run_schemagen_for_dir "$dir"; then
136146
FAILED_DIRS+=("$dir_display")
137147
echo "Done with $dir_display"
138148
echo "------------------------------------------"
139149
continue
140150
fi
141151

142152
echo "Done with $dir_display"
143-
144-
145-
metadata_dir="$dir/internal/metadata"
146-
if [ -f "$metadata_dir/generated_config.go" ]; then
147-
metadata_basename=$(basename "$metadata_dir")
148-
skip_metadata=false
149-
for ignored in "${IGNORED_DIRS[@]}"; do
150-
if [[ "$metadata_basename" == "$ignored" ]]; then
151-
skip_metadata=true
152-
break
153-
fi
154-
done
155-
metadata_display="$dir_display/internal/metadata"
156-
if [ "$skip_metadata" = true ]; then
157-
echo "Skipping $metadata_display (in ignore list)"
158-
else
159-
echo "Run on: $metadata_display"
160-
if ! (cd "$metadata_dir" && "$EXEC_DIR/.tools/schemagen"); then
161-
FAILED_DIRS+=("$metadata_display")
153+
if [ "$METADATA_MODE" = true ]; then
154+
metadata_dir="$dir/internal/metadata"
155+
if [ -f "$metadata_dir/generated_config.go" ]; then
156+
metadata_basename=$(basename "$metadata_dir")
157+
skip_metadata=false
158+
for ignored in "${IGNORED_DIRS[@]}"; do
159+
if [[ "$metadata_basename" == "$ignored" ]]; then
160+
skip_metadata=true
161+
break
162+
fi
163+
done
164+
metadata_display="$dir_display/internal/metadata"
165+
if [ "$skip_metadata" = true ]; then
166+
echo "Skipping $metadata_display (in ignore list)"
167+
else
168+
echo "Run on: $metadata_display"
169+
if ! run_schemagen_for_dir "$metadata_dir"; then
170+
FAILED_DIRS+=("$metadata_display")
171+
fi
172+
echo "Done with $metadata_display"
162173
fi
163-
echo "Done with $metadata_display"
164174
fi
165175
fi
166176

0 commit comments

Comments
 (0)