| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
|
|
| |
* Remove require statements
* explicity define namespace modules/classes for
Puppet::Resource::Status to avoid require dependency cycle.
|
|
|
|
|
|
|
|
|
|
| |
"${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.
|
|
|
|
|
|
|
|
|
|
|
| |
"${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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
It was previously not allowing false values.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
containing the specified command.
Also adds rspec tests for generate().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
| |
|
|
|
|
|
|
|
| |
It was only apparently working with constant keys,
not, say, AST strings.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
We just use the scope's environment.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
|
| |
Brice's hash implementation introduces new occurances of SQTEXT/DQTEXT which, with
string interpolation, should simply be STRING.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
It's no longer necessary, given the new ResourceTypeCollection
class.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
We previously passed a hash of options but now just
the environment.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
This is so everyone doesn't have to define the same method
everywhere.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
|
|
|
| |
It was previously handled by the Interpreter,
but we're planning on getting of that.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
| |
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|