summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
Commit message (Collapse)AuthorAgeFilesLines
* Fix #1829 - Add puppet function versioncmp to compare versionsBrice Figureau2009-03-241-0/+10
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1828 - Scope.number? wasn't strict enough and could produce wrong resultsBrice Figureau2009-03-141-3/+3
| | | | | | | Some invalid numbers were treated as numbers and conversion to Integer was failing returning 0 (for instance 0.24.7). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Using the FileCollection where appropriate.Luke Kanies2009-02-286-8/+19
| | | | | | | | | | | | | This commit just replaces the :file and :line accessors with the use of the new FileCollection Lookup module. This should mean that we've normalized all file names in a given process, which *might* have drastic RAM improvements. For initial simplicity, I've gone with a single global collection of file names, but it's built so it's easy to use individual file collections instead. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fixed #1831 - Added sprintf functionJames Turnbull2009-02-141-0/+17
|
* Fixed #1830 - Added regsubst functionJames Turnbull2009-02-141-0/+93
|
* Fixed #1884 - exported defines are collected by the exporting hostLuke Kanies2009-02-112-4/+2
| | | | | | | | | | | | | | | | | | This was caused by the fix to #1472. That fix unexported any resources collected from the local catalog. The crux of this fix is that it separates 'exported' and 'virtual' a bit more. It also removes no-longer-needed functionality where resources copied their virtual or exported bits from the enclosing define or class. This is now obsolete because we don't evaluate virtual defined resources. The crux of this commit is that defined resources can stay exported even though they're evaluated, and that exported state won't inherit to contained resources such that those then don't get evaluated. Signed-off-by: Luke Kanies <luke@madstop.com>
* Cleaning up the AST::Resource code a bitLuke Kanies2009-02-101-20/+21
| | | | | | | | | | | Mostly renaming 'obj' to 'resource', since the whole 'obj' thing is a holdover from before we had the term 'resource'. Also pulling a bit of code out of a loop, since it didn't need to be there. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fix #1691 - Realize fails with array of Resource ReferencesBrice Figureau2009-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following snippet: realize( File["/tmp/a","/tmp/b"] ) is parsed into: AST::Function @name=realize @arguments= AST::ASTArray @children = [ AST::ResourceReference @title= AST::ASTArray @children = [ String(/tmp/a), String(/tmp/b) ] ] When evaluated: ResourceReference gives -> [ File[/tmp/a], File[/tmp/b] ] which means the function arguments are: [[File[/tmp/a], File[/tmp/b]] after evaluating the @arguments ASTArray of AST::Functions. Then the collector complains that it can't find the resource because it is not supposed to work on non-flattened resource array. The fix is to flatten in the realize function (although it can be done more generally in the AST::Function evaluation) before the resources are given to the Collector. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1682 - Resource titles are not flattened as they shouldBrice Figureau2009-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following manifest: $groups = ["foo", "bar"] $type_groups = ["baz", "quux"] $user_groups = [$groups, $type_groups] notify{ $user_groups: } which outputs: notice: foo notice: //Notify[foobar]/message: defined 'message' as 'foo' notice: baz notice: //Notify[bazquux]/message: defined 'message' as 'baz' is not equivalent to $user_groups = [ ["foo", "bar"], ["baz", "quux"] ] notify{ $user_groups: } which outputs: notice: foo notice: //Notify[foo]/message: defined 'message' as 'foo' notice: baz notice: //Notify[baz]/message: defined 'message' as 'baz' notice: bar notice: //Notify[bar]/message: defined 'message' as 'bar' notice: quux notice: //Notify[quux]/message: defined 'message' as 'quux' Obviously the second one manages to flatten the arrays and not the first one. This changeset adds flattening to the resource titles evaluations in order to be consitent in all cases. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1922 - Functions squash all arguments into a single hashBrice Figureau2009-02-111-1/+2
| | | | | | | | Revert "Fix #1682 - ASTArray should flatten product of evaluation of its children" This reverts commit c7ccc4ba7c42d56595564491ae578a1604c628d1. Bug #1824 and #1922 proved the fix for #1682 and #1691 was wrong. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Change the way the tags and params are handled in railsBrice Figureau2009-02-062-18/+17
| | | | | | | | | | | | | The rationale behind this patch is that it takes a lots of time to let rails unserialize the ParamValue and ResourceTag object on each compilation, just to throw them away the second after. The idea is to fetch directly (and batched host per host) the parameters and tags from the database and then returns them as hash. This allows the no-modification case to takes at least 2 times less than before. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1741 - Add inline_template functionBrice Figureau2008-11-291-0/+21
|
* Fix #1741 - refactor TemplateWrapper, test for template functionBrice Figureau2008-11-292-24/+33
|
* Fix #1741 - Puppet::Parser::Functions rmfunctions and unit testBrice Figureau2008-11-291-0/+14
|
* Fixing #1755 - handling fully qualified classes correctly.Luke Kanies2008-11-262-4/+5
| | | | | | | This involves lexing '::class' tokens along with correctly looking them up from the Resource::Reference class. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fix #1759 - Comparison operator was using string comparison for numbersBrice Figureau2008-11-201-0/+4
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Move function existance test to parser evaluationBrice Figureau2008-11-171-12/+16
| | | | | | | | The aim is to let --parseonly succeeds even if the function is not (yet) present. This is usefull in commit-hooks and for the inline documentation generation system. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Add a doc attribute to AST nodes and fill it with the last seen commentsBrice Figureau2008-11-1717-111/+252
| | | | | | | | | | | | | The lexer maintains a stack of last seen comments. On blank lines the lexer flush the comments. On each opening brace the lexer enters a new stack level. On each block AST nodes, the stack is popped. Each AST nodes has a doc property that is filled with the last seen comments on node creation (in fact only on important node creation representing statements). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1402 - Allow multiline commentsBrice Figureau2008-10-291-0/+5
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #857 - Multiple class of the same name don't append codeBrice Figureau2008-10-291-1/+5
| | | | | | | | | | | | | | | | | | | | The following manifest wasn't working: class one { notice('class one') } class one { notice('second class one') } include one It all boiled down to class code not being arrays. Encapsulating code in ASTArray when needed is enough to append code, because of the property of ASTArray to evaluate all their members in turn. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1682 - ASTArray should flatten product of evaluation of its childrenBrice Figureau2008-10-291-2/+1
| | | | | If the ASTArray contains children that evaluate to arrays themselves, they aren't flattened.
* Fixed #1104 - Classes and nodes should set $name variablesBrice Figureau2008-10-281-1/+6
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixes #1663 - added Symbol check and additional testSean E. Millichamp2008-10-231-1/+5
|
* Fix #936 - Allow trailing comma in array definitionBrice Figureau2008-10-212-388/+393
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1115 - part2 - fix tests and add all_tagsBrice Figureau2008-10-211-1/+6
| | | | | | | | Up until this patch, TemplateWrapper.tags was returning all the tags defined in the catalog. I think this is wrong and tags shoul only return the defined tags in the current scope. Hence, I defined a all_tags method that returns the list of tags defined in the whole catalog.
* Fixed #1663 - Regression relating to facter fact naming from 0.24.5James Turnbull2008-10-211-1/+2
|
* Fix #636 - Allow extraneous comma in function argument listBrice Figureau2008-10-212-882/+898
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1115 - Allow checking tags/classes from ERb templatesBrice Figureau2008-10-141-0/+10
| | | | | | | | Add to predefined variables to the ERB template space. "classes" and "tags" which provide arrays of all the defined classes and tags for a node. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1202 - Collection attribute matching doesn't parse arraysBrice Figureau2008-10-081-1/+6
| | | | | | | | | | | | This patch allows to do this: User <| groups == leads |> @user { "foo": ensure => "present", groups => ["bar","baz","leads"] } Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1109 - allow empty if or else branchesBrice Figureau2008-10-074-563/+637
| | | | | | | | | | | | This changesets allow empty if or else branches: if true { } else { } It works by emitting on the parser stack an AST node that doesn't do anything (a no-op). This allows the less intrusive code as no part of the if evaluation code has been touched.
* Fix #381 - Allow multiple resource overrides or referencesBrice Figureau2008-10-054-390/+383
| | | | | | | | | | | | | | | | | | | | | | | Allow this syntax: Resource[title1,title2] { param => value } as a compact form of Resource[title1] { param => value } Resource[title2] { param => value } This patch also introduces for free the possibility to group class references by type: exec { test: require => File["file1","file2","File3"] } which is completely equivalent to: exec { test: require => [ File["file1"],File["file2"],File["File3"] ] }
* Fixing #1098 - Multiline strings now correctly increment the line countLuke Kanies2008-10-041-0/+3
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Add parser for arbitrary expressionsBrice Figureau2008-10-013-645/+1020
| | | | | | | | | | | | | | | | The expressions can be used in if 'test' and in the right side of assignements. The expressions can contain any number of sub-expressions combined by either arithmetic operators, comparison operators, or boolean operators. Random Usage Examples: $result = ((( $two + 2) / $one) + 4 * 5.45) - (6 << 7) + (0x800 + -9) or if ($a < 10) and ($a + 10 != 200) { ... }
* Add arithmetic operators to ASTBrice Figureau2008-09-304-0/+89
| | | | | This changeset adds +,-,/,*,<< and >> computation and AST parse nodes.
* Add not operator to ASTBrice Figureau2008-09-302-0/+20
|
* Add comparison operators (< > == != <= >=) to ASTBrice Figureau2008-09-302-0/+38
|
* Add boolean operators to ASTBrice Figureau2008-09-302-0/+49
|
* Fixed #1472 -- defined, exported resources in the current compile now get ↵Luke Kanies2008-09-251-1/+2
| | | | | | | | | expanded correctly. This was working for defined resources in the db, but not in the current compile. I just had to mark the resources as non-exported.
* Fixed #1045 - Multiple metaparams all get added to resources.Luke Kanies2008-09-241-1/+1
| | | | | | | The problem was that I was using a 'return' in a loop where I should have been using a 'next'. Signed-off-by: Luke Kanies <luke@madstop.com>
* Add an append (+=) variable operator:Brice Figureau2008-09-215-716/+760
| | | | | | | | | | | | | | | | | | | The append variable operator can be used to append something to a variable defined in a parent scope, containing either a string or an array. The main use is to append array elements in classes to a variable globally defined in a node. Example: $ssh_users = ['brice', 'admin1'] class backup { $ssh_users += ['backup_operator'] ... } Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixed #1488 - Moved individual functions out of functions.rb intoJames Turnbull2008-08-2613-217/+208
| | | | | the lib/puppet/parser/functions directory. New functions should be created in this directory.
* Fix leaking LoadedFile when adding templates to be watchedAndrew Shafer2008-08-231-13/+18
|
* Fix #1502 - abysmal storeconfig performance - part2Brice Figureau2008-08-171-2/+10
| | | | | | | | | | | | | | Resource parameters whose values are a resource reference (ie require, notify...) where always DELETEd/INSERTed because the code comparing resource reference compared object instances instead of their values (since Puppet::Parser::Resource::Reference doesn't override == ), leading to storeconfig performance issues. The correct fix would have been to define == in Puppet::Parser::Resource::Reference but that might introduce some side effects I don't know. Hence, the fix introduces a local compare() method that knows how to compare Puppet::Parser::Resource::Reference. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixes #1274 - allow class names to start with numbersJames Turnbull2008-08-171-1/+1
|
* Added tests for TemplateWrapper's use of Scope#to_hash.Luke Kanies2008-08-091-11/+10
| | | | | | We should deprecate the method_missing stuff in 0.25. Signed-off-by: Luke Kanies <luke@madstop.com>
* Expose all puppet variables as instance member variables of the template ↵Daniel Pittman2008-08-012-13/+59
| | | | | | | | | | | | | | | | | wrapper. This helps resolve redmine #1427, by providing a safe mechanism to access variables. * Implement Puppet::Parser::Scope#to_hash, which returns a hash containing all the variable bindings in the current and, optionally, parent scope. * Use that to set instance member variables into Puppet::Parser::Templatewrapper * Report the time taken for variable binding at debug level, to help identify any performance regression that is encountered in the real world. * Rename the @scope and @file members of the template wrapper, to avoid clashing with a scope variable exposed within puppet. Signed-off-by: Daniel Pittman <daniel@rimspace.net> (cherry picked from commit ba220b41e4f509f2632e2664d332e49b20a70ea7)
* Fixed #1396 - Added sha1 function from DavidS to coreJames Turnbull2008-07-082-1/+9
|
* Issue 1215Andrew Shafer2008-06-131-17/+2
| | | | | | Removed logic to reuse parser and log on server when there is a parsing error. Now we just make a new parser and if there is an error, raise it up, which will result in errors on the client logs.
* Fixing #1242 -- lack of storeconfigs only produces warning, not exception.Luke Kanies2008-05-263-6/+12
| | | | | Exporting or collecting resources no longer raises an exception when no storeconfigs is enabled, it just produces a warning.
* Put function in ticket #311 in correct locationJames Turnbull2008-05-241-0/+16
|