reclass icon indicating copy to clipboard operation
reclass copied to clipboard

How to escape ${var} in parameter value

Open franky4u opened this issue 8 years ago • 7 comments

I've a class test.yml with the following def: parameters: url: http://my.domain.com/tst/do?nr=${nr}

${nr} is not a reclass variable just a normal string which should be passed to app... How to escape ${nr} in parameter string? (e.g. ${nr} or similar) The error I got: reclass-salt --pillar node1 Traceback (most recent call last): File "/usr/bin/reclass-salt", line 9, in load_entry_point('reclass==1.4.1', 'console_scripts', 'reclass-salt')() File "build/bdist.linux-x86_64/egg/reclass/adapters/salt.py", line 105, in cli File "build/bdist.linux-x86_64/egg/reclass/adapters/salt.py", line 38, in ext_pillar File "build/bdist.linux-x86_64/egg/reclass/core.py", line 136, in nodeinfo File "build/bdist.linux-x86_64/egg/reclass/core.py", line 122, in _nodeinfo File "build/bdist.linux-x86_64/egg/reclass/datatypes/entity.py", line 65, in interpolate File "build/bdist.linux-x86_64/egg/reclass/datatypes/parameters.py", line 180, in interpolate File "build/bdist.linux-x86_64/egg/reclass/datatypes/parameters.py", line 219, in _interpolate_inner AttributeError: 'UndefinedVariableError' object has no attribute 'var'

franky4u avatar Aug 02 '16 08:08 franky4u

I have not catered for this, I don't think. But it shouldn't be hard to add an escape handler.

madduck avatar Aug 02 '16 18:08 madduck

Hi Martin,

Thx for the reply. I’m not very good in python – so I want to ask you to invest some more of your time in your splendid product.

Do you think it’s possible for you to fix that?

Best regards Franky


Frank Stuppy ITERGO Informationstechnologie GmbH ERV Basisinfrastruktur (PEBE M) Thomas-Dehler-Straße 2 81737 München Tel. 089/4166-1250 Fax 089/4166-2250 [email protected]:[email protected]

Vorsitzender des Aufsichtsrats: Christian Diedrich Geschäftsführung: Tomasz Smaczny (Vorsitzender), Lothar Engelke, Joachim Fensch, Bernd Jung, Dr. Michael Regauer. Sitz: Düsseldorf, Handelsregister: Amtsgericht Düsseldorf, HRB 37996

Von: martin f. krafft [mailto:[email protected]] Gesendet: Dienstag, 2. August 2016 20:40 An: madduck/reclass [email protected] Cc: Stuppy Frank [email protected]; Author [email protected] Betreff: Re: [madduck/reclass] How to escape ${var} in parameter value (#55)

I have not catered for this, I don't think. But it shouldn't be hard to add an escape handler.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/madduck/reclass/issues/55#issuecomment-237000780, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AL7qhI9Hy_OHgVBigZrSvWc6ZcB7EjbYks5qb48AgaJpZM4JaV78.

franky4u avatar Aug 03 '16 06:08 franky4u

Not anytime soon. I am totally busy elsewhere after I've funding for reclass has been removed.

madduck avatar Aug 03 '16 19:08 madduck

I can look into implementing this in my fork. I'll open a PR back to upstream if I produce anything worth looking at.

lottspot avatar Aug 07 '16 00:08 lottspot

I agree with this problem, but how would you solve it?

I suppose you could insert an escape like \${var}, but what should you type if you'd need to write exactly \ followed instead by a variable substitution?

Maybe it could be define by the following rule: is possible to escape a variable substitution if it is placed a backslash before the dollar, but is you'd need to post a backslash before a variable substitution you should place again a backslash before it.

Sjd-Risca avatar Oct 31 '16 20:10 Sjd-Risca

Haven't had time to circle back to this issue yet, and a couple other features have come up which we're looking at with priority. PRs are welcome in the meantime.

lottspot avatar Dec 28 '16 14:12 lottspot

We are doing this way:

parameters:
  dollar: '$' # escaping
  url: http://my.domain.com/tst/do?nr=${dollar}{nr}

eburghar avatar May 05 '17 10:05 eburghar