summaryrefslogtreecommitdiffstats
path: root/spec/unit
Commit message (Collapse)AuthorAgeFilesLines
...
* Cleaning up ResourceAPI testsLuke Kanies2010-02-171-7/+1
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* s/DSL::ResourceHelper/DSL::ResourceAPI/gLuke Kanies2010-02-172-7/+7
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding simplistic pure ruby interfaceLuke Kanies2010-02-174-6/+232
| | | | | | | | | This is a simplistic DSL - you can create resource types (defined resources), classes, and nodes, and they can call functions and create resources. Nothing else, at this point. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding environment support to parser resourcesLuke Kanies2010-02-171-0/+9
| | | | | | We just use the scope's environment. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Moving the string interpolation parsing to the parser/lexerMarkus Roberts2010-02-171-163/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-179-28/+50
| | | | | | | | | | | | 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>
* Forcing parent evaluation in resource typesLuke Kanies2010-02-171-1/+44
| | | | | | | | | When a class is evaluated, its parent class needs to be evaluated first. This forces that evaluation. We somehow lost it when we converted the resource types out of AST. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Fixing type/title resource resolutionLuke Kanies2010-02-171-73/+121
| | | | | | | | | | | | | This code is impressively difficult, because sometimes resource types act like resources (classes and nodes are singletons) and sometimes like resource types (defined and builtin resources). So, to get nodes to show as Node[foo] and classes as Class[Foo::Bar], but defined resources to show up as Foo::Bar[baz], we have to do some silliness. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Converging the Resource classes furtherLuke Kanies2010-02-171-13/+13
| | | | | | | | | | | 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-49/+47
| | | | | | | 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-175-31/+95
| | | | | | | | 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-1722-448/+563
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Allowing Environment.new to take an environmentLuke Kanies2010-02-171-0/+5
| | | | | | | | | This can happen because we're almost always converting to environment instances from strings. Shouldn't happen often, but it's easier to be more failure-tolerant. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* TypeCollection now supports namespace arraysLuke Kanies2010-02-171-2/+9
| | | | | | | | | 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-174-17/+121
| | | | | | | | | | | | | 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>
* Fixing failing Environment unit testsLuke Kanies2010-02-171-1/+1
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding an environment helperLuke Kanies2010-02-171-0/+24
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Changing the interface of Puppet::ResourceLuke Kanies2010-02-172-9/+24
| | | | | | | | We need the ability to set the namespace and environment at initialization so the resource can look up qualified types. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Partially fixing #2954 - Adding class parametersLuke Kanies2010-02-171-0/+41
| | | | | | | | 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>
* Fixing test structureLuke Kanies2010-02-171-8/+8
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* REST: Fix a state leak causing test failuresJesse Wolfe2010-02-171-0/+1
|
* REST FileBucket: REST barfs on relative pathsJesse Wolfe2010-02-171-0/+6
| | | | Force FileBucket to always send absolute (real) paths
* REST: hide Request objectJesse Wolfe2010-02-178-23/+13
| | | | | | This change to the REST branch restores some sanity by explicitly allowing a destination URL for indirector save() calls, removing a hack that I was using to accomplish this.
* Feature #3394 REST runner, executionJesse Wolfe2010-02-174-16/+55
| | | | puppetrun uses REST to trigger puppet runs.
* Feature #3394 REST Runner, preparationJesse Wolfe2010-02-172-14/+14
| | | | Rename Puppet::Agent::Runner to Puppet::Run, for consistency
* Feature #3383 RAL over RESTJesse Wolfe2010-02-176-46/+218
| | | | | | | | ralsh --host works now, and is using REST. A node running puppetd --listen will allow ralsh to find, search, and modify live resources, via REST. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
* Fix tests on #3347Jesse Wolfe2010-02-171-6/+6
|
* Feature #3347 REST-ified FileBucketJesse Wolfe2010-02-1712-116/+653
| | | | | | | | | | | | | | | | FileBucket Files have been reimplemented as an indirector terminus so that they can be transmitted over REST. The old Network::Client.dipper has been replaced with a compatibility later in FileBucket::Dipper that uses the indirector to access filebucket termini. Slightly revised patch: * No longer allows nil contents in FileBucket outside of initialization * Uses File.exist? instead of the deprecated File.exists? * Tweaks JSON serialization and de-serialization to include "path" Deferred issues: * Feature #3371 "FileBucket should not keep files in memory". * Feature #3372 "Replace FileBucket Dipper with more idiomatic calls"
* Fix a failing test in #3115Jesse Wolfe2010-02-171-0/+8
| | | | Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
* Feature #3115 REST-ified status()Jesse Wolfe2010-02-173-0/+35
| | | | | | | | | | | | | | | | | | This patch re-implements the status() remote procedure as a REST interface. A running server returns key-value pairs, currently the only implemented key is "is_alive" which will always be set to true. Some future tool will consume this by: Puppet::Status.indirection.terminus_class = :rest Puppet::Status.find('https://puppet:8140/production/status/default') Now with unit tests. plus fixes a typo. plus integration test and default security setting. plus tests suggested by Brice. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
* Fix #3229 - use original value in case/selector regex matchingBrice Figureau2010-02-173-20/+13
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Cleaning up a test.Luke Kanies2010-02-171-3/+3
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Removing unused Checksum::File terminusLuke Kanies2010-02-171-139/+0
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Converting File terminus to use formats.Luke Kanies2010-02-172-75/+95
| | | | | | | | | | This fixes most of #1943, except the checksum indirection still uses this. This basically always chooses the most recent file when finding files, and saves the file with the default format. Signed-off-by: Luke Kanies <luke@madstop.com>
* Adding filename extension support to formats.Luke Kanies2010-02-173-0/+20
| | | | | | | | This is toward fixing #1943 - we need the ability to easily convert between file extensions and file formats. Signed-off-by: Luke Kanies <luke@madstop.com>
* Resolving conflicts with ???Markus Roberts2010-02-171-2/+2
|
* Renaming Parser::ResourceType to Resource::TypeLuke Kanies2010-02-1713-154/+154
| | | | | | | | | | 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-176-182/+33
| | | | | | | 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-178-95/+155
| | | | | | | | | 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-2/+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-18/+18
| | | | | | | | | | 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/+25
| | | | | | | 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-172-16/+32
| | | | | | | 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-24/+30
| | | | | | | | | 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-172-4/+148
| | | | | | | 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-174-60/+60
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Storing per-environment LoadedCode instancesLuke Kanies2010-02-173-31/+40
| | | | | | | | | | | | 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-0/+23
| | | | | | | 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>
* Fixing test structureLuke Kanies2010-02-171-4/+4
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding []/[]= support to Parser::ResourceLuke Kanies2010-02-171-0/+10
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>