summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
Commit message (Collapse)AuthorAgeFilesLines
...
* Functions are added to a module instead of ScopeLuke Kanies2010-02-172-3/+22
| | | | | | | | | | | | | | | | | We were previously adding them directly to Scope, but now they're in a module that Scope includes. This is the first half of #1175 - we can now maintain environment-specific collections of functions. We need some way of tracking which environment a given function is loaded from. Well, maybe it's the first third - the core functions probably need to be added to all of these modules, or there needs to be a 'common' module that is included by all of them. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Slightly restructuring "Functions" fileLuke Kanies2010-02-171-7/+4
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* [#3921] Remove unnecessary require 'puppet/resource'Rein Henrichs2010-02-172-2/+0
| | | | | | * Remove require statements * explicity define namespace modules/classes for Puppet::Resource::Status to avoid require dependency cycle.
* Fix for 3664: interpolating qualified variables.Markus Roberts2010-02-171-9/+9
| | | | | | | | | | "${myclass::var}" was lexed as a CLASSNAME instead of a VARIABLE token, giving an error while parsing because a rvalue can't be a bare CLASSNAME token. This commit (based of Brice's) fixes it by restricting the contexts in which the CLASSNAME and CLASSREF tokens are acceptable, analagous with the handling for NAME tokens.
* Fix #3664 - qualified variable parsing in string interpolationBrice Figureau2010-02-171-4/+6
| | | | | | | | | | | "${myclass::var}" was lexed as a CLASSNAME instead of a VARIABLE token, giving an error while parsing because a rvalue can't be a bare CLASSNAME token. This patch fixes the issue by making VARIABLE lexing higher priority than CLASSNAME. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixing #2658 - adding backward compatibility for 0.24Luke Kanies2010-02-171-3/+5
| | | | | | | | | | | | | The way stages were implemented caused backward compatibility to be completely broken for 0.24.x. This commit fixes that, mostly by assuming Stage[main] will be the top node in the graph rather than Class[main]. Other stages are not supported in 0.24.x, and explicitly throw a warning (although not an error). Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Adding #2658 - Adding support for run stagesLuke Kanies2010-02-172-16/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | This allows you to specify a run stage for either a class or a resource. By default, all classes get directly added to the 'main' stage. You can create new stages as resources: stage { [pre, post]: } To order stages, use standard relationships: stage { pre: before => Stage[main] } Or use the new relationship syntax: stage { pre: } -> Stage[main] -> stage { post: } Then use the new class parameters to specify a stage: class { foo: stage => pre } If you set a stage on an individual resource, it will fail; stages can only be set on class resources. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Fixing #1903 - metaparam inheritance is much fasterLuke Kanies2010-02-172-18/+46
| | | | | | | | | | | | This doesn't actually fix the specific request in #1903, which said there should be no inheritance at all, but I've changed my mind on that. Static inheritance is good, it should just be faster. This change could result in up to 70% speed improvements in compiling. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Fixing Parser::Resource param validationLuke Kanies2010-02-171-1/+1
| | | | | | It was previously not allowing false values. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Fixing #448 - relationships have their own syntaxLuke Kanies2010-02-177-1760/+1845
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Updated Template documentation linkJames Turnbull2010-02-171-3/+3
|
* Fixing #3668 - fixed autoloading classes from modulesLuke Kanies2010-02-174-868/+872
| | | | | | | | | | | This involved essentially moving all of the importing and loading code out of the Parser and into a new 'TypeLoader' class. The parser and the ResourceTypeCollection classes now delegate to that class for all file handling. Most of the code paths are also now much cleaner, and a bit of redundancy was removed. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Fix to the fix for #3295Markus Roberts2010-02-171-6/+2
| | | | | | The output variable in the inner block wasn't visible in the outer block, and wasn't needed in any case, since the results are returned naturally if you just leave everything alone.
* Fix for #3558 -- source file reading speedupMarkus Roberts2010-02-171-7/+1
| | | | | | It's about 10x faster to read the whole file than to read each line and concatenate them (actually, it's O(n) vs. O(n^2), so the exact speedup depends on the file size).
* Fix for #3556 Plussignment value meldingMarkus Roberts2010-02-171-4/+10
| | | | | | | | | | | | | | The plussignment operator was constructing the new parameter value by modifying the param object's value in place (so as to preserve the file and line information for debugging). However, when multiple resources are overridden by the same plussignment this would result in all of the resources sharing the same value (the union of all the prior values and the new value), which is wrong. Instead, we need to give each resource its own copy of the value (e.g., a copy of the param object), which this patch implements. Signed-off-by: Markus Roberts <Markus@reality.com>
* Fixes #3295 - generate() now sets the working directory to the directory ↵Paul Lathrop2010-02-171-2/+4
| | | | | | containing the specified command. Also adds rspec tests for generate().
* Fix #3155 - prevent error when using two matching regex in cascadeBrice Figureau2010-02-174-12/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following manifest: case $var { /match/: { if $var =~ /matchagain/ { } } } is failing because the "=~" operators when matching sets an ephemeral variable in the scope. But the case regex also did it, and since they both belong to the same scope, and Puppet variables are immutables, the scope raises an error. This patch fixes this issue by adding to the current scope a stack of ephemeral symbol tables. Each new match operator or case/selector with regex adds a new scope. When we get out of the case/if/selector structure the scope is reset to the ephemeral level we were when entering it. This way the following manifest produces the correct output: case $var { /match(rematch)/: { notice("1. \$0 = $0, \$1 = $1") if $var =~ /matchagain/ { notice("2. \$0 = $0, \$1 = $1") } notice("3. \$0 = $0, \$1 = $1") } } notice("4. \$0 = $0") And the output is: 1. $0 = match, $1 = rematch 2. $0 = matchagain, $1 = rematch 3. $0 = match, $1 = rematch 4. $0 = Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixed link typoJames Turnbull2010-04-221-1/+1
|
* Fixed #3384 - Updated broken linkJames Turnbull2010-04-221-3/+3
|
* Fixing Hash functionality with non-constant keysLuke Kanies2010-04-121-1/+2
| | | | | | | It was only apparently working with constant keys, not, say, AST strings. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Removing vistigial method in ASTHashLuke Kanies2010-04-121-3/+0
| | | | Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Markus's patch concerning string interpolationJesse Wolfe2010-04-123-1674/+1759
| | | | | | | | | | | From email: Some of the errors I needed to track down were actually coming from my string interpolation branch: * I wasn't handling "Foo ${1} bar" as a regexp back reference (and I don't like it, but hey) * I wasn't warning about & passing on the "unneeded" backslash in strings like 'foo\"bar' * I fumbled part of the conflict resolution with Brice's hash patch.
* Removing any mentions of :casesensitive settingLuke Kanies2010-04-093-9/+7
| | | | | | | | | | | | | | | | | It is a setting that was added years ago as a backward compatibility option and even if it still works, which is questionable, it has no purpose any longer. It just complicated the code and didn't do much, so it's gone now. Also simplified the interface of Leaf#evaluate_match, since it was now using none of the passed-in options. Finally, removed/migrated the last of the Selector/CaseStatement test/unit tests. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Adding environment support to parser resourcesLuke Kanies2010-02-171-0/+2
| | | | | | We just use the scope's environment. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Resolving conflicts with ???Markus Roberts2010-02-171-3/+2
| | | | | Brice's hash implementation introduces new occurances of SQTEXT/DQTEXT which, with string interpolation, should simply be STRING.
* Moving the string interpolation parsing to the parser/lexerMarkus Roberts2010-02-174-1134/+1232
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch moves the syntactic aspects of string interpolation up into the lexer/parser phase, preparatory to moving the semantic portions down to the as yet unnamed futures resolution phase. This is an enabling move, designed to allow: * Futures resolution in and between interpolated strings * Interpolation of hash elements into strings * Removal of certain order-dependent paths * Further modularization of the lexer/parser The key change is switching from viewing strings with interpolation as single lexical entities (which await later special case processing) to viewing them as formulas for constructing strings, with the internal structure of the string exposed by the parser. Thus a string like: "Hello $name, are you enjoying ${language_feature}?" internally becomes something like: concat("Hello ",$name,", are you enjoying ",$language_feature,"?") where "concat" is an internal string concatenation function. A few test cases to show the user observable effects of this change: notice("string with ${'a nested single quoted string'} inside it.") $v2 = 3+4 notice("string with ${['an array ',3,'+',4,'=',$v2]} in it.") notice("string with ${(3+5)/4} nested math ops in it.") ...and so forth. The key changes in the internals are: * Unification of SQTEXT and DQTEXT into a new token type STRING (since nothing past the lexer cares about the distinction. * Creation of several new token types to represent the components of an interpolated string: DQPRE The initial portion of an interpolated string DQMID The portion of a string betwixt two interpolations DQPOST The final portion of an interpolated string DQCONT The as-yet-unlexed portion after an interpolation Thus, in the example above (phantom curly braces added for clarity), DQPRE "Hello ${ DQMID }, are you enjoying ${ DQPOST }?" DQCONT is a bookkeeping token and is never generated. * Creation of a DOLLAR_VAR token to strip the "$" off of variables with explicit dollar signs, so that the VARIABLEs produced from things like "Test ${x}" (where the "$" has already been consumed) do not fail for want of a "$" * Reworking the grammar rules in the obvious way * Introduction of a "concatenation" AST node type (which will be going away in a subsequent refactor). Note finally that this is a component of a set of interrelated refactors, and some of the changes around the edges of the above will only makes sense in context of the other parts.
* Finishing renaming :params to :parameters internallyLuke Kanies2010-02-177-22/+22
| | | | | | | | | | | | I had only done this partway, because it seemed easier, but not surprisingly, it ended up being more complex. In addition to those renames, this commit includes fixes to whatever tests I needed to fix to confirm that things were again working. I think most of these broken tests have been broken for a while. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Converging the Resource classes furtherLuke Kanies2010-02-172-47/+19
| | | | | | | | | | | I was using 'params' and 'parameters', so I fixed that and extracted the differences in how they handle parameters into a stubbable method. This allowed me to almost entirely remove the subclass's 'initialize' method. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding strictness checking to resourcesLuke Kanies2010-02-172-4/+9
| | | | | | | This is used for AST resources (and fixed the last of the tests I broke in spec/). Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Fixing most of the broken tests in test/Luke Kanies2010-02-172-5/+5
| | | | | | | | This involves a bit of refactoring in the rest of the code to make it all work, but most of the changes are fixing or removing old tests. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Removing Resource::Reference classesLuke Kanies2010-02-1711-296/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Adding support for class parametersLuke Kanies2010-02-172-10/+4
| | | | | | | | | This is functional syntactically but not yet through the whole system, because of the changes made to how resource types are managed. See the next commit for that fix. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* TypeCollection now supports namespace arraysLuke Kanies2010-02-171-12/+3
| | | | | | | | | We previously only supported a single namespace when searching for resource types et al, but the whole system actually relies on an array of namespaces and search paths, so this adds that functionality all the way down, as it were. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding parameter validation to Puppet::ResourceLuke Kanies2010-02-171-1/+1
| | | | | | | | | | | | | This will allow us to remove all of the parameter validation from the other Resource classes. This is possible because resource types defined in the language are visible outside of the parser, via the environment. This will enable lots of code removal and simplication. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Partially fixing #2954 - Adding class parametersLuke Kanies2010-02-172-691/+668
| | | | | | | | This isn't 100% functional yet - I need to refactor some of the internals to make the class lookup work everywhere. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Fix #3229 - use original value in case/selector regex matchingBrice Figureau2010-02-173-9/+5
| | | | | | | | | | | | | | | | | | | | | | | The issue is that case/selectors are downcasing the value before it is compared to the options. Unfortunately regex are matching in a case sensitive way, which would make the following manifest fail: $var = "CaseSensitive" case $var { /CaseSensitive/: { notice("worked") } default: { fail "miserably" } } This patch fixes the issue by making sure the regexp match is done one the original (not downcased) value, but still doing a case sensitive match. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Renaming Parser::ResourceType to Resource::TypeLuke Kanies2010-02-177-440/+14
| | | | | | | | | | 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-174-73/+9
| | | | | | | 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-177-35/+40
| | | | | | | | | 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>
* Fixing callers to Parser to only pass environmentLuke Kanies2010-02-171-3/+1
| | | | | | | We previously passed a hash of options but now just the environment. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Using the RTC helper to find the known resource typesLuke Kanies2010-02-171-14/+13
| | | | | | | | | | We previously defined the method statically. This also renames the method to match how the environment thinks of them - known resource types, rather than resource type collection. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding helper module for finding known resource typesLuke Kanies2010-02-171-0/+5
| | | | | | | This is so everyone doesn't have to define the same method everywhere. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Moving Rails initialization to Compiler terminusLuke Kanies2010-02-171-15/+1
| | | | | | | It was previously handled by the Interpreter, but we're planning on getting of that. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Parser now uses Environment resource type collectionLuke Kanies2010-02-171-29/+23
| | | | | | | | | This is the last step enabling us to make it so no one needs to maintain these references to the parser. Instead, everyone will just get access to the type collection from the Environment. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding 'known_resource_types' to EnvironmentLuke Kanies2010-02-171-14/+46
| | | | | | | Each environment now has its own known collection of resource types, and it is responsible for caching as necessary. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Renaming LoadedCode to ResourceTypeCollectionLuke Kanies2010-02-172-12/+28
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Storing per-environment LoadedCode instancesLuke Kanies2010-02-171-1/+1
| | | | | | | | | | | | This will soon replace all of the env/parser mungling we have to do. A given process will only be able to have one collection of code per environment in memory. This is somewhat limiting, in theory, but some global means of looking up code collection (LoadedCode instances) must exist for the pure ruby stuff to work. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding support for parsing ruby filesLuke Kanies2010-02-171-2/+8
| | | | | | | This doesn't work without the later commits - it just relies on Ruby to read in Ruby files. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding []/[]= support to Parser::ResourceLuke Kanies2010-02-171-0/+4
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Fixing "require" function to use new class interfaceLuke Kanies2010-02-171-1/+1
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>