summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application
Commit message (Collapse)AuthorAgeFilesLines
...
* | | maint: better error reporting for argument count mismatch.Daniel Pittman2011-04-281-47/+39
| | | | | | | | | | | | | | | Another face quirk in error reporting highlights a better way to work the error message; do so.
* | | (#7122) Enforce call arity on actions in the CLI wrapper.Daniel Pittman2011-04-281-1/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had a problem, previously, in the generic translation of command line arguments to Ruby method calls: we could mistake the options, added by the CLI wrapper, for a positional argument to the action method. This was caused by a combination of factors, but primarily that the wrapper methods for actions are designed to present a friendly, helpful Ruby API for internal use. Consequently, they have a default value if you don't wish to pass options. Unfortunately, this meant that the options that the CLI *always* passed could be treated as a positional argument instead, and the default set of options added to the back of the call. To resolve this we now check the number of positional arguments in the CLI wrapper, and raise an exception if they are mismatched. This makes the generic CLI handling do the right thing in adapting the command line arguments to the Ruby API. (As an aside, we would have had a similar-but-different failure mode if we type-checked positional arguments: these calls would have failed with an invalid argument validation error.) Reviewed-By: Max Martin <max@puppetlabs.com>
* | | (#7269) Fix error reporting for bad render formats...Daniel Pittman2011-04-281-24/+34
| | | | | | | | | | | | | | | | | | | | | | | | The previous change was incomplete, and could result in internal errors with the wrong combination of inputs. Now we have more testing, and a logically consistent model, so all works. Reviewed-By: Max Martin <max@puppetlabs.com>
* | | (#7269) Better error reporting for bad render formats.Daniel Pittman2011-04-281-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we would try and send `nil` to a class to render an unsupported format, which was bad. Worse, we would only discover this *after* the fact, when we tried to render, so the entire action had run and the result was lost to the world. Instead, validate the parameter early and fail during option parsing. This has less nice error reporting than we can get handling it later[1], but it gets us a much better overall set of behaviour. [1] puppet/application.rb will print and exit, rather than raising, when the option handler fails; this will improve when we unify face and application options properly. Reviewed-By: Max Martin <max@puppetlabs.com>
* | | (#7160) Support 'json' as a rendering method for CLI faces.Daniel Pittman2011-04-281-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already had some specialized support for rendering JSON using the PSON libraries; this just extends that to recognize the request on the command line for json to be identical to a request for pson. Theoretically we should also support the format in our network rendering code, but that is a much bigger change, in established code, that has more chance of destabilizing the whole release. Reviewed-By: Max Martin <max@puppetlabs.com>
* | | (#7157) Return a non-zero exit code on face failure.Daniel Pittman2011-04-221-12/+14
| | | | | | | | | | | | | | | | | | | | | | | | When a face or action fails we should exit non-zero on the CLI to signal this to our caller. "Fails" is defined as "raises an exception"; we don't treat any return value as a significant failure. Reviewed-By: Jesse Wolf <jesse@puppetlabs.com>
* | | (#7181) Rename configurer face to secret_agent.Daniel Pittman2011-04-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This is a much more useful public name, especially given the code is aimed to eventually replace the agent entirely. Until then this is pleasant enough to talk about. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
* | | (#7116) Handle application-level options in parse_optionsDaniel Pittman2011-04-201-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We hid another layer of per-application option in the class backing the application, which wasn't correctly handled in the parse_options method. They are now found and handled, so that global flags like --debug work as expected on the left of the action, not just the right. Reviewed-By: Max Martin <max@puppetlabs.com>
* | | maint: fix gratuitous whitespace in the code.Daniel Pittman2011-04-201-2/+2
| | | | | | | | | | | | | | | | | | | | | We had some stray spacing between variables and the '=' sign from when there was another variable in place; it got deleted, but the code wasn't closed up. Reviewed-By: Max Martin <max@puppetlabs.com>
* | | Merge branch 'bug/2.7.x/6752-allow-action-specific-render-methods'Daniel Pittman2011-04-191-12/+45
|\ \ \ | | | | | | | | | | | | Fix the conflicts over changes in my previous commit.
| * | | (#7013) Wire up rendering hooks on the CLI.Daniel Pittman2011-04-191-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now find, and call, the appropriate rendering hooks on actions during the rendering phase. This allows the user to intercept and replace the result object that passes through the rest of the rendering system on the fly. Example usage: action :foo do when_rendering :pson do |result| { :whatever => result[a], :foobar => result[b], } end end Reviewed-By: Max Martin <max@puppetlabs.com>
| * | | (#7013) Handle rendering modes out in the application layer.Daniel Pittman2011-04-191-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We no longer establish the rendering mode in the actions; they just default to "nothing", and let that flow on out to the application layer. That lets the facade we put before the face determine the default behaviour. This is mostly a no-op down in the CLI side, but it makes it much easier to integrate into MCollective, HTTP-API, and for other non-CLI users of Faces. Reviewed-By: Max Martin <max@puppetlabs.com>
| * | | (#7013) Strip out old face-wide rendering defaults.Daniel Pittman2011-04-191-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now we want to support action-based rendering, it is super-hard to define the semantics around defaulting where things are unspecified: the execution context (CLI, HTTP, etc) vs the face, vs the action all have different semantics. Without solving the problem of how we express all that context and those semantics down in the action, especially one written by a third party, this just becomes a box of counter-intuitive and annoying semantics and edge-cases. Reviewed-By: Max Martin <max@puppetlabs.com>
| * | | (#7013) better default rendering support for facesDaniel Pittman2011-04-191-4/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have some specific requirements around rendering, including the ability of authors of actions to add nice, custom rendering. To support that we want solid "basic" rendering for human-focused output. This implements that generic rendering correctly and to spec, to give a sound basis that we can build on for extensible rendering. (#7013) better default rendering support for faces We have some specific requirements around rendering, including the ability of authors of actions to add nice, custom rendering. To support that we want solid "basic" rendering for human-focused output. This implements that generic rendering correctly and to spec, to give a sound basis that we can build on for extensible rendering. Reviewed-By: Max Martin <max@puppetlabs.com>
| * | | maint: print 'false' in the default render method.Daniel Pittman2011-04-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to skip printing if the return value from an action was false; this made it impossible to display "false" to the user, which was a more meaningful output in some cases than nothing. maint: print 'false' in the default render method. We used to skip printing if the return value from an action was false; this made it impossible to display "false" to the user, which was a more meaningful output in some cases than nothing. Reviewed-By: Max Martin <max@puppetlabs.com>
* | | | (#7108) Update help/man text for puppet kicknfagerlund2011-04-181-25/+10
|/ / / | | | | | | | | | | | | Puppet kick's help referred only to the outdated authconfig (namespaceauth.conf) file, rather than the modern rest_authconfig (auth.conf).
* | | Merge remote-tracking branch 'community/feature/puppet-device' into 2.7.xPieter van de Bruggen2011-04-181-0/+255
| | | | | | | | | | | | Reviewed-By: Mike Stahnke
* | | Merge branch 'tickets/2.7.x/7115' into 2.7.xPieter van de Bruggen2011-04-151-12/+20
|\ \ \
| * | | (#7115) Enable default actions.Pieter van de Bruggen2011-04-151-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This also enables the 'help' action on the 'help' face to serve as a default action. Reviewed-By: Daniel Pittman Reviewed-By: Nick Lewis
* | | | (#6408) Update puppet cert help for new subcommand action syntax.nfagerlund2011-04-141-47/+51
|/ / / | | | | | | | | | | | | Puppet cert now allows bareword actions, which brings it more in-line with the Faces subcommands. Updating the help text accordingly.
* | | Revert "(#6928) Removed --ignoreimport"Nick Lewis2011-04-133-10/+4
| | | | | | | | | | | | | | | | | | | | | This reverts commit 24a277c5e805ce16e0b86e17e6cb2fbe1945ae07. Despite not needing --ignoreimport as an option anymore, it's still used internally and has to stay.
* | | (#6928) Removed --ignoreimportNick Lewis2011-04-133-4/+10
| | | | | | | | | | | | | | | | | | This was only used with --parseonly, which is gone. Paired-With: Jesse Wolfe
* | | (#6928) Remove --parseonlyNick Lewis2011-04-132-30/+10
| | | | | | | | | | | | | | | | | | This has been removed in favor of 'puppet parser validate <manifest>'. Paired-With: Jesse Wolfe
* | | (#6928) Add a Parser face with Validate actionNick Lewis2011-04-131-0/+5
| | | | | | | | | | | | | | | | | | | | | This will accept a number of manifests as arguments and check their syntax. If no filenames are specified, it will check the default 'manifest' setting. Paired-With: Jesse Wolfe
* | | (#7056) Use 'face' rather than 'faces' in the production code.Daniel Pittman2011-04-136-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | After some discussion we decided that most uses of the Puppet Face infrastructure were about single faces on their own, not about the collection, and so we were better referring to Puppet::Face[...] in code. This implements that by translating names and references in the Ruby code to the new, s-less, name.
* | | (#6962) Move option handling into #parse_options, not #preinit.Daniel Pittman2011-04-121-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Logically, the extra work around option parsing for faces belongs in the application parse_options method, not hidden in the step before. This commit moves that to the right place and fixes the fallout from that strange early design decision. Along the way we unify error reporting for invalid options so that all the code paths result in the same externally detected failures. Reviewed-By: Matt Robinson <matt@puppetlabs.com>
* | | (#6962) Override 'render' in help to just return the string.Daniel Pittman2011-04-121-3/+4
| | | | | | | | | | | | | | | | | | | | | The default behaviour is to serialize the result somehow, defaulting to displayed, render should be a no-op. This means overriding the parent method. Paired-With: Matt Robinson <matt@puppetlabs.com>
* | | (#6962) render prints the rval; fix help subcommand.Daniel Pittman2011-04-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The face application base uses render to transform the returned object to a form where #to_s produces the output intended for the end user; we were actually printing in the method instead, leading to an extraneous 'nil' at the end of the output... Paired-With: Matt Robinson <matt@puppetlabs.com>
* | | (#6962) Create the basic shape of the help face.Daniel Pittman2011-04-121-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | This implements the basic help face, along with the start of the support structures; we include the basic application, and the default help action that just emits a listing of faces and other discovered stuff... Reviewed-By: Matt Robinson <matt@puppetlabs.com>
* | | maint: finish transition of application help to return strings.Daniel Pittman2011-04-121-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Jesse made a change, in e1191f33defcaffec5900c7122a89ca75d3a9673, to transition from printing and exiting in the help method up to returning the help data to the caller. This was part of eliminating rdoc usage from the display of help to the user. The cert application was missed, and still used the legacy "print and exit" model; this cleans that up so it matches the rest of the code. Paired-With: Matt Robinson <matt@puppetlabs.com>
* | | Fixed #5684 - Move to Apache 2.0 licenseJames Turnbull2011-04-1111-23/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For details of why we're moving please see: https://groups.google.com/d/topic/puppet-users/NuspYhMpE5o/discussion Removed explicit GPL licenses where appropriate Replaced selected GPL licenses with Apache 2.0 Replaced LICENSE with Apache 2.0 Updated README
* | | Fixing 'puppet faces' applicationLuke Kanies2011-04-091-16/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It only had one available method, and the errors incorrectly specified what it was. This just defaults to listing all the time, and I've updated the docs to be correct, too. Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
* | | Merge puppet-interfaces into puppet.Daniel Pittman2011-04-0716-0/+334
|\ \ \ | | | | | | | | | | | | | | | | This joins the two repositories, including full history, into a single run, as well as landing the interfaces work on the next branch ready for release.
| * | | (#7012) Update references in code to use face(s)Daniel Pittman2011-04-075-28/+28
| | | | | | | | | | | | | | | | | | | | The codebase is now using the new name, faces, uniformly to reference the objects contained. All tests pass.
| * | | (#7012) global rename of strings to faces.Daniel Pittman2011-04-072-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This just changes filenames and directories; files are exact copies rather than having additional modifications to make clearer each step of this process. This does leave a currently broken build. :/
| * | | (#6972) Handle ca-location in the certificate string.Daniel Pittman2011-04-061-12/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This ports the existing certificate location configuration to be a string option, and then uses that to change the configuration. This will leak state between calls, which is somewhat unavoidable, but should at least get the basic stuff right for the CLI. We eventually need the CA string to be supported by a stateless internal CA implementation that allows us to do the right thing overall. Reviewed-By: Dan Bode <dan@puppetlabs.com>
| * | | (#6972) Recognize puppet global options in pre-parse.Daniel Pittman2011-04-061-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This extends the CLI pre-parse phase to identify both string *and* global options out of the Puppet settings/defaults system. This makes the regular CLI support for setting Puppet configuration globals work as expected. This moves us along the line of supporting these options more fully. Reviewed-By: Dan Bode <dan@puppetlabs.com>
| * | | (#6949) Fix passing positional arguments to actions.Daniel Pittman2011-04-041-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had a logic failure that didn't pass positional arguments at all, but which our testing didn't verify. This entirely broke things. Now fixed, and a test added to ensure we don't bug out further... Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
| * | | (#6749) Handle options with inline arguments.Daniel Pittman2011-04-041-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We didn't correctly handle '--foo=bar' as having supplied an argument during the pre-parse phase. Now we have a test for it, and a fix in the code. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
| * | | (#6749) Extract the action from the arguments cleanly.Daniel Pittman2011-04-041-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a test to verify that we are correctly removing the action name from the set of arguments passed to the string action, then cleans up the previous code so we don't need to mutilate the command line arguments: we can just extract it from the resultant set of information. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
| * | | (#6749) Fix optional vs mandatory argument handling.Daniel Pittman2011-04-041-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | optparse will treat '--foo --bar' as "foo with the argument --bar" when foo takes a mandatory argument. We need to emulate that behaviour in our pre-parse of the command line. Incidentally, fix up a bug in boolean options, and improve our testing. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
| * | | (#6749) Polish the CLI option pre-parse implementationDaniel Pittman2011-04-041-11/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This improves handling of the pre-parse of the command line to be non-destructive, which cuts down the volume of garbage generated in the process. It also improves testing to verify that we get the darn thing right... Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
| * | | (#6749) Start porting existing strings to the options API.Daniel Pittman2011-04-042-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This provides a solid test of the new code, by migrating the existing strings to match. This also gives us a chance to determine any weak points in the code as written. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
| * | | (#6749) code and test cleanup of Application/StringBase.Daniel Pittman2011-04-041-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes dead code now we have terminus in the base string, and disables some tests on StringBase app until they can be rewritten. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
| * | | (#6749) Remove "save does not work" language from strings.Daniel Pittman2011-04-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Now we are pushing into production we can eliminate this language, which was a legacy from the prototype that is no longer relevant globally. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
| * | | (#6749) string cli base: implement preinit CLI parsingDaniel Pittman2011-04-041-41/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to identify the full set of options we need to know the action that is being invoked; that actually requires a pre-processing step to identify that out of the global options. Notably, our spec is that options can be to the right of their declaration point, but not to the left: that means that we can now extract the full set of options, and interact with the standard Puppet option handling code, resulting in at least vaguely saner behaviour... Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
| * | | (#6749) implementing option handling in CLI string wrapperDaniel Pittman2011-04-042-14/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The purpose of this is to adapt the generic option support in our strings to the command line; we adapt the generic option information to optparse, and establish our environment early in the process to ensure that we can play nice with Puppet::Application for the moment. In the process we ensure that we detect, and report, conflicts in option naming across the board. Additionally, when an option is declared with multiple aliases, we insist that either all, or none, of them take an argument. To support this we support introspecting options having an optional argument, as well as documentation and all. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
| * | | (#6758) Pass options as an argument to string actions.Daniel Pittman2011-04-021-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Earlier in their implementation the String prototype would set global state on a String object to reflect options set on the command line. As we move strings away from a CLI-only prototype, this becomes troublesome because we can easily have, for example, HTTP access to a string, which means load balancers can really make this confusing. It also encourages global state pollution, where one invocation can adversely influence another. A better approach is that we pass options to the string action invocation directly; this makes the interaction stateless. Changes required to your code to adapt to the new world: - action(:foo) do |some, args| + action(:foo) do |some, args, options={}| if options[:whatever] then Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
| * | | (#6770) Change versioning; adopt :current over :latest.Pieter van de Bruggen2011-03-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As per discussion with Luke, versions of an interface are first looked up by requiring 'puppet/interface/{name}', and secondarily looked up by requiring '{name}@{version}/puppet/interface/{name}' if the first failed. A version of `:current` can be used to represent the version living in 'puppet/interface/{name}'. Paired-With: Nick Lewis
| * | | MAINT: the API is officially named "string" as of this moment.Daniel Pittman2011-03-285-32/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we have settled on the final public name for the API, "Puppet::String", mass-rename and mass-edit all the files to follow. Reviewed-By: Randall Hansen <randall@puppetlabs.com>