|
17 | 17 | my $semconvSpecRepoUrl = 'https://github.com/open-telemetry/semantic-conventions';
|
18 | 18 | my $semConvRef = "$otelSpecRepoUrl/blob/main/semantic_conventions/README.md";
|
19 | 19 | my $specBasePath = '/docs/specs';
|
20 |
| -my %versions = qw( |
21 |
| - spec: 1.41.0 |
22 |
| - otlp: 1.5.0 |
23 |
| - semconv: 1.29.0 |
24 |
| -); |
25 |
| -my %versFromRepo = %versions; # Use declared versions a defaults |
26 |
| -my $otelSpecVers = $versions{'spec:'}; |
27 |
| -my $otlpSpecVers = $versions{'otlp:'}; |
28 |
| -my $semconvVers = $versions{'semconv:'}; |
29 | 20 | my %patchMsgCount;
|
30 | 21 | my $lineNum;
|
31 | 22 |
|
| 23 | +my %versionsRaw = # Keyname must end with colons because the auto-version update script expects one |
| 24 | + qw( |
| 25 | + spec: 1.41.0 |
| 26 | + otlp: 1.5.0 |
| 27 | + semconv: 1.29.0 |
| 28 | + ); |
| 29 | +# Versions map without the colon in the keys |
| 30 | +my %versions = map { s/://r => $versionsRaw{$_} } keys %versionsRaw; |
| 31 | +# Shorthands |
| 32 | +my $otelSpecVers = $versions{'spec'}; |
| 33 | +my $otlpSpecVers = $versions{'otlp'}; |
| 34 | +my $semconvVers = $versions{'semconv'}; |
| 35 | + |
| 36 | +my %versFromSubmod = %versions; # Actual version of submodules. Updated by getVersFromSubmodule(). |
| 37 | + |
32 | 38 | sub printTitleAndFrontMatter() {
|
33 | 39 | print "---\n";
|
34 | 40 | if ($title eq 'OpenTelemetry Specification') {
|
|
70 | 76 | sub applyPatchOrPrintMsgIf($$$) {
|
71 | 77 | # Returns truthy if patch should be applied, otherwise prints message (once) as to why not.
|
72 | 78 |
|
73 |
| - my ($patchID, $versKey_, $targetVers) = @_; |
74 |
| - my $versKey = $versKey_ . ':'; |
| 79 | + my ($patchID, $specName, $targetVers) = @_; |
75 | 80 | my $vers;
|
| 81 | + my $key = $specName . $patchID; |
76 | 82 |
|
77 |
| - return 0 if $patchMsgCount{$patchID}; |
| 83 | + return 0 if $patchMsgCount{$key}; |
78 | 84 |
|
79 |
| - if (($vers = $versions{$versKey}) ne $targetVers) { |
80 |
| - print STDOUT "INFO: remove obsolete patch '$patchID' now that spec '$versKey_' is at v$vers, not v$targetVers - $0\n"; |
81 |
| - } elsif (($vers = $versFromRepo{$versKey}) ne $targetVers) { |
82 |
| - print STDOUT "INFO [$patchID]: skipping patch '$patchID' since spec '$versKey_' submodule is at v$vers not v$targetVers - $0\n"; |
| 85 | + if (($vers = $versions{$specName}) ne $targetVers) { |
| 86 | + print STDOUT "INFO: remove obsolete patch '$patchID' now that spec '$specName' is at v$vers, not v$targetVers - $0\n"; |
| 87 | + } elsif (($vers = $versFromSubmod{$specName}) ne $targetVers) { |
| 88 | + print STDOUT "INFO [$patchID]: skipping patch '$patchID' since spec '$specName' submodule is at v$vers not v$targetVers - $0\n"; |
83 | 89 | } else {
|
84 | 90 | return 'Apply the patch';
|
85 | 91 | }
|
86 |
| - $patchMsgCount{$patchID}++; |
| 92 | + $patchMsgCount{$key}++; |
87 | 93 | return 0;
|
88 | 94 | }
|
89 | 95 |
|
|
95 | 101 | s|$semconv_attr_naming|$1/attribute-naming/|g if /$semconv_attr_naming/;
|
96 | 102 | }
|
97 | 103 |
|
98 |
| -sub getVersFromRepo() { |
99 |
| - my $vers = qx( |
100 |
| - cd content-modules/semantic-conventions; |
101 |
| - git describe --tags 2>&1; |
| 104 | +sub patchEventAliases() { |
| 105 | + return unless $ARGV =~ /^tmp\/otel\/specification\/logs\// |
| 106 | + && applyPatchOrPrintMsgIf('2025-01-23-event-aliases', 'spec', '1.41.0'); |
| 107 | + |
| 108 | + my $aliases = '^( - )(event-(api|sdk))$'; |
| 109 | + s|$aliases|$1./$2|g if /$aliases/; |
| 110 | +} |
| 111 | + |
| 112 | +sub patchSemConvAlias() { |
| 113 | + return unless $ARGV =~ /^tmp\/semconv\/docs\/general\// |
| 114 | + && applyPatchOrPrintMsgIf('2025-01-23-general-aliases', 'semconv', '1.29.0'); |
| 115 | + |
| 116 | + my $aliases = '\[docs/specs/semconv/general/(trace-general)\]'; |
| 117 | + s|$aliases|[$1]|g if /$aliases/; |
| 118 | +} |
| 119 | + |
| 120 | +sub getVersFromSubmodule() { |
| 121 | + my %repoNames = qw( |
| 122 | + otlp opentelemetry-proto |
| 123 | + semconv semantic-conventions |
| 124 | + spec opentelemetry-specification |
102 | 125 | );
|
103 |
| - chomp($vers); |
104 | 126 |
|
105 |
| - if ($?) { |
106 |
| - warn "WARNING: semconv repo: call to 'git describe' failed: '$vers'"; |
107 |
| - } else { |
108 |
| - $vers =~ s/v//; |
109 |
| - $versFromRepo{'semconv:'} = $vers; |
| 127 | + foreach my $spec (keys %repoNames) { |
| 128 | + my $directory = $repoNames{$spec}; |
| 129 | + my $vers = qx( |
| 130 | + cd content-modules/$directory; |
| 131 | + git describe --tags 2>&1; |
| 132 | + ); |
| 133 | + chomp($vers); |
| 134 | + |
| 135 | + if ($?) { |
| 136 | + warn "WARNING: submodule '$spec': call to 'git describe' failed: '$vers'"; |
| 137 | + } else { |
| 138 | + $vers =~ s/v//; |
| 139 | + $versFromSubmod{$spec} = $vers; |
| 140 | + } |
110 | 141 | }
|
111 | 142 | }
|
112 | 143 |
|
113 | 144 | # main
|
114 | 145 |
|
115 |
| -getVersFromRepo(); |
| 146 | +getVersFromSubmodule(); |
116 | 147 |
|
117 | 148 | while(<>) {
|
118 | 149 | $lineNum++;
|
|
127 | 158 | while(<>) {
|
128 | 159 | $lineNum++;
|
129 | 160 | last if /^-?-->/;
|
130 |
| - patchAttrNaming(); # TEMPORARY patch |
| 161 | + patchAttrNaming(); |
| 162 | + patchEventAliases(); |
| 163 | + patchSemConvAlias(); |
131 | 164 | $frontMatterFromFile .= $_;
|
132 | 165 | }
|
133 | 166 | next;
|
|
0 commit comments