summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast
Commit message (Collapse)AuthorAgeFilesLines
* Switching to LoadedCode from ASTSetLuke Kanies2009-07-053-4/+4
| | | | | | | | I also took the opportunity to clean up and simplify the interface to the parts of the parser that interact with this. Mostly it was method renames. Signed-off-by: Luke Kanies <luke@madstop.com>
* Make sure virtual and rails query use tags when tag are searchedBrice Figureau2009-06-061-4/+11
| | | | | | | | | | | | Up to now, when trying to match with tags: File<<| tag == 'value' |>> in fact we were querying parameters. Hopefully all the user tags are stored in parameters so it was working. But it wasn't possible to search on auto-tags (like class name). This patch makes sure searching by tag is done on tags both on the rails side and the resource side. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #2246 - Array tagged resources can't be collected or exportedBrice Figureau2009-06-061-1/+1
| | | | | | | | | | | | I don't know why we imposed the restriction that we shouldn't match with parameter containing arrays in exported mode. That doesn't seem right, as the produced rails query works fine with arrays. Note: the user tags are not stored in the rails database except under the special resource parameter tag. This also doesn't seem right. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Removed extra whitespace from end of linesIan Taylor2009-06-069-12/+12
|
* Merge branch '0.24.x'Luke Kanies2009-04-022-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: bin/ralsh lib/puppet/executables/client/certhandler.rb lib/puppet/parser/functions/versioncmp.rb lib/puppet/parser/resource/reference.rb lib/puppet/provider/augeas/augeas.rb lib/puppet/provider/nameservice/directoryservice.rb lib/puppet/provider/ssh_authorized_key/parsed.rb lib/puppet/type.rb lib/puppet/type/file/checksum.rb spec/integration/defaults.rb spec/integration/transaction/report.rb spec/unit/executables/client/certhandler.rb spec/unit/indirector/ssl_rsa/file.rb spec/unit/node/catalog.rb spec/unit/provider/augeas/augeas.rb spec/unit/rails.rb spec/unit/type/ssh_authorized_key.rb spec/unit/type/tidy.rb test/executables/filebucket.rb test/executables/puppetbin.rb
| * Using the FileCollection where appropriate.Luke Kanies2009-02-282-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Fix #1088 - Collections overridesBrice Figureau2009-03-141-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset defines a new syntax to override collection of resources (virtual or not). This feature is not constrained to the override in inherited context as usual resource override. The collection of resource supports a query like regular collection of virtual or exported resources. Usage example: file { "/tmp/testing": content => "whatever" } File<| |> { mode => 0600 } It also introduces a different behaviour for collection of catalog resources. Before this patch, only virtual resources were collected, now all resources (virtual or no) are collected and can be overriden. That means it is now possible to do: File <| |> { mode => 0600 } And all the Files resources will have mode 0600. It is then possible to have this puppet pattern: file { "/tmp/a": content => "a" } file { "/tmp/b": content => "b" } File <| title != "/tmp/a" |> { require => File["/tmp/b"] } which means that every File requires a file. Moreover it is now possible to define resource overriding without respecting the override on inheritance rule: class a { file { "/tmp/testing": content => "whatever" } } class b { include a File<| |> { mode => 0600 } } include b Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* | Fixed #1849 - Ruby 1.9 portability: `when' doesn't like colons, replace with ↵James Turnbull2009-02-262-8/+8
| | | | | | | | semicolons
* | Merge branch '0.24.x'Luke Kanies2009-02-112-21/+22
|\| | | | | | | | | | | Conflicts: CHANGELOG spec/unit/type/file/selinux.rb
| * Fixed #1884 - exported defines are collected by the exporting hostLuke Kanies2009-02-111-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #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>
* | Renaming Puppet::ResourceReference to Puppet::Resource::ReferenceLuke Kanies2008-12-091-1/+1
|/ | | | 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-1712-0/+32
| | | | | | | | | | | | | 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 #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>
* 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-071-0/+11
| | | | | | | | | | | | 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-052-22/+33
| | | | | | | | | | | | | | | | | | | | | | | 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"] ] }
* Add arithmetic operators to ASTBrice Figureau2008-09-302-0/+64
| | | | | This changeset adds +,-,/,*,<< and >> computation and AST parse nodes.
* Add not operator to ASTBrice Figureau2008-09-301-0/+19
|
* Add comparison operators (< > == != <= >=) to ASTBrice Figureau2008-09-301-0/+37
|
* Add boolean operators to ASTBrice Figureau2008-09-301-0/+48
|
* Add an append (+=) variable operator:Brice Figureau2008-09-211-2/+2
| | | | | | | | | | | | | | | | | | | 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 #1396 - Added sha1 function from DavidS to coreJames Turnbull2008-07-081-1/+1
|
* Fixed #1047 -- Puppet's parser no longer changes the orderLuke Kanies2008-02-281-21/+3
| | | | | | in which statements are evaluated, which means that case statements can now set variables that are used by other variables.
* Fixing #1085, I think -- I was not returning a resourceLuke Kanies2008-02-252-4/+8
| | | | | | if the class had already been evaluated, but this was only being run into in corner cases -- mostly where one class included another class, I assume.
* Moving the ast node tests to rspec (which I could haveLuke Kanies2008-02-123-34/+15
| | | | | | | *sworn* I did this weekend). In the process, I fixed a couple of bugs related to differentiating between nodes and classes, and then cleaned up quite a few error messages.
* Changing the name of the Compile class to Compiler,Luke Kanies2008-02-116-9/+9
| | | | | since it's stupid to have a class named after a verb.
* Changing some methods in the Compile class toLuke Kanies2008-02-113-3/+3
| | | | | be more internally consistent (switched store_resource to add_resource, and store_override to add_override).
* Fixed #1030 - class and definition evaluation has been significantlyLuke Kanies2008-02-112-19/+26
| | | | | | refactored, fixing this problem and making the whole interplay between the classes, definitions, and nodes, and the Compile class much cleaner.
* More AST refactoring -- each of the code wrapping classesLuke Kanies2008-02-083-264/+249
| | | | | | | | | | | just returns a resource from its evaluate() method, and all of the work is done in the evaluate_code method. This makes the code cleaner, because it means 1) evaluate() has the same prototype as all of the other AST classes, 2) evaluate() is no longer called indirectly through the Parser Resource class, and 3) the classes themselves are responsible for creating the resources, rather than it being done in the Compile class.
* Refactoring the AST classes just a bit. I realized thatLuke Kanies2008-02-0820-106/+64
| | | | | | all of the evaluate() methods only ever accepted a scope, and sometimes one other option, so I switched them all to use named arguments instead of a hash.
* Renaming 'configuration' to 'catalog', fixing #954.Luke Kanies2007-12-111-1/+1
|
* Theoretically, this patch is to fix #917 (which it does), butLuke Kanies2007-11-281-1/+4
| | | | | | | | | | | | | | | | | | | there were enough problems fixing it that I decided something more drastic needed to be done. This uses the new Puppet::ResourceReference class to canonize what a resource reference looks like and how to retrieve resources via their references. Specifically, it guarantees that resource types are always capitalized, even when they include '::' in them. While many files are modified in this commit, the majority of changes are quite small, and most of the changes are fixing the tests to use capitalized types. As we look at consolidating some of our resource types, we could consolidate the ResourceReference stuff at the same time, but at least the Puppet::Parser::ResourceReference class subclasses the main Puppet::ResourceReference class.
* Fixing the first half of #917 -- the ResourcReferenceLuke Kanies2007-11-281-2/+2
| | | | | | AST code now correctly finds the resource. It's getting lost in the configuration translation, though, so I need to fix that, too.
* Fixing the error message as requested in #893.Luke Kanies2007-11-271-3/+1
|
* Fixing a parser test -- really, just removing testsLuke Kanies2007-11-132-1/+2
| | | | | | | | that belong with the AST classes rather than in the parser. Yeah, these tests need to be rewritten. Committed on an airplane. :)
* Removing the completely obsolete passwd2puppet and the obsolete component.rbLuke Kanies2007-09-131-224/+0
|
* Fixing #802 -- tags are now applied before parent classes are evaluated, so ↵Luke Kanies2007-09-061-1/+3
| | | | parent classes can use tagged() to test if a node is a member of a subclass.
* Renaming some ast resource classes and files so they make a lot more sense.Luke Kanies2007-09-065-6/+6
|
* Fixing #806. Resources correctly look up their fully qualified definition ↵Luke Kanies2007-09-062-17/+33
| | | | type, just like resource references do, which causes the resource and reference to again agree on the full name of a given defined type.
* Successfully modified all tests and code so that all language tests pass ↵Luke Kanies2007-09-042-8/+5
| | | | again. This is the majority of the work necessary to make the separate "configuration" object work.
* We now have a real configuration object, as a subclass of GRATR::Digraph, ↵Luke Kanies2007-09-0422-351/+41
| | | | that has a resource graph including resources for the container objects like classes and nodes. It is apparently functional, but I have not gone through all of the other tests to fix them yet. That is next.
* More refactoring. I have removed a few more extraneous methods from Scope, ↵Luke Kanies2007-09-034-13/+25
| | | | mostly just pointing directly to the compile, and I have begun (but commented out) the move to having resources to model each of the classes and nodes, in addition to the definitions. This will, again, enable a real Configuration object, and it will enable class versioning and similar features.
* Removing the Scope#setresource method, since it was essentially redundant. ↵Luke Kanies2007-09-031-3/+3
| | | | The work is done in either AST::ResourceDef#evaluate or Compile#store_resource.
* Doing a small amount of refactoring, toward being able to use Parser ↵Luke Kanies2007-09-033-78/+63
| | | | resources to evaluate classes and nodes, not just definitions. This will hopefully simplify some of the parsing work, and it will enable the use of a Configuration object that more completely models a configuration.