bartavelle / language-puppet

A library to work with Puppet manifests, test them and eventually replace everything ruby.
BSD 3-Clause "New" or "Revised" License
51 stars 8 forks source link

Implement the mock translate function (from Puppetlabs-translate) #254

Closed PierreR closed 6 years ago

PierreR commented 6 years ago

I was about to push this PR but it does not accept the the following syntax with the double ((.

Any idea ?

 fail translate(('log_level must be one of debug, info, warn, error or fatal'))

https://github.com/puppetlabs/puppetlabs-docker/blob/master/manifests/init.pp#L498

ERROR: (swarm.manager.dev) cannot parse ./modules/application/manifests/role/swarm/test.pp:3:17:
  |
3 |   fail translate(('You must provide the $bridge parameter.'))
  |                 ^
unexpected '('
expecting ',', '}', operator, or the rest of Statement
 at ./modules/application/manifests/role/swarm/manager.pp:2:3
bartavelle commented 6 years ago

Is it accepted with single parens?

PierreR commented 6 years ago

I guess it is. Looking at the help from puppetlabs-translate there no usage of double parens. I am actually surprised this is valid puppet syntax.

PierreR commented 6 years ago

I guess it is. Looking at the help from puppetlabs-translate there no usage of double parens. I am actually surprised this is valid puppet syntax.

bartavelle commented 6 years ago

I think puppetresources doesn't like that fail is called without parens, that is why I wonder if it worked with single parens.

PierreR commented 6 years ago

No it does not work with single parens:

ERROR: (swarm.manager.dev) cannot parse ./modules/application/manifests/role/swarm/test.pp:3:17:
  |
3 |   fail translate('You must provide the $bridge parameter.')
  |                 ^
unexpected '('
expecting ',', '}', operator, or the rest of Statement
PierreR commented 6 years ago

Do you want to support that idiom with the single parens ? Not at all or only in permissive mode ?

fail translate('Custom package source is currently not implemented on windows.')
bartavelle commented 6 years ago

The problem is not with the parens, it is that you can apparently call functions like fail with no parens ...

bartavelle commented 6 years ago

Your translate function is fine, it is a parser problem with fail "foo".

PierreR commented 6 years ago

Ok thanks I will fill in a different issue if needed.