Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for more then just $config$ in Service Apply For Rule properties #2432

Open
v0tti opened this issue Nov 22, 2021 · 2 comments · May be fixed by #2446 or #2387
Open

Allow for more then just $config$ in Service Apply For Rule properties #2432

v0tti opened this issue Nov 22, 2021 · 2 comments · May be fixed by #2446 or #2387

Comments

@v0tti
Copy link

v0tti commented Nov 22, 2021

Expected Behavior

I have a data field looking like something like this:

 {
    "name" => "Name".
    "parameter1" => 123,
    "parameter2" => 456
 }

I use it in an Service Apply Rule with Apply For.

I set the following:
Service Name: Check $config.name$
Custom Properties: Property 1 => $config.parameter1$ and Property 2 => $config.parameter2$

I expect the Service to be named Check Name and the properties to be set to 123 and 456 respectively.

Current Behavior

The Service gets named correctly.
The two properties will be populated with the String "$config.parameter1$" and "$config.parameter2$".

The check will report as UNKNOWN with this error:
Error: Non-optional macro 'config.parameter1' used in argument 'parameter1' is missing.

It seems the macro is expanded at a later point, which is not possible anymore since context is missing.

Possible Solution

Allow for specifying parameters in Custom Properties. At the moment only $config$ is allowed in https://github.com/Icinga/icingaweb2-module-director/blob/master/library/Director/CustomVariable/CustomVariableString.php#L49 but this will fill in my entire object.

Your Environment

  • Director version (System - About): 1.8.0
  • Icinga Web 2 version and modules (System - About): 2.9.5
  • Operating System and version: Rocky Linux 8
  • Webserver, PHP versions: PHP 8.0.13
@v0tti
Copy link
Author

v0tti commented Nov 23, 2021

I would like to look into fixing this issue if nothing speaks against it. Has a PR the prospect of being merged?

@v0tti
Copy link
Author

v0tti commented Nov 23, 2021

I see two easy ways to circumvent this issue:

  1. Remove the ['config'] in CustomVariableString Line 49 completely
  2. Enhance renderStringWithVariables to check not only for exact matches to whitelist entries, but also everything that starts with this variable.

Solution (1) works fine for my use case, but may break other peoples setup?

@v0tti v0tti linked a pull request Dec 6, 2021 that will close this issue
@Yoda-BZH Yoda-BZH linked a pull request Dec 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant