|
1 | 1 | #!/usr/bin/perl -w |
2 | 2 | # |
3 | | -# Script to generate module.yaml from module-template.yaml |
4 | | -# by adding autogenerated semconv mount entries. |
| 3 | +# Script to generate module.yaml from module-template.yaml by adding |
| 4 | +# autogenerated semconv mount entries. The entries are generated from the list |
| 5 | +# of README.md files in the semconv submodule. |
5 | 6 | # |
6 | | -# Reads from: $MODULE_CONFIG_TEMPLATE (version-controlled template) |
7 | | -# Writes to: $MODULE_CONFIG_YAML (generated, gitignored) |
| 7 | +# Note that this script might be called in situations where some but not all |
| 8 | +# content-modules have been initialized. If the semconv submodule is not |
| 9 | +# git-submodule initialized, the script will warn and exit. |
| 10 | +# |
| 11 | +# Reads from: $MODULE_CONFIG_TEMPLATE (version-controlled template) Writes to: |
| 12 | +# $MODULE_CONFIG_YAML (generated, gitignored) |
8 | 13 |
|
9 | 14 | use strict; |
10 | 15 | use warnings; |
|
25 | 30 | my $END_MARKER = markerFor("above"); |
26 | 31 |
|
27 | 32 | sub main() { |
| 33 | + if (! -e $SEMCONV_DIR) { |
| 34 | + # The directory should be present even if the submodule isn't initialized. |
| 35 | + print STDERR "ERROR: submodule directory not found: $SEMCONV_DIR\n"; |
| 36 | + exit 1; |
| 37 | + } |
| 38 | + |
| 39 | + if (! -e "$SEMCONV_DIR/.git") { |
| 40 | + print STDERR |
| 41 | + "WARNING: submodule not initialized, '.git' directory not found in $SEMCONV_DIR\n" . |
| 42 | + " Skipping semconv mount config generation.\n" . |
| 43 | + " Run 'npm run get:submodule' to initialize.\n"; |
| 44 | + exit 0; |
| 45 | + } else { |
| 46 | + print STDERR "Submodule found and initialized: $SEMCONV_DIR\n"; |
| 47 | + } |
| 48 | + |
| 49 | + if (! -e $SEMCONV_DOCS_DIR) { |
| 50 | + print STDERR "ERROR: directory '$SEMCONV_DOCS_DIR' expected but not found.\n"; |
| 51 | + exit 1; |
| 52 | + } |
| 53 | + |
28 | 54 | # Find all README.md by running system `find`. Must be in |
29 | 55 | # $SEMCONV_DIR for find to generate the correct relative paths |
30 | 56 | my $readme_files = `cd $SEMCONV_DIR && find docs -name "README.md" | sort`; |
|
0 commit comments