peak-sdk 1.6.0__py3-none-any.whl → 1.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- peak/_metadata.py +78 -58
- peak/_version.py +1 -1
- peak/callbacks.py +22 -2
- peak/cli/args.py +19 -0
- peak/cli/helpers.py +12 -8
- peak/cli/press/apps/deployments.py +72 -18
- peak/cli/press/apps/specs.py +29 -11
- peak/cli/press/blocks/deployments.py +71 -18
- peak/cli/press/blocks/specs.py +95 -35
- peak/cli/press/deployments.py +40 -1
- peak/cli/press/specs.py +2 -2
- peak/cli/resources/alerts/emails.py +4 -5
- peak/cli/resources/artifacts.py +9 -9
- peak/cli/resources/images.py +29 -18
- peak/cli/resources/services.py +6 -7
- peak/cli/resources/tenants.py +4 -2
- peak/cli/resources/users.py +3 -3
- peak/cli/resources/webapps.py +6 -6
- peak/cli/resources/workflows.py +24 -25
- peak/compression.py +28 -13
- peak/exceptions.py +15 -1
- peak/handler.py +5 -1
- peak/helpers.py +38 -0
- peak/output.py +13 -6
- peak/press/apps.py +43 -3
- peak/press/blocks.py +450 -138
- peak/press/deployments.py +25 -0
- peak/resources/images.py +309 -86
- peak/sample_yaml/press/apps/specs/create_app_spec.yaml +2 -0
- peak/sample_yaml/press/apps/specs/create_app_spec_release.yaml +2 -0
- peak/sample_yaml/press/blocks/specs/service/api/create_block_spec.yaml +102 -0
- peak/sample_yaml/press/blocks/specs/service/api/create_block_spec_release.yaml +88 -0
- peak/sample_yaml/press/blocks/specs/service/webapp/create_block_spec.yaml +103 -0
- peak/sample_yaml/press/blocks/specs/service/webapp/create_block_spec_release.yaml +89 -0
- peak/sample_yaml/press/blocks/specs/{create_block_spec.yaml → workflow/create_block_spec.yaml} +20 -1
- peak/sample_yaml/press/blocks/specs/{create_block_spec_release.yaml → workflow/create_block_spec_release.yaml} +20 -1
- peak/sample_yaml/resources/images/dockerfile/create_image.yaml +3 -0
- peak/sample_yaml/resources/images/dockerfile/create_image_version.yaml +3 -0
- peak/sample_yaml/resources/images/dockerfile/update_version.yaml +3 -0
- peak/sample_yaml/resources/images/github/create_image.yaml +3 -0
- peak/sample_yaml/resources/images/github/create_image_version.yaml +3 -0
- peak/sample_yaml/resources/images/github/update_version.yaml +3 -0
- peak/sample_yaml/resources/images/upload/create_image.yaml +3 -0
- peak/sample_yaml/resources/images/upload/create_image_version.yaml +3 -0
- peak/sample_yaml/resources/images/upload/create_or_update_image.yaml +3 -0
- peak/sample_yaml/resources/images/upload/update_version.yaml +3 -0
- peak/sample_yaml/resources/workflows/create_or_update_workflow.yaml +9 -1
- peak/sample_yaml/resources/workflows/create_workflow.yaml +9 -1
- peak/sample_yaml/resources/workflows/patch_workflow.yaml +9 -1
- peak/sample_yaml/resources/workflows/update_workflow.yaml +9 -1
- peak/session.py +1 -1
- peak/template.py +21 -2
- {peak_sdk-1.6.0.dist-info → peak_sdk-1.8.0.dist-info}/METADATA +18 -18
- {peak_sdk-1.6.0.dist-info → peak_sdk-1.8.0.dist-info}/RECORD +57 -53
- {peak_sdk-1.6.0.dist-info → peak_sdk-1.8.0.dist-info}/LICENSE +0 -0
- {peak_sdk-1.6.0.dist-info → peak_sdk-1.8.0.dist-info}/WHEEL +0 -0
- {peak_sdk-1.6.0.dist-info → peak_sdk-1.8.0.dist-info}/entry_points.txt +0 -0
peak/_metadata.py
CHANGED
@@ -36,7 +36,7 @@ def tag_parser(data: Any) -> str:
|
|
36
36
|
|
37
37
|
|
38
38
|
command_metadata: Dict[str, Any] = {
|
39
|
-
"
|
39
|
+
"images>list": {
|
40
40
|
"table_params": {
|
41
41
|
"output_keys": {
|
42
42
|
"id": {
|
@@ -73,7 +73,7 @@ command_metadata: Dict[str, Any] = {
|
|
73
73
|
"subheader_key": "imageCount",
|
74
74
|
},
|
75
75
|
},
|
76
|
-
"
|
76
|
+
"images>list-versions": {
|
77
77
|
"table_params": {
|
78
78
|
"output_keys": {
|
79
79
|
"id": {
|
@@ -104,7 +104,7 @@ command_metadata: Dict[str, Any] = {
|
|
104
104
|
"subheader_key": "versionCount",
|
105
105
|
},
|
106
106
|
},
|
107
|
-
"
|
107
|
+
"images>list-builds": {
|
108
108
|
"table_params": {
|
109
109
|
"output_keys": {
|
110
110
|
"buildId": {
|
@@ -131,7 +131,7 @@ command_metadata: Dict[str, Any] = {
|
|
131
131
|
"subheader_key": "buildCount",
|
132
132
|
},
|
133
133
|
},
|
134
|
-
"
|
134
|
+
"workflows>list": {
|
135
135
|
"table_params": {
|
136
136
|
"output_keys": {
|
137
137
|
"id": {
|
@@ -162,7 +162,7 @@ command_metadata: Dict[str, Any] = {
|
|
162
162
|
"subheader_key": "workflowsCount",
|
163
163
|
},
|
164
164
|
},
|
165
|
-
"
|
165
|
+
"workflows>list-executions": {
|
166
166
|
"table_params": {
|
167
167
|
"output_keys": {
|
168
168
|
"executionId": {
|
@@ -183,7 +183,7 @@ command_metadata: Dict[str, Any] = {
|
|
183
183
|
"subheader_key": "executionsCount",
|
184
184
|
},
|
185
185
|
},
|
186
|
-
"
|
186
|
+
"workflows>get-execution-details": {
|
187
187
|
"table_params": {
|
188
188
|
"output_keys": {
|
189
189
|
"name": {
|
@@ -214,7 +214,7 @@ command_metadata: Dict[str, Any] = {
|
|
214
214
|
"subheader_key": "status",
|
215
215
|
},
|
216
216
|
},
|
217
|
-
"
|
217
|
+
"webapps>list": {
|
218
218
|
"table_params": {
|
219
219
|
"output_keys": {
|
220
220
|
"id": {
|
@@ -242,7 +242,7 @@ command_metadata: Dict[str, Any] = {
|
|
242
242
|
"subheader_key": "webappsCount",
|
243
243
|
},
|
244
244
|
},
|
245
|
-
"
|
245
|
+
"services>list": {
|
246
246
|
"table_params": {
|
247
247
|
"output_keys": {
|
248
248
|
"id": {
|
@@ -273,7 +273,7 @@ command_metadata: Dict[str, Any] = {
|
|
273
273
|
"subheader_key": "servicesCount",
|
274
274
|
},
|
275
275
|
},
|
276
|
-
"
|
276
|
+
"artifacts>list": {
|
277
277
|
"table_params": {
|
278
278
|
"output_keys": {
|
279
279
|
"id": {
|
@@ -297,7 +297,7 @@ command_metadata: Dict[str, Any] = {
|
|
297
297
|
"subheader_key": "artifactCount",
|
298
298
|
},
|
299
299
|
},
|
300
|
-
"
|
300
|
+
"specs>list": {
|
301
301
|
"table_params": {
|
302
302
|
"output_keys": {
|
303
303
|
"id": {
|
@@ -325,7 +325,7 @@ command_metadata: Dict[str, Any] = {
|
|
325
325
|
"subheader_key": "specCount",
|
326
326
|
},
|
327
327
|
},
|
328
|
-
"
|
328
|
+
"specs>list-release-deployments": {
|
329
329
|
"table_params": {
|
330
330
|
"output_keys": {
|
331
331
|
"id": {
|
@@ -356,7 +356,7 @@ command_metadata: Dict[str, Any] = {
|
|
356
356
|
"subheader_key": "deploymentCount",
|
357
357
|
},
|
358
358
|
},
|
359
|
-
"
|
359
|
+
"deployments>list": {
|
360
360
|
"table_params": {
|
361
361
|
"output_keys": {
|
362
362
|
"id": {
|
@@ -387,7 +387,7 @@ command_metadata: Dict[str, Any] = {
|
|
387
387
|
"subheader_key": "deploymentCount",
|
388
388
|
},
|
389
389
|
},
|
390
|
-
"
|
390
|
+
"apps>specs>list": {
|
391
391
|
"table_params": {
|
392
392
|
"output_keys": {
|
393
393
|
"id": {
|
@@ -415,7 +415,7 @@ command_metadata: Dict[str, Any] = {
|
|
415
415
|
"subheader_key": "specCount",
|
416
416
|
},
|
417
417
|
},
|
418
|
-
"
|
418
|
+
"apps>specs>list-releases": {
|
419
419
|
"table_params": {
|
420
420
|
"output_keys": {
|
421
421
|
"id": {
|
@@ -439,7 +439,7 @@ command_metadata: Dict[str, Any] = {
|
|
439
439
|
"subheader_key": "releaseCount",
|
440
440
|
},
|
441
441
|
},
|
442
|
-
"
|
442
|
+
"apps>deployments>list": {
|
443
443
|
"table_params": {
|
444
444
|
"output_keys": {
|
445
445
|
"id": {
|
@@ -470,7 +470,7 @@ command_metadata: Dict[str, Any] = {
|
|
470
470
|
"subheader_key": "deploymentCount",
|
471
471
|
},
|
472
472
|
},
|
473
|
-
"
|
473
|
+
"apps>deployments>list-revisions": {
|
474
474
|
"table_params": {
|
475
475
|
"output_keys": {
|
476
476
|
"id": {
|
@@ -491,7 +491,7 @@ command_metadata: Dict[str, Any] = {
|
|
491
491
|
"subheader_key": "revisionCount",
|
492
492
|
},
|
493
493
|
},
|
494
|
-
"
|
494
|
+
"blocks>specs>list": {
|
495
495
|
"table_params": {
|
496
496
|
"output_keys": {
|
497
497
|
"id": {
|
@@ -519,7 +519,7 @@ command_metadata: Dict[str, Any] = {
|
|
519
519
|
"subheader_key": "specCount",
|
520
520
|
},
|
521
521
|
},
|
522
|
-
"
|
522
|
+
"blocks>specs>list-releases": {
|
523
523
|
"table_params": {
|
524
524
|
"output_keys": {
|
525
525
|
"id": {
|
@@ -543,7 +543,7 @@ command_metadata: Dict[str, Any] = {
|
|
543
543
|
"subheader_key": "releaseCount",
|
544
544
|
},
|
545
545
|
},
|
546
|
-
"
|
546
|
+
"blocks>deployments>list": {
|
547
547
|
"table_params": {
|
548
548
|
"output_keys": {
|
549
549
|
"id": {
|
@@ -574,7 +574,7 @@ command_metadata: Dict[str, Any] = {
|
|
574
574
|
"subheader_key": "deploymentCount",
|
575
575
|
},
|
576
576
|
},
|
577
|
-
"
|
577
|
+
"blocks>deployments>list-revisions": {
|
578
578
|
"table_params": {
|
579
579
|
"output_keys": {
|
580
580
|
"id": {
|
@@ -595,7 +595,27 @@ command_metadata: Dict[str, Any] = {
|
|
595
595
|
"subheader_key": "revisionCount",
|
596
596
|
},
|
597
597
|
},
|
598
|
-
"
|
598
|
+
"deployments>execute-resources": {
|
599
|
+
"table_params": {
|
600
|
+
"output_keys": {
|
601
|
+
"blockSpecId": {
|
602
|
+
"label": "Block Spec ID",
|
603
|
+
},
|
604
|
+
"version": {
|
605
|
+
"label": "Version",
|
606
|
+
},
|
607
|
+
"executionId": {
|
608
|
+
"label": "Execution ID",
|
609
|
+
},
|
610
|
+
"status": {
|
611
|
+
"label": "Execution Status",
|
612
|
+
},
|
613
|
+
},
|
614
|
+
"title": "Trigger Resources",
|
615
|
+
"data_key": "executeResponse",
|
616
|
+
},
|
617
|
+
},
|
618
|
+
"tenants>list-instance-options": {
|
599
619
|
"table_params": {
|
600
620
|
"output_keys": {
|
601
621
|
"id": {
|
@@ -624,7 +644,7 @@ command_metadata: Dict[str, Any] = {
|
|
624
644
|
"data_key": "data",
|
625
645
|
},
|
626
646
|
},
|
627
|
-
"
|
647
|
+
"alerts>emails>list": {
|
628
648
|
"table_params": {
|
629
649
|
"output_keys": {
|
630
650
|
"id": {
|
@@ -651,7 +671,7 @@ command_metadata: Dict[str, Any] = {
|
|
651
671
|
"subheader_key": "emailCount",
|
652
672
|
},
|
653
673
|
},
|
654
|
-
"
|
674
|
+
"alerts>emails>list-templates": {
|
655
675
|
"table_params": {
|
656
676
|
"output_keys": {
|
657
677
|
"id": {
|
@@ -675,103 +695,103 @@ command_metadata: Dict[str, Any] = {
|
|
675
695
|
"subheader_key": "templateCount",
|
676
696
|
},
|
677
697
|
},
|
678
|
-
"
|
698
|
+
"artifacts>create": {
|
679
699
|
"request_body_yaml_path": "sample_yaml/resources/artifacts/create_artifact.yaml",
|
680
700
|
},
|
681
|
-
"
|
701
|
+
"artifacts>update-metadata": {
|
682
702
|
"request_body_yaml_path": "sample_yaml/resources/artifacts/update_artifact_metadata.yaml",
|
683
703
|
},
|
684
|
-
"
|
704
|
+
"artifacts>create-version": {
|
685
705
|
"request_body_yaml_path": "sample_yaml/resources/artifacts/create_artifact_version.yaml",
|
686
706
|
},
|
687
|
-
"
|
707
|
+
"images>create": {
|
688
708
|
"request_body_yaml_path": "sample_yaml/resources/images/upload/create_image.yaml",
|
689
709
|
},
|
690
|
-
"
|
710
|
+
"images>create-version": {
|
691
711
|
"request_body_yaml_path": "sample_yaml/resources/images/upload/create_image_version.yaml",
|
692
712
|
},
|
693
|
-
"
|
713
|
+
"images>update-version": {
|
694
714
|
"request_body_yaml_path": "sample_yaml/resources/images/upload/update_version.yaml",
|
695
715
|
},
|
696
|
-
"
|
716
|
+
"images>create-or-update": {
|
697
717
|
"request_body_yaml_path": "sample_yaml/resources/images/upload/create_or_update_image.yaml",
|
698
718
|
},
|
699
|
-
"
|
719
|
+
"workflows>create": {
|
700
720
|
"request_body_yaml_path": "sample_yaml/resources/workflows/create_workflow.yaml",
|
701
721
|
},
|
702
|
-
"
|
722
|
+
"workflows>update": {
|
703
723
|
"request_body_yaml_path": "sample_yaml/resources/workflows/update_workflow.yaml",
|
704
724
|
},
|
705
|
-
"
|
725
|
+
"workflows>create-or-update": {
|
706
726
|
"request_body_yaml_path": "sample_yaml/resources/workflows/create_or_update_workflow.yaml",
|
707
727
|
},
|
708
|
-
"
|
728
|
+
"workflows>patch": {
|
709
729
|
"request_body_yaml_path": "sample_yaml/resources/workflows/patch_workflow.yaml",
|
710
730
|
},
|
711
|
-
"
|
731
|
+
"workflows>execute": {
|
712
732
|
"request_body_yaml_path": "sample_yaml/resources/workflows/execute_workflow.yaml",
|
713
733
|
},
|
714
|
-
"
|
734
|
+
"webapps>create": {
|
715
735
|
"request_body_yaml_path": "sample_yaml/resources/webapps/create_webapp.yaml",
|
716
736
|
},
|
717
|
-
"
|
737
|
+
"webapps>update": {
|
718
738
|
"request_body_yaml_path": "sample_yaml/resources/webapps/update_webapp.yaml",
|
719
739
|
},
|
720
|
-
"
|
740
|
+
"webapps>create-or-update": {
|
721
741
|
"request_body_yaml_path": "sample_yaml/resources/webapps/create_or_update_webapp.yaml",
|
722
742
|
},
|
723
|
-
"
|
743
|
+
"services>create": {
|
724
744
|
"request_body_yaml_path": "sample_yaml/resources/services/create_service.yaml",
|
725
745
|
},
|
726
|
-
"
|
746
|
+
"services>update": {
|
727
747
|
"request_body_yaml_path": "sample_yaml/resources/services/update_service.yaml",
|
728
748
|
},
|
729
|
-
"
|
749
|
+
"services>create-or-update": {
|
730
750
|
"request_body_yaml_path": "sample_yaml/resources/services/create_or_update_service.yaml",
|
731
751
|
},
|
732
|
-
"
|
752
|
+
"services>test": {
|
733
753
|
"request_body_yaml_path": "sample_yaml/resources/services/test_service.yaml",
|
734
754
|
},
|
735
|
-
"
|
755
|
+
"alerts>emails>send": {
|
736
756
|
"request_body_yaml_path": "sample_yaml/resources/emails/send_email.yaml",
|
737
757
|
},
|
738
|
-
"
|
758
|
+
"apps>specs>create": {
|
739
759
|
"request_body_yaml_path": "sample_yaml/press/apps/specs/create_app_spec.yaml",
|
740
760
|
},
|
741
|
-
"
|
761
|
+
"apps>specs>update-metadata": {
|
742
762
|
"request_body_yaml_path": "sample_yaml/press/apps/specs/update_app_spec_metadata.yaml",
|
743
763
|
},
|
744
|
-
"
|
764
|
+
"apps>specs>create-release": {
|
745
765
|
"request_body_yaml_path": "sample_yaml/press/apps/specs/create_app_spec_release.yaml",
|
746
766
|
},
|
747
|
-
"
|
767
|
+
"apps>deployments>create": {
|
748
768
|
"request_body_yaml_path": "sample_yaml/press/apps/deployments/create_app_deployment.yaml",
|
749
769
|
},
|
750
|
-
"
|
770
|
+
"apps>deployments>create-revision": {
|
751
771
|
"request_body_yaml_path": "sample_yaml/press/apps/deployments/create_app_deployment_revision.yaml",
|
752
772
|
},
|
753
|
-
"
|
773
|
+
"apps>deployments>update-metadata": {
|
754
774
|
"request_body_yaml_path": "sample_yaml/press/apps/deployments/update_app_deployment_metadata.yaml",
|
755
775
|
},
|
756
|
-
"
|
757
|
-
"request_body_yaml_path": "sample_yaml/press/blocks/specs/create_block_spec.yaml",
|
776
|
+
"blocks>specs>create": {
|
777
|
+
"request_body_yaml_path": "sample_yaml/press/blocks/specs/workflow/create_block_spec.yaml",
|
758
778
|
},
|
759
|
-
"
|
779
|
+
"blocks>specs>update-metadata": {
|
760
780
|
"request_body_yaml_path": "sample_yaml/press/blocks/specs/update_block_spec_metadata.yaml",
|
761
781
|
},
|
762
|
-
"
|
763
|
-
"request_body_yaml_path": "sample_yaml/press/blocks/specs/create_block_spec_release.yaml",
|
782
|
+
"blocks>specs>create-release": {
|
783
|
+
"request_body_yaml_path": "sample_yaml/press/blocks/specs/workflow/create_block_spec_release.yaml",
|
764
784
|
},
|
765
|
-
"
|
785
|
+
"blocks>deployments>create": {
|
766
786
|
"request_body_yaml_path": "sample_yaml/press/blocks/deployments/create_block_deployment.yaml",
|
767
787
|
},
|
768
|
-
"
|
788
|
+
"blocks>deployments>create-revision": {
|
769
789
|
"request_body_yaml_path": "sample_yaml/press/blocks/deployments/create_block_deployment_revision.yaml",
|
770
790
|
},
|
771
|
-
"
|
791
|
+
"blocks>deployments>update-metadata": {
|
772
792
|
"request_body_yaml_path": "sample_yaml/press/blocks/deployments/update_block_deployment_metadata.yaml",
|
773
793
|
},
|
774
|
-
"
|
794
|
+
"blocks>deployments>patch-parameters": {
|
775
795
|
"request_body_yaml_path": "sample_yaml/press/blocks/deployments/patch_block_parameters.yaml",
|
776
796
|
},
|
777
797
|
}
|
peak/_version.py
CHANGED
peak/callbacks.py
CHANGED
@@ -19,8 +19,11 @@
|
|
19
19
|
# # along with this program. If not, see <https://apache.org/licenses/LICENSE-2.0>
|
20
20
|
#
|
21
21
|
"""All the Typer callbacks."""
|
22
|
+
from __future__ import annotations
|
23
|
+
|
22
24
|
from pathlib import Path
|
23
25
|
|
26
|
+
import click
|
24
27
|
import typer
|
25
28
|
|
26
29
|
import peak.config
|
@@ -41,11 +44,28 @@ def paging(*, enable_paging: bool) -> None:
|
|
41
44
|
peak.config.ENABLE_PAGING = enable_paging
|
42
45
|
|
43
46
|
|
47
|
+
def get_full_command_name(ctx: typer.Context | click.core.Context | None) -> str:
|
48
|
+
"""Callback to get the full command name."""
|
49
|
+
if ctx:
|
50
|
+
parent = get_full_command_name(ctx.parent)
|
51
|
+
if parent:
|
52
|
+
return f"{parent}>{ctx.info_name}"
|
53
|
+
return str(ctx.info_name)
|
54
|
+
|
55
|
+
return ""
|
56
|
+
|
57
|
+
|
58
|
+
def get_command_name(ctx: typer.Context) -> str:
|
59
|
+
"""Callback to get the parsed command name with first part removed."""
|
60
|
+
command = get_full_command_name(ctx)
|
61
|
+
return ">".join(command.split(">")[1:])
|
62
|
+
|
63
|
+
|
44
64
|
def handle_output(output_type: OutputTypes, ctx: typer.Context) -> None:
|
45
65
|
"""Callback to handle CLI output type and set all the required parameters for Table output."""
|
46
66
|
peak.config.OUTPUT_TYPE = output_type
|
47
67
|
|
48
|
-
command = ctx
|
68
|
+
command = get_command_name(ctx)
|
49
69
|
|
50
70
|
if (command not in command_metadata) or ("table_params" not in command_metadata[command]):
|
51
71
|
return
|
@@ -55,7 +75,7 @@ def handle_output(output_type: OutputTypes, ctx: typer.Context) -> None:
|
|
55
75
|
|
56
76
|
def generate_yaml(ctx: typer.Context, generate_yaml: bool) -> None: # noqa: FBT001 # pragma: no cover
|
57
77
|
"""Callback to generate yaml file."""
|
58
|
-
command = ctx
|
78
|
+
command = get_command_name(ctx)
|
59
79
|
|
60
80
|
if (command not in command_metadata) or ("request_body_yaml_path" not in command_metadata[command]):
|
61
81
|
return
|
peak/cli/args.py
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
# # along with this program. If not, see <https://apache.org/licenses/LICENSE-2.0>
|
20
20
|
#
|
21
21
|
"""CLI arguments."""
|
22
|
+
|
22
23
|
import typer
|
23
24
|
from peak.callbacks import dry_run, generate_yaml, handle_output, paging
|
24
25
|
from peak.cli.version import display_version
|
@@ -159,3 +160,21 @@ FILE_NAME = typer.Option(
|
|
159
160
|
None,
|
160
161
|
help="Name or path of the file to save the logs.",
|
161
162
|
)
|
163
|
+
|
164
|
+
RELEASE_NOTES_FILE = typer.Option(
|
165
|
+
None,
|
166
|
+
"--release-notes-file",
|
167
|
+
"-n",
|
168
|
+
help="""
|
169
|
+
Path to the file that defines the release notes for this operation, supports `md`, and `txt` files only.
|
170
|
+
""",
|
171
|
+
)
|
172
|
+
|
173
|
+
REVISION_NOTES_FILE = typer.Option(
|
174
|
+
None,
|
175
|
+
"--revision-notes-file",
|
176
|
+
"-n",
|
177
|
+
help="""
|
178
|
+
Path to the file that defines the revision notes for this operation, supports `md`, and `txt` files only.
|
179
|
+
""",
|
180
|
+
)
|
peak/cli/helpers.py
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
# # along with this program. If not, see <https://apache.org/licenses/LICENSE-2.0>
|
20
20
|
#
|
21
21
|
"""Helper functions for Peak `cli`."""
|
22
|
+
|
22
23
|
from __future__ import annotations
|
23
24
|
|
24
25
|
import inspect
|
@@ -90,33 +91,36 @@ def template_handler(
|
|
90
91
|
file: str,
|
91
92
|
params_file: Optional[str] = None,
|
92
93
|
params: Optional[List[str]] = None,
|
93
|
-
|
94
|
+
markdown_files: Optional[Dict[str, str]] = None,
|
94
95
|
) -> Dict[str, Any]:
|
95
96
|
"""Loads and returns the rendered template.
|
96
97
|
|
97
98
|
Args:
|
98
99
|
file (str): Path to the template file.
|
99
100
|
params_file (Optional[str]): Path to the params map file.
|
100
|
-
description_file: (Optional[str]): Path to the description markdown/text file
|
101
101
|
params (Optional[List[str]]): List of params to override.
|
102
|
+
markdown_files (Optional[Dict[str, str]]): Dictionary of markdown files to load.
|
103
|
+
The key is a colon-separated string representing the nested key path (e.g., "body:metadata:description"), and the value is the path to the markdown file.
|
102
104
|
|
103
105
|
Returns:
|
104
106
|
Dict[str, Any]: Rendered template with values substituted.
|
105
107
|
"""
|
106
108
|
params_dict: Dict[str, Any] = {}
|
107
|
-
|
109
|
+
markdown_data: Dict[str, str] = {}
|
110
|
+
|
108
111
|
if params_file:
|
109
112
|
with Path(params_file).open("r") as f:
|
110
113
|
params_dict = yaml.safe_load(f.read())
|
111
114
|
|
112
|
-
if
|
113
|
-
|
114
|
-
|
115
|
-
|
115
|
+
if markdown_files:
|
116
|
+
for key, value in markdown_files.items():
|
117
|
+
check_file_extension(value)
|
118
|
+
with Path(value).open("r") as f:
|
119
|
+
markdown_data[key] = f.read()
|
116
120
|
|
117
121
|
params_dict = remove_none_values({**params_dict, **parse_params(params)})
|
118
122
|
|
119
|
-
return load_template(file, params_dict,
|
123
|
+
return load_template(file, params_dict, markdown_data=markdown_data, convert_to_snake_case=True)
|
120
124
|
|
121
125
|
|
122
126
|
def remove_unknown_args(args: Dict[str, Any], func: Callable[..., Any]) -> Dict[str, Any]:
|