| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit unifies some paths in the grammar, which had previously been
duplicated to avoid shift/reduce conflicts. Merging these paths together and
separating only the conflicting structures leads to a cleaner grammar, with
fewer holes.
Several bugs are fixed as a result:
(#3129) Nested class names beginning with numbers work correctly
(#5268) Hyphens in class names work correctly
(#5817) Hashes and arrays can now be passed to functions (hashes require parentheses)
Additionally, expressions are now legal in most places where they would make
sense, when previously only bare rvalues were allowed.
Paired-With: Markus Roberts
Reviewed-By: Matt Robinson
|
|
|
|
|
|
| |
This has been removed in favor of 'puppet parser validate <manifest>'.
Paired-With: Jesse Wolfe
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This was a particularly nasty merge, so rather than hold up merges into
next any longer, I'm going to push this merge with a few outstanding
problems. The tests that were failing in the following areas have been
marked pending, and will be addressed separately, immediately following
this push.
TODO:
Verify that brice's rdoc change is still valid: tests to show that line
numbers from class, define and node get into the ast
Fix mount parsed_spec spec/unit/provider/mount/parsed_spec.rb
* 2.6.next: (85 commits)
(#5148) Fix failing spec due to timezone
(#5148) Add support for PSON to facts
(#6338) Remove inventory indirection, and move to facts indirection
(#6445) Fix inline docs: puppet agent does not accept --mkusers
Update CHANGELOG and version for 2.6.6rc1
(#6541) Fix content with checksum truncation bug
(#6418) Recursive files shouldn't be audited
(#6541) maint: whitespace cleanup on the file integration spec
(#6541) Fix content with checksum truncation bug
(#5466) Write specs for output of puppet resource
(#5466) Monkey patch Symbol so that you can sort them
(#5466) Fixed puppet resource bug with trailing ,
Update CHANGELOG for 2.6.5
(#4922) Don't truncate remotely-sourced files on 404
(#6338) Remove unused version control tags
Maint: Align tabs in a code block in the Augeas type.
(#6509) Inline docs: Fix erroneous code block in directoryservice provider for computer type
Maint: Rewrite comments about symlinks to reflect best practice.
(#6509) Inline docs: Fix broken lists in Launchd provider.
(#6509) Inline docs: Fix broken code blocks in zpool type
...
Manually Resolved Conflicts:
lib/puppet/application/inspect.rb
lib/puppet/defaults.rb
lib/puppet/file_bucket/dipper.rb
lib/puppet/network/http/handler.rb
lib/puppet/node/facts.rb
lib/puppet/parser/parser.rb
lib/puppet/parser/parser_support.rb
lib/puppet/util/command_line/puppet
lib/puppet/util/command_line/puppetd
lib/puppet/util/command_line/puppetmasterd
lib/puppet/util/monkey_patches.rb
lib/puppet/util/rdoc/parser.rb
spec/unit/application/agent_spec.rb
spec/unit/file_bucket/file_spec.rb
spec/unit/indirector/file_bucket_file/file_spec.rb
spec/unit/network/http/handler_spec.rb
spec/unit/parser/parser_spec.rb
spec/unit/provider/mount/parsed_spec.rb
|
| |
| |
| |
| |
| |
| |
| |
| | |
This reverts commit e3c59df2b246fe5e764272f21b631a5d2f28687f.
This commit is being reverted because the solution is incomplete, and a better
solution is out of scope for this release. A more complete solution will be
implemented in the future.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function(-1) was failing because the grammar wasn't allowing negated values in
function calls. This fix makes the negation of any value which was previously
legal as a function argument also now legal as a function argument.
Paired-With: Max Martin
Paired-With: Markus Roberts
|
| |\
| | |
| | |
| | | |
parser.rb manually rebuilt to resolve global grammer chances.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The following manifest was failing:
$hash = { 'a' => { 'b' => { 'c' => 'it works' } } }
$out = $hash['a']['b']['c']
because of a typo in the grammar.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
| | |
| | |
| | |
| | |
| | | |
The automatically generated parser.rb needed to be rebuilt to make the syntax
changes functional; this commits only that rebuild.
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The following manifest was producing a parse error:
$int = { 'eth0' => 'bla' }
$foo = $int['eth0'] ? {
'bla' => 'foo',
default => 'bleh'
}
because selectors didn't support hash access.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | | |
Conflicts resolved manually, by Paul Berry:
lib/puppet/parser/ast/astarray.rb
lib/puppet/parser/grammar.ra
lib/puppet/parser/parser.rb (by rebuilding from grammar.ra)
|
| | |
| | |
| | |
| | |
| | | |
or node occurs in a conditional construct so that it contains the
proper line number.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously, ASTArray#evaluate() was responsible for checking whether
the user had tried to declare a class, define, or node in a prohibited
location (such as a conditional construct). This meant that errors
would only be reported to the user if the conditional code was
actually evaluated.
Moved the checking into the parser, so that errors are always
reported.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Changed the grammar so that the following "plural" constructs always
parse as an ASTArray:
- funcvalues
- rvalues
- resourceinstances
- anyparams
- params
- caseopts
- casevalues
And the following "singluar" construct never parses as an ASTArray:
- statement
The previous behavior was for these constructs to parse as a scalar
when they represented a single item and an ASTArray when they
contained zero or multiple items. ("Statement" could sometimes
represent a single item because a single resource declaration could
represent multiple resources). This complicated other grammar rules
and caused ambiguous handling of nested arrays.
Also made these changes to the AST class hierarchy:
- ResourceInstance no longer derives from ASTArray. This relationship
was not meaningful because a ResourceInstance is a (title,
parameters) pair, not an array, and it produced complications when
we wanted to represent an array of ResourceInstance objects.
- Resource no longer derives from ResourceReference. No significant
functionality was being inherited and the relationship doesn't make
sense in an AST context.
- ResourceOverride no longer derives from Resource. No significant
functionality was being inherited and the relationship doesn't make
sense in an AST context.
- Resource can now represent a compound resource instance such as
"notify { foo: ; bar: }". This saves the parser from having to
use represent a statement as an array of objects.
- ASTArray's evaluate method never flattens out arrays of arrays.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
definitions (classes, definitions, and nodes).
Previously, type definitions were not represented directly in the AST.
Instead, the parser would instantiate types and insert them into
known_resource_types as soon as they were parsed. This made it
difficult to distinguish which types had come from the file that was
just parsed and which types had been loaded previously, which led to
bug 4496.
A side-effect of this change is that the user is no longer allowed to
define types inside of conditional constructs (such as if/else). This
was allowed before but had unexpected semantics (bugs 4521 and 4522).
It is still possible, however, to place an "include" statement inside
a conditional construct, and have that "include" statement trigger the
autoloading of a file that instantiates types.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This operator allows to find if the left operand is in the right one.
The left operand must be resort to a string, but the right operand can be:
* a string
* an array
* a hash (the search is done on the keys)
This syntax can be used in any place where an expression is supported.
Syntax:
$eatme = 'eat'
if $eatme in ['ate', 'eat'] {
...
}
$value = 'beat generation'
if 'eat' in $value {
notice("on the road")
}
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|
|
|
|
| |
Puppetdoc got confused because it wasn't popping the comment context for
collections and resource defaults. This commit adds the popping.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
It's no longer necessary, given the new ResourceTypeCollection
class.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>]
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
Add a regex rule (unused for the moment) to the parser.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|
|
|
| |
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Careful inspection of the parser code show that when we
associate a source line number for an AST node, we use the
current line number of the currently lexed token.
In many case, this is correct, but there are some cases where
this is incorrect.
Unfortunately due to how LALR parser works the ast node creation
of a statement can appear _after_ we lexed another token after
the current statement:
1. $foo = 1
2.
3. class test
When the parser asks for the class token, it can reduce the
assignement statement into the AST VarDef node, because no other
grammar rule match. Unfortunately we already lexed the class token
so we affect to the VarDef node the line number 3 instead of 1.
This is not a real issue for error reporting, but becomes a real
concern when we associate documentation comments to AST node for
puppetdoc.
The solution is to enhance the tokens lexed and returned to the parser
to carry their declaration line number.
Thus a token value becomes a hash: { :value => tokenvalue, :line }
Next, each time we create an AST node, we use the line number of
the correct token (ie the foo line number in the previous example).
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|
|
|
| |
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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"] ]
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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) {
...
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
Exporting or collecting resources no longer raises an exception
when no storeconfigs is enabled, it just produces a warning.
|
|
|
|
|
| |
including not compiling the configurations, and also storeconfigs
is no longer required during parse-testing.
|
| |
|
|
|
|
| |
lexer. Updated CLASSREF token regex in the lexer.
|
| |
|
| |
|
|
|
|
| |
piece to make this complete is to add multiple environment support to the fileserver. I also renamed Configuration.rb to Compile.rb (that is, I fixed all the classes that used to know it as a configuration).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refactored how the parser and interpreter relate,
so parsing is now effectively an atomic process (thus
fixing #314 and #729). This makes the interpreter less
prone to error and less prone to show the error to the
clients. Note that this means that if a configuration
fails to parse, then the previous, parseable configuration
will be used instead, so the client will not know that
the configuration failed to parse.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2742 980ebf18-57e1-0310-9a29-db15c13687c0
|