Dynatrace / dynatrace-configuration-as-code

This tool automates deployment of Dynatrace Configuration to one or multiple Dynatrace environments.
https://docs.dynatrace.com/docs/manage/configuration-as-code/monaco
Apache License 2.0
164 stars 94 forks source link

feat: Introduce `FileParameter` to allow reading parameter content from files #1461

Closed warber closed 6 months ago

warber commented 6 months ago

What this PR does / Why we need it:

This PR introduces a new type of parameter, FileParameter which can be used to load content from a file and use it for templating in Monaco:

configs:
- id: 2dab49b5-b58c-3f1c-b55f-342bee900db4
  config:
    name:
      type: value
      value: MyWorkflow
    parameters:
      comment: "// hey special comment"
      workflow:
        type: file
        path: "myWf.js"
        references:
          - comment
    template: 2dab49b5-b58c-3f1c-b55f-342bee900db4.json
    skip: false
    originObjectId: 2dab49b5-b58c-3f1c-b55f-342bee900db4

During deployment, Monaco will load the content of myWf.js into the parameter called workflowwhich can be referenced in the template using {{ .workflow }} This particular example allows users to keep their workflow scripts in separate files instead of embedded inside the template, whicih improves usability a lot. Note, that it is also possible to use templating inside the loaded file as well. In the example above this is demonstrated by another paramter comment which can be used inside the myFs.js file with {{ .comment }}

Usually the path field of a FileParamter shall contain the filename. Monaco will search and load for that file located relative to the config folder. However it is also possible to break out of the config folder by using e.g. ../myFs.js

Special notes for your reviewer:

Does this PR introduce a user-facing change?

github-actions[bot] commented 6 months ago

Unit Test Results

1 803 tests  +8   1 803 :white_check_mark: +8   17s :stopwatch: ±0s   129 suites +1       0 :zzz: ±0      1 files   ±0       0 :x: ±0 

Results for commit 0ca9943b. ± Comparison against base commit a4287300.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 6 months ago

E2E Test Results

    4 files  ± 0    258 suites  +2   21m 16s :stopwatch: -26s 1 909 tests + 9  1 908 :white_check_mark: + 9  1 :zzz: ±0  0 :x: ±0  1 998 runs  +18  1 997 :white_check_mark: +18  1 :zzz: ±0  0 :x: ±0 

Results for commit 0dc686c2. ± Comparison against base commit 19ed1688.

:recycle: This comment has been updated with latest results.

sonarcloud[bot] commented 6 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud