summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
Commit message (Collapse)AuthorAgeFilesLines
...
* Allow adding single key to hashesBrice Figureau2010-02-174-853/+925
| | | | | | | | | | This patch allow this syntax: $hash[mykey] = 12 If the key already exist an error is raised. Hashes are essentially write only, like puppet variables. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Raise an error when appending not a hash to a hashBrice Figureau2010-02-171-0/+1
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #2389 - Enhance Puppet DSL with HashesBrice Figureau2010-02-176-918/+1192
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bring a new container syntax to the Puppet DSL: hashes. Hashes are defined like Ruby Hash: { key1 => val1, ... } Hash keys are strings, but hash values can be any possible right values admitted in Puppet DSL (ie function call, variables access...) Currently it is possible: 1) to assign hashes to variable $myhash = { key1 => "myval", key2 => $b } 2) to access hash members (recursively) from a variable containing a hash (works for array too): $myhash = { key => { subkey => "b" }} notice($myhash[key][subjey]] 3) to use hash member access as resource title 4) to use hash in default definition parameter or resource parameter if the type supports it (known for the moment). It is not possible to string interpolate an hash access. If it proves to be an issue it can be added or work-arounded with a string concatenation operator easily. It is not possible to use an hash as a resource title. This might be possible once we support compound resource title. Unlike the proposed syntax in the ticket it is not possible to assign individual hash member (mostly to respect write once nature of variable in puppet). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #3186 - require function set relationship only on the last classBrice Figureau2010-02-171-1/+1
| | | | | | | | Due to the fact that resource.set_parameter is overwriting the previous set_parameters, we were losing the previous relationships we set there, either in a previous call of require or in the same call. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #3150 - require function doesn't like ::class syntaxBrice Figureau2010-02-171-0/+7
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Move scope parenting & class_scope from Compiler to ScopeMarkus Roberts2010-02-173-57/+37
| | | | | | | | | | | | | | | | This refactor fixes about a quarter of the test failures on master and (I hope) will simplify some of the integration issues on the testing branch. It is my best guess at The Right Thing To Do (or at least a step in that direction) but I could be persuaded otherwise. The basic idea is to take responsibility for maintaining scope hierarchy and class_name -> class_scope mapping out of the compiler class and put it in the scope class where it arguably belongs. To maintain the semantics, class scopes are all tracked by the "top level" scope, though this could be relaxed if the nesting semantics were ever needed. If this winds up being the right thing to do, related routines (e.g. newscope) should be sorted out as well.
* Merge branch '0.25.x'James Turnbull2010-01-131-1/+1
|\ | | | | | | | | | | Conflicts: lib/puppet/ssl/host.rb spec/spec_helper.rb
| * Fixed spellquote function documentationJames Turnbull2009-12-061-1/+1
| |
* | Fix #2818 - scope variable assigned with undef are not "undef"Brice Figureau2009-12-291-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following manifest doesn't work: $foo = undef case $foo { undef: { notice("undef") } default: { notice("defined") } } This is because "undef" scope variable are returned as an empty string. This patch introduces a behavior change: Now, unassigned variable usage returns also undef. This might produce some issues in existing manifests, although care has been taken to allow correct behavior in the most commonly used patterns. For instance: case $bar { undef: { notice("undef") } default: { notice("defined") } } will print "undef". But matching undef in case/selector/if will also match "". case $bar { "": { notice("empty") } default: { notice("defined") } } will print "empty". Of course "" doesn't match undef :-) Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* | Merge branch '0.25.x'Luke Kanies2009-12-216-14/+29
|\| | | | | | | | | | | | | | | Conflicts: lib/puppet/agent.rb lib/puppet/application/puppetd.rb lib/puppet/parser/ast/leaf.rb lib/puppet/util/rdoc/parser.rb
| * Possible workaround for #2824 (MRI GC bug)Markus Roberts2009-11-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a moderately ugly workaround for the MRI garbage collection bug (see the ticket for details). I explored several other potential solutions (notably, monkey patching the routines that trigger the bug) but none of them were satisfactory. Monkey patching sub, gsub, sub!, gsub!, etc., for example, either changes the scoping of $~, $1, etc. in a way that could potentially subtly change the meaning of programs or (if you are clever) faithfully reproduces the behaviour of MRI--including the memory leak. I decided to go with the standardized and somewhat obnoxious never- used optional argument as it was easy to automatically insert and should be even easier to automatically find and remove if a better fix is developed. It also should be obtrusive enough to escape accidental removal in refactoring.
| * Updated generate function documentation to make it clear it runs on the masterJames Turnbull2009-11-131-2/+2
| |
| * Fix #2796 - Fix puppetdoc rdoc selector parsingBrice Figureau2009-11-123-0/+12
| | | | | | | | | | | | | | | | | | This patch fix this bug by adding more to_s methods to ast member so that puppetdoc can just to_s the AST to reconstruct the original puppet code. Of course this is not perfect, but should work most of the time. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
| * Al Hoang's patch for #2781, removing obsolete when/: syntaxMarkus Roberts2009-11-051-2/+2
| | | | | | | | | | | | This is just Al's patch with removal of trailing ";"s. Signed-off-by: Markus Roberts <Markus@reality.com>
| * Fixing #2752 - "require" loads "include"Luke Kanies2009-10-261-1/+4
| | | | | | | | Signed-off-by: Luke Kanies <luke@madstop.com>
| * Bug #2534 Raise error if property appears twiceJesse Wolfe2009-10-271-0/+6
| | | | | | | | | | | | | | This patch changes Puppet::Parser::Resource to check if it has been passed two Puppet::Parser::Resource::Param objects with the same name. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
| * Use notice() in the versioncmp() docsTodd Zullinger2009-10-261-1/+1
| | | | | | | | | | | | | | | | Use of notify() is an error, so replace it with notice, which is a function. Alternately, notify { msg => '2.6-1 is > than 2.4.5' } could be used. Signed-off-by: Todd Zullinger <tmz@pobox.com>
| * Fix #2691 - Collection AR request should not include params if querying with ↵Brice Figureau2009-10-251-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tags f9516d introduced a change in the way the user tags are persisted to the database: user tags are now treated as regular tags (they are stored to the tags table). Thus this commit changed the AR collector request to also look at the tags tables when collecting. Unfortunately this added a performance regression since tag request were still importing the resources parameters tables and AR was issuing a large request which was returning all the resource parameters joined with the tags. This commit fixes the AR request to join to the needed table, instead of doing an include. Including (ie eager loading) parameter values was not working for resource parameters anyway since at least 0.24 because searching by parameter add a constraint to the joins and only the searched parameter was returned instead of all parameter for a given exported resource. So on a performance standpoint this new code should be as fast 0.24 was. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* | Fixing #2596 - Node, Class, Definition are not ASTLuke Kanies2009-12-0910-515/+291
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit extracts these three classes into a single ResourceType class in the Parser heirarchy, now completely independent of the AST heirarchy. Most of the other changes are just changing the interface to the new class, which is greatly simplified over the previous classes. This opens up the possibility of drastically simplifying a lot of this other code, too -- in particular, replacing the reference to the parser with a reference to the (soon to be renamed) LoadedCode class. Signed-off-by: Luke Kanies <luke@madstop.com>
* | Fix #2796 - Fix puppetdoc rdoc selector parsingBrice Figureau2009-11-123-0/+12
|/ | | | | | | | | This patch fix this bug by adding more to_s methods to ast member so that puppetdoc can just to_s the AST to reconstruct the original puppet code. Of course this is not perfect, but should work most of the time. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Bug #1900 Parsing of quoted $ in stdinJesse Wolfe2009-10-191-1/+1
| | | | | | | | | | | | | | | When code comes in via STDIN or --code , Puppet::Util::Settings interpolates $values in the code, which is probably never the intended behavior. This is the least destructive fix I could think of: have Puppet::Parser::Interpreter ask for the uninterpolated value. More general fixes could be to: a) Add an escape character to Settings's interpolator, and escape STDIN b) Add a mechanism to Settings to mark some values as uninterpolated Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
* Fixing #2735 - node classes are immed. added to classlistLuke Kanies2009-10-181-0/+3
| | | | | | | | | This commit adds any external node classes to the classlist at compiler initialization, so that at least those classes will be isolated from any ordering issues encountered when testing the contents of the class list during compilation. Signed-off-by: Luke Kanies <luke@madstop.com>
* Proposed alternative solution for #2664 (REGEX / DIV lexing)Markus Roberts2009-10-161-31/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | This is my proposed attack on the lexing problem, with a few minor cleanups to simplify its integration. The strategy: * Anotate tokens with a method "acceptable?" that determines if they can be generated in a given context. Have this default to true. * Give the lexer the notion of a context; initialize it and update it as needed. The present context records the name of the last significant token generated and a start_of_line flag. * When a token is found to match, check if it is acceptable in the present context before generating it. These changes don't result any any change in behaviour but they enable: * Give the REGEX token an acceptable? rule that only permits a regular expression in specific contexts. The other changes were a fix to the scan bug Brice reported, adjusting a test and clearing up some cluttered conditions in the context collection path. Added tests and subsumed change restricting REGEX to one line.
* Fix #2707 config_version fails more helpfullyRein Henrichs2009-10-151-1/+4
| | | | | | Use Puppet::Util.execute to run the config_version command and reraise its potential Puppet::ExecutionFailure exception as a more useful Pupppet::ParseError
* Fix #2672 - Make sure nodenames keep their underscores when used as classnameBrice Figureau2009-09-231-1/+1
| | | | | | | | The #2627 fix was modifying nodename in case of string nodename, but was removing '_'. Since underscores is a valid character in a class name, we now allow it. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #2664 - Mathematic expressions mis-lexed as RegexBrice Figureau2009-09-221-1/+1
| | | | | | | | | | | | | | | | This is not the real fix. It is just an hot-fix to limit the issue. The issue is that the lexer regexes have precedences over simple '/' (divide). In the following expression: $var = 4096 / 4 $var2 = "/tmp/file" The / 4... part is mis-lexed as a regex instead of a mathematical expression. The current fix limits regex to one-line. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixing #2632 - 'require' works for 0.25 clientsLuke Kanies2009-09-222-8/+20
| | | | | | | | I couldn't find a way to make it compatible with earlier clients, so the docs specify that it doesn't work with them, and it helpfully fails. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fixing relationship metaparam backward compatibilityLuke Kanies2009-09-221-6/+25
| | | | | | | | | | We broke some cases of metaparam compatibility in 0.25. Most of it was pretty esoteric, but one thing that wasn't working was relationship metaparams specified on defined resources. This adds a compatibility method for older clients. Signed-off-by: Luke Kanies <luke@madstop.com>
* Adding version information to the catalog for compatLuke Kanies2009-09-221-0/+4
| | | | | | | We need to be able to do compatibility testing, and this allows us to do so. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fix #2638 - Allow creating several nodes with matching namesBrice Figureau2009-09-172-1/+5
| | | | | | | | When we are checking if a node exists before creating a new one we were also trying to match with regex node names, finding matches where in fact there is no equality. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #2627 - regex node name could lead to invalid tagBrice Figureau2009-09-161-3/+1
| | | | | | | | | We're converting the regex to a straight name to be used as the node class name which later on will be used as tag. It was possible to generate an invalid tag name (containing leading or successive dots). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Merged fix for #2601Markus Roberts2009-09-161-10/+4
| | | | | | | | | | | This patch rolls up the changeses discussed on the list & the ticket The fqdn_rand now takes any number of additional arguments of any type that has a string representation (typically integers or strings) and concatenats them on to the salt. The tests have been adjusted to reflect this. Signed-off-by: Markus Roberts <Markus@reality.com>
* Make regsubst() function operate on arrays (feature #2491).Thomas Bellman2009-09-151-30/+44
| | | | | | | | | | | Allow the first argument to the regsubst() function be an array, and perform regexp replacement on each element of the array in that case. This patch also adds more error checking to give better error messages to the user when given bad parameters. Signed-off-by: Thomas Bellman <bellman@nsc.liu.se>
* Ticket #2525 don't fail find_manifest on invalid module namesMarkus Roberts2009-09-051-13/+11
| | | | | | | | | The patch that put validity assertions in for module names broke find_manifest because rather than returning a failure it now rasies an exception. This patch catches the exception and treats it as a negative result. Signed-off-by: Markus Roberts <Markus@reality.com>
* Fixing #2592 - you can escape slashes in regexesLuke Kanies2009-09-041-3/+14
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* The first regex node now matches firstLuke Kanies2009-09-011-8/+15
| | | | | | | Before it was undefined, but now we always match the first defined node. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fixing #2563 - multiple regex nodes now work togetherLuke Kanies2009-09-011-2/+12
| | | | | | | | | | The problem was that we were needing to convert one of the regexes to a string, which wasn't working well. This adds specific rules for how regexes vs. strings get compared. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fix parser error outputTodd Zullinger2009-08-241-1/+1
| | | | | | The 'value' passed to on_error in Puppet::Parser::Parser is a hash, and we only want to print the 'value' key, rather than a flattened string of the hash.
* Fixing #2549 - autoloading of top-level classes works againLuke Kanies2009-08-241-7/+14
| | | | | | | | This was broken in the recent refactor around autoloading, which didn't special-case classes that specified that they were top-level. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fixes #2493Markus Roberts2009-08-141-0/+2
| | | | | | | | | | | | Added downcasing into find_or_load (which replaced fqfind) to get back the old behaviour. Adjusted tests so that they would catch the problem & confirmed that they fail without the downcasing. Added tests to confirm the existance of #2493; improved existing autoload tests (removed inter-test interactions) and noted (with a TODO) that there was dead code in the feature loading test; added analogus case sensitivity tests where apropriate.
* Fix #2507 - Exported resources were not correctly collected.Brice Figureau2009-08-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | #2507 contains two issues: * a crash when we filters-out an unwanted resource which had edges pointing to it. * resources are losing their virtuality when they are transformed from Puppet::Parser::Resource to Puppet::Resource. This means we weren't able to distinguish anymore between an exported resource collected in the same node as it was exported and an exported resource collected in another node. The net result is that we can't apply exported resources that are collected in the same node because they are filtered out by the catalog filter (see the commits for #2391 for more information). The fix is to keep the virtuality of the resources so that we can differentiate those two types of exported resources. We keep this until the catalog is ready to be sent, where we filter out the virtual resouces only, the other still exported ones needs to be sent to the client. To be real sure, the transaction also skips virtual resources. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Add shellquote() function.Thomas Bellman2009-08-081-0/+41
| | | | | | | | | | This adds a new function shellquote() which can be used for quoting arguments in shell commands used in the exec type. This only supports Unixoid operating systems. Other systems would likely require some other quoting. Signed-off-by: Thomas Bellman <bellman@nsc.liu.se>
* Fixed #2486 - Missing require 'monitor' in parser_support.rbJames Turnbull2009-08-041-0/+1
|
* Fixed #2294 - Classes sometimes cannot be foundMarkus Roberts2009-08-031-52/+63
| | | | | | | | | | | | | | | | | | | | | | | | This patch should fix the race condition causing ticket 2294; it extends the loading logic so that: * initial load attempts are processed (as before), * recursive load attempts return immediately (as before), * but subsequent concurrent load attempts from different threads wait on a semaphore (condition variable) and then retry (e.g. use the now-valid results of the first thread). This is a slight modification of the solution I'd originally proposed, to prevent a deadlock that could have arisen if three or more threads simultaneously attempted to load the same item. Though it solves the bug as reported, it has room for improvement: * Failures aren't cached, so repeated attempts will be made to import invalid items each time they are encountered * It doesn't address any of the underlying referential ambiguity (module vs. filename) * The threading logic should probably be refactored into a separate class (as a start I encapsulated it in an ad hoc singleton class, so at least it isn't cluttering up the load method) Signed-off-by: Markus Roberts <Markus@reality.com>
* Fixing tests broken by caching autoload resultsLuke Kanies2009-08-021-1/+1
| | | | | | | | | These tests tried to load something, verified the loads didn't work, and then created the thing to load. This is a bit silly, so I just removed those sections of the tests. Signed-off-by: Luke Kanies <luke@madstop.com>
* Adding support for an external catalog versionLuke Kanies2009-08-011-1/+11
| | | | | | | | This allows you to specify a command used to determine the catalog version. Also added an integration test to verify the version cascades. Signed-off-by: Luke Kanies <luke@madstop.com>
* Implement node matching with regexesBrice Figureau2009-08-016-572/+604
| | | | | | | This patch enhance AST::HostName to support regexes, and modifies the parser to allow regex to be used as node name. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>]
* Make sure node are referenced by their namesBrice Figureau2009-08-016-579/+600
| | | | | | | | | This patch uses the unused AST::HostName as the only way to reference a node in the AST nodes array. The AST::HostName respect the hash properties of the underlying string, to keep the O(1) hash properties. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Enhance selector and case statements to match with regexpBrice Figureau2009-08-015-617/+652
| | | | | | | | | | | | | | | | | | | | | | | | | The case and selector statements define ephemeral vars, like 'if'. Usage: case statement: $var = "foobar" case $var { "foo": { notify { "got a foo": } } /(.*)bar$/: { notify{ "hey we got a $1": } } } and for selector: $val = $test ? { /^match.*$/ => "matched", default => "default" } Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #2033 - Allow regexp in if expressionBrice Figureau2009-08-015-635/+692
| | | | | | | | | | | | | | | | | | | This changeset introduces regexp in if expression with the use of the =~ (match) and !~ (not match) operator. Usage: if $uname =~ /Linux|Debian/ { ... } Moreover this patch creates ephemeral variables ($0 to $9) in the current scope which contains the regex captures: if $uname =~ /(Linux|Debian)/ { notice("this is a $1 system") } Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>