Skip to content

Conversation

@jsoriano
Copy link
Member

@jsoriano jsoriano commented Nov 23, 2022

Use common.MapStr to be able to get variables independently of them being expanded because of having dots or not.

Variables in policy templates can have dots in their names. This names are defined as plain strings in yaml files. For example like this:

      - name: jmx.mappings
        type: yaml
        title: JMX Mappings
        multi: false
        required: true
        show_user: true

These variables can be overridden in system tests configuration files, for example like this:

vars:
  hosts:
    - {{Hostname}}:{{Port}}
  jmx.mappings: |
    - mbean: 'java.lang:type=Runtime'
      attributes:
        - attr: Uptime
          field: uptime

These configuration files are parsed with go-ucfg, configured to use . as path separator, so variable names containing dots are expanded. Also, when parsed, they are parsed into an opaque VarVariable structure, so it is not possible to access their content, so overrides cannot be defined for variables with dots in their names.
This happens for example in elastic/integrations#4706.

This issue could be easily solved if ucfg would support preserve as defined in elastic/go-ucfg#124.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-11-23T16:34:52.271+0000

  • Duration: 30 min 53 sec

Test stats 🧪

Test Results
Failed 0
Passed 865
Skipped 0
Total 865

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link
Collaborator

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (35/35) 💚
Files 66.923% (87/130) 👍
Classes 61.622% (114/185) 👍
Methods 47.442% (371/782) 👍
Lines 30.356% (3321/10940) 👎 -0.003
Conditionals 100.0% (0/0) 💚

Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jsoriano jsoriano merged commit 832fc32 into elastic:main Nov 24, 2022
@jsoriano jsoriano deleted the config-variables-with-dots branch November 24, 2022 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants