Skip to content

Commit e48879c

Browse files
Liudmila Molkovalmolkova
authored andcommitted
generate resolved schema and diff for stable and dev versions
1 parent 57af184 commit e48879c

File tree

5 files changed

+104
-0
lines changed

5 files changed

+104
-0
lines changed

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,42 @@ areas-table-generation:
343343
.PHONY: areas-table-check
344344
areas-table-check:
345345
docker run --rm -v ${PWD}:/repo -w /repo python:3-alpine python internal/tools/scripts/update-areas-table.py --install --check;
346+
347+
SCHEMAS_PATH = $(PWD)/schemas
348+
.PHONY: generate-schema-v2-dev
349+
generate-schema-v2-dev:
350+
$(DOCKER_RUN) --rm \
351+
$(DOCKER_USER_IS_HOST_USER_ARG) \
352+
--mount 'type=bind,source=$(PWD)/internal/tools/scripts,target=/home/weaver/templates,readonly' \
353+
--mount 'type=bind,source=$(PWD)/model,target=/home/weaver/source,readonly' \
354+
--mount 'type=bind,source=$(SCHEMAS_PATH),target=/home/weaver/target' \
355+
$(WEAVER_CONTAINER) registry generate \
356+
--registry=/home/weaver/source \
357+
--templates=/home/weaver/templates \
358+
--param next_version=$(NEXT_SEMCONV_VERSION) \
359+
--config=/home/weaver/templates/registry/schema-v2-weaver.yaml \
360+
. \
361+
/home/weaver/target
362+
363+
# TODO: diff does not have indication about stability, so we can only generate
364+
# dev diff
365+
$(DOCKER_RUN) --rm \
366+
$(DOCKER_USER_IS_HOST_USER_ARG) \
367+
--mount 'type=bind,source=$(PWD)/internal/tools/scripts,target=/home/weaver/templates,readonly' \
368+
--mount 'type=bind,source=$(PWD)/model,target=/home/weaver/source,readonly' \
369+
--mount 'type=bind,source=$(SCHEMAS_PATH),target=/home/weaver/target' \
370+
$(WEAVER_CONTAINER) registry diff \
371+
--registry=/home/weaver/source \
372+
--baseline-registry=https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/v$(LATEST_RELEASED_SEMCONV_VERSION).zip[model] \
373+
--diff-format yaml \
374+
--diff-template /home/weaver/templates/schema-v2-diff \
375+
--output /home/weaver/target
376+
377+
# TODO: these commands should not be necessary:
378+
$(SED) -i 's/semconv_version: unversioned/semconv_version: $(NEXT_SEMCONV_VERSION)/' $(SCHEMAS_PATH)/next-version-dev/schema-diff.yaml
379+
380+
rm -rf $(SCHEMAS_PATH)/${NEXT_SEMCONV_VERSION}-dev
381+
mv $(SCHEMAS_PATH)/next-version-dev $(SCHEMAS_PATH)/${NEXT_SEMCONV_VERSION}-dev
382+
383+
rm -rf $(SCHEMAS_PATH)/${NEXT_SEMCONV_VERSION}
384+
mv $(SCHEMAS_PATH)/next-version $(SCHEMAS_PATH)/${NEXT_SEMCONV_VERSION}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
templates:
2+
- pattern: schema.j2
3+
filter: .
4+
application_mode: single
5+
file_name: next-version-dev/schema.yaml # how to parametrize this?
6+
- pattern: schema.j2
7+
filter: >
8+
def filter_members:
9+
if type == "array" then
10+
map(select(.stability == "stable") | filter_members)
11+
elif type == "object" then
12+
if has("members") and (.members | type == "array") then
13+
.members |= filter_members
14+
else
15+
.
16+
end
17+
else
18+
.
19+
end;
20+
21+
.groups |= map(
22+
select(
23+
(.stability == "stable") or
24+
(
25+
.type == "attribute_group" and
26+
(.attributes | map(select(.stability == "stable")) | length > 0)
27+
)
28+
)
29+
|
30+
if .attributes then
31+
.attributes |= map(
32+
select(.stability == "stable")
33+
|
34+
if (.type | type == "object") and (.type.members) then
35+
.type |= filter_members
36+
else
37+
.
38+
end
39+
)
40+
else
41+
.
42+
end
43+
)
44+
application_mode: single
45+
file_name: next-version/schema.yaml
46+
47+
whitespace_control:
48+
trim_blocks: true
49+
lstrip_blocks: true
50+
keep_trailing_newline: true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# TODO: toyaml generates some scrabbled output
2+
{#{{ ctx | toyaml }}#}
3+
4+
{{ ctx | tojson(indent=true) }}
5+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ ctx | toyaml }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
templates:
2+
- pattern: schema-diff.j2
3+
filter: .
4+
application_mode: single
5+
file_name: next-version-dev/schema-diff.yaml # how to parametrize this?
6+
whitespace_control:
7+
trim_blocks: true
8+
lstrip_blocks: true
9+
keep_trailing_newline: true

0 commit comments

Comments
 (0)