summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/compiler.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fixing #448 - relationships have their own syntaxLuke Kanies2010-02-171-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | You can now specify relationships directly in the language: File[/foo] -> Service[bar] Specifies a normal dependency while: File[/foo] ~> Service[bar] Specifies a subscription. You can also do relationship chaining, specifying multiple relationships on a single line: File[/foo] -> Package[baz] -> Service[bar] Note that while it's confusing, you don't have to have all of the arrows be the same direction: File[/foo] -> Service[bar] <~ Package[baz] This can provide some succinctness at the cost of readability. You can also specify full resources, rather than just resource refs: file { "/foo": ensure => present } -> package { bar: ensure => installed } But wait! There's more! You can also specify a subscription on either side of the relationship marker: yumrepo { foo: .... } package { bar: provider => yum, ... } Yumrepo <| |> -> Package <| provider == yum |> This, finally, provides easy many to many relationships in Puppet, but it also opens the door to massive dependency cycles. This last feature is a very powerful stick, and you can considerably hurt yourself with it. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Removing Resource::Reference classesLuke Kanies2010-02-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is hopefully less messy than it first appears, but it's certainly cross-cutting. The reason for all of this is that we previously only looked up builtin resource types from outside the parser, but now that the defined resource types are available globally via environments, we can push that lookup code to Resource. Once we do that, however, we have to have environment and namespace information in every resource. Here I remove the Resource::Reference classes (except the AST class), and use Resource instances instead. I did this because the shared code between the two classes got incredibly complicated, such that they should have had a hierarchical relationship disallowed by their constants. This complexity convinced me just to get rid of References entirely. I also make Puppet::Parser::Resource a subclass of Puppet::Resource. There are still broken tests in test/, but this was a big enough commit I wanted to get it in. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Renaming Parser::ResourceType to Resource::TypeLuke Kanies2010-02-171-3/+3
| | | | | | | | | | Basically, these classes (ResourceType and ResourceTypeCollection) don't really belong in Parser, so I'm moving them to the Resource namespace. This will be where anything RAL-related goes from now on, and as we migrate functionality out of Puppet::Type, it should go here. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Removing Interpreter classLuke Kanies2010-02-171-0/+7
| | | | | | | It's no longer necessary, given the new ResourceTypeCollection class. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* All non-transient parser references are goneLuke Kanies2010-02-171-14/+12
| | | | | | | | | We now use references to the ResourceTypeCollection instances through the environment, which is much cleaner. The next step is to remove the Interpreter class. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Move scope parenting & class_scope from Compiler to ScopeMarkus Roberts2010-02-171-46/+6
| | | | | | | | | | | | | | | | 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.
* Fixing #2596 - Node, Class, Definition are not ASTLuke Kanies2009-12-091-4/+4
| | | | | | | | | | | | | | | | | 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>
* 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>
* 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>
* Fixing #2423 - no more strange dependency cyclesLuke Kanies2009-07-251-1/+5
| | | | | | | | | | | | | | | We were getting strange dependency cycles because our class structure mirrored our scope structure. We can't change the scope structure without switching from a dynamically scoped language to a lexically scoped language, which is too big of a change to make right now. Instead, I'm changing the resource graph so that all classes default to just having an edge to the 'main' graph. This will be a behaviour change for many, in that you were getting automatic dependencies from this old behaviour, but it will bring consistency. Signed-off-by: Luke Kanies <luke@madstop.com>
* Switching to LoadedCode from ASTSetLuke Kanies2009-07-051-5/+5
| | | | | | | | 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>
* Switching to Indirected ActiveRecordLuke Kanies2009-04-221-37/+0
| | | | | | | | | | | This is mostly a configuration change, with some code getting removed. Also adding an extra require in Format; Puppet::Provider requires Puppet::Provider::Confiner, so the constant lookup is weird. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fix #1933 - Inconsistent resource evaluation order in subsequent evaluation runsBrice Figureau2009-02-141-9/+10
| | | | | | | | | | | | | While evaluating the AST, catalog vertices are not always ordered the same way on different run, leading to some tags (which should have been applied in evaluation order) to not be associated with some underlying resources. This changeset change all accesses to resources inside the compiler to always use an ordered (in evaluation order) list of added resources. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Renaming Puppet::Node::Catalog to Puppet::Resource::CatalogLuke Kanies2008-12-181-2/+2
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Fixing an error message to be more clearLuke Kanies2008-05-011-1/+1
|
* Always duplicating resource defaults in the parser, so thatLuke Kanies2008-03-061-1/+0
| | | | | | stacked metaparameter values do not result in all resources that receive a given default also getting those stacked values.
* Fixing #1092 by no longer using the resource reference toLuke Kanies2008-02-281-3/+2
| | | | | | look resources up, which means there's no concern about not finding the resource, which is where the nil was coming from. We now just iterate over the vertices.
* Merge commit 'bartv/pending/fix-997' into 0.24.xLuke Kanies2008-02-121-2/+6
|
* Moving the ast node tests to rspec (which I could haveLuke Kanies2008-02-121-2/+3
| | | | | | | *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.
* Removing the last remaining vestiges of GRATR --Luke Kanies2008-02-111-3/+3
| | | | removing the bangs from 'add_vertex!' and 'add_edge!'.
* Changing the name of the Compile class to Compiler,Luke Kanies2008-02-111-0/+467
since it's stupid to have a class named after a verb.