summaryrefslogtreecommitdiffstats
path: root/lib/puppet/interface.rb
Commit message (Collapse)AuthorAgeFilesLines
* (#7184) Centralize "find action for face" into Puppet::FaceDaniel Pittman2011-07-221-0/+4
| | | | | | | | | | | | As part of moving to load actions first, and their associated face, when invoked from the command line, it makes sense to push the logic for finding the action and face down into the Puppet::Face implementation. This means that we can change the logic there without needing to update the public part of the CLI implementation, and that any further facades can use the same, correct, logic to locate the action for the face. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
* (#7204) Consolidate Semantic Versioning code.Pieter van de Bruggen2011-07-191-2/+3
| | | | | | | | | | This introduces a class representing a semantic version, and implementing a few of the most common uses of them: validation, comparison, and finding the greatest available version matching a range. This refactoring also allows us to easily expand our matching of version ranges in the future, which is a big plus. Reviewed-By: Daniel Pittman
* (#7828) Fix whitespace in synopsis generator.Daniel Pittman2011-06-071-20/+1
| | | | | | | | | | | | | | | | We accidentally omitted whitespace between multiple options while building the synopsis. This fixes that, by introducing a breakable space in the right location. Additionally, we extract the code that was 99 percent identical from the face and action synopsis generators, push it down into the documentation module, and then invoke it from both places. This eliminates the duplicate code, allowing me to fix that bug once and have it apply to both parts of the code; this is pretty much assured to be true any time we change the synopsis generation. Reviewed-By: Nick Fagerlund <nick.fagerlund@puppetlabs.com>
* Merge branch 'tickets/2.7.x/7289' into 2.7.xPieter van de Bruggen2011-04-291-0/+2
|\
| * (#7289) Specify order for option decorations.Pieter van de Bruggen2011-04-291-0/+2
| | | | | | | | | | | | | | | | | | | | `before_action` decorations should always resolve in resolution order from most general (inherited from furthest away) to most specific (declared on the instance), and should always execute Face-level option decorations before action-level option decorations. `after_action` decorations should execute in the opposite order. Reviewed-By: Daniel Pittman
* | Merge branch 'feature/2.7.x/6962-finish-documentation-api-for-faces' into 2.7.xDaniel Pittman2011-04-271-17/+33
|\ \ | |/ |/|
| * (#6962) Finish documentation API on Face options.Daniel Pittman2011-04-271-1/+1
| | | | | | | | | | | | | | This extends the last of the documentation support, down into options, so they can be described as expected. In the process we split out the modular docs API into a full and short version options only want short docs, but the behaviours are identical to the full version.
| * (#6962) Move documentation support into a module.Daniel Pittman2011-04-261-162/+4
| | | | | | | | | | | | Given that we have identical documentation behaviour in the face and action code, it should properly be written once. So, move it into a module, extend the other classes with it, and have done.
| * (#6962) Extend documentation API for Faces.Daniel Pittman2011-04-261-2/+176
| | | | | | | | | | | | This adds the remaining documentation mechanisms to the Face instances, allowing them to build and report correct documentation, licensing and ownership for the help face to build on.
* | (#7251) Let exceptions raised in decorators rise.Pieter van de Bruggen2011-04-261-5/+3
|/ | | | | | This allows users to write before_action advice that does basic option validation very easily. Reviewed-By: Daniel Pittman
* (#7183) Implement "invisible glob" version matching for facesDaniel Pittman2011-04-211-7/+6
| | | | | | | | | | | | | | | | | | | | | "Invisible glob", or "prefix", version matching means that when you specify a version string to use you can specify as little as one version number out of the semantic versioning spec. Matching is done on the prefix; an omitted number is treated as "anything" in that slot, and we return the highest matching versioned face by that spec. For example, given the set of versions: 1.0.0, 1.0.1, 1.1.0, 1.1.1, 2.0.0 The following would be matched: input matched 1 1.1.1 1.0 1.0.1 1.0.1 1.0.1 1.0.2 fail - no match 1.1 1.1.1 1.1.1 1.1.1 1.2 fail - no match
* maint: better error report for a missing version of a face.Daniel Pittman2011-04-201-1/+1
| | | | | | | | | | We would report this: Could not find version 1.0.0 of Puppet::Face[:version_matching, "2.0.0"] That is not actually so helpful, not least because people wonder why it reports a version number they didn't ask for. Instead, we just report the requested name now.
* Merge branch 'bug/2.7.x/6752-allow-action-specific-render-methods'Daniel Pittman2011-04-191-6/+3
|\ | | | | | | Fix the conflicts over changes in my previous commit.
| * (#7013) Strip out old face-wide rendering defaults.Daniel Pittman2011-04-191-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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) Support 'when_rendering' and 'render_as' in actions.Daniel Pittman2011-04-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | These define the API used by folks writing actions that supports their rendering hooks. 'when_rendering' defines a helper method on the interface, which runs the users code in their expected context. 'render_as' just sets the default rendering format; by default this is :for_humans. Reviewed-By: Max Martin <max@puppetlabs.com>
* | maint: drop multi-version support from action loading.Daniel Pittman2011-04-191-20/+5
| | | | | | | | | | | | | | Right now we have no other support for multi-version loading in the code; we should strip out support from the action loading to mirror. Reviewed-By: Max Martin <max@puppetlabs.com>
* | (#6962) Add 'description' to faces and action.Daniel Pittman2011-04-191-2/+14
| | | | | | | | | | | | | | This adds the 'description' method to the faces and actions, as well as structured testing to ensure that the DSL works as expected. Reviewed-By: Max Martin <max@puppetlabs.com>
* | (#7132) Reject 'summary' text with newlines embedded.Daniel Pittman2011-04-191-1/+8
|/ | | | | | | | | Our summary documentation is used to provide single-line context to faces, actions, and other items. To support this we hard-fail if someone tries to use the summary to embed the long documentation, and point them to the right place to add the extended text. Reviewed-By: Max Martin <max@puppetlabs.com>
* (#6978) Add before and after decorators to actions from options.Daniel Pittman2011-04-151-0/+39
| | | | | | | | | | | | | | | | | | | | | | | Options can now add before_action and after_action blocks; these are invoked before or after any action is invoked on the face. This allows these options to declare common behaviour and have it automatically applied to the actions invoked. Option hooks have no defined order of invocation: they will run in a completely random order. Where there are dependencies they should be on the value of the options hash passed to the invocation, not on side-effects of the other invocations. You are not able to influence the arguments, options, or calling of the action body in a before or after decorator. This is by design. The invocation passes to the hook: 1. The action object representing this action. 2. The arguments to the action, as an array. 3. The options for the action, as a hash. Paired-With: Max Martin <max@puppetlabs.com>
* (#7056) Use 'face' rather than 'faces' in the production code.Daniel Pittman2011-04-131-3/+3
| | | | | | | | | 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) Implement 'summary' for faces.Daniel Pittman2011-04-121-2/+7
| | | | | | | | | | | | This adds the methods to the summary builder and runtime instance to support setting and getting a summary of the face. This is a short description used to summarize the purpose of the face in help output. For example, from the help face: "Displays help about puppet subcommands" Reviewed-By: Matt Robinson <matt@puppetlabs.com>
* (#6969) String failures differentiate between invalid string/versionDan Bode2011-04-071-1/+10
| | | | | | | | | | | | This patch does two things: 1. splits out the string lookup functionality from define into a seperate method [] 2. Tries to both load the specific version of a string as well as the current version so that specific error messages can be returned differentiating between an invalid version/string. Reviewed-By: Daniel Pittman <daniel@puppetlabs.com>
* (#7012) Split plumbing into Puppet::InterfaceDaniel Pittman2011-04-071-0/+106
| | | | | | | | | This splits out the plumbing into the Puppet::Interface namespace, and uses Puppet::Faces for all the public-facing code. The fault line is "what you care about if you are using or writing a face", which is public, against "what you care about to enable either of those two", which is the plumbing.
* MAINT: the API is officially named "string" as of this moment.Daniel Pittman2011-03-281-98/+0
| | | | | | | 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>
* (#6770) Add support for version :latest.Pieter van de Bruggen2011-03-251-0/+4
| | | | | | | | | Specifying a version of `:latest` will find the most recent version of the named interface installed in your RUBYLIB, and attempt to load that. This is unlikely to provide a stable dependency in the future, so should be used sparingly, acknowledging the dangers. Reviewed-By: Daniel Pittman
* (#6770) Refactor Puppet::Interface#initialize.Pieter van de Bruggen2011-03-251-13/+10
| | | | | | | | | P::I#initialize now takes a name and a version (and an optional block). The options hash has been removed, though it may be reintroduced if a legitimate use case can be made for it (so far, it's only been used for the version number). Reviewed-By: Jacob Helwig
* (#6770) Rename Puppet::Interface::interface method.Pieter van de Bruggen2011-03-231-24/+28
| | | | | | | Puppet::Interface::interface is now Puppet::Interface::define, also aliased to Puppet::Interface::[] for convenience. Paired-With: Nick Lewis
* (#6770) Add basic versioning for interfaces.Pieter van de Bruggen2011-03-231-10/+12
| | | | Reviewed-By: Nick Lewis
* maint: Implement an InterfaceCollection class to manage interfacesNick Lewis2011-03-221-55/+19
| | | | | | | | | | | Having an instance variable on class Interface is insufficient for Interface::Indirector. This also changes the semantics of "Interface.interface" to handle registration and loading actions, and for "Interface.new" to only instantiate an Interface. Thus, consumers of the API should typically use "Interface.interface", unless they have reasons to not want an interface automatically registered. Paired-With: Pieter van de Bruggen
* (#6786) Change interface storage and access.Pieter van de Bruggen2011-03-221-13/+17
| | | | | | | | | | | Ruby's namespace mechanism introduced a number of problems, including incorrect name resolution for common and simple cases. Given that, we've refactored back to class-level data structures with accessor methods available. The current method names are unlikely to be the final UI. Reviewed-By: Daniel Pittman
* (Maint.) Remove Puppet::Interface#unload_interfacePieter van de Bruggen2011-03-211-4/+0
| | | | Reviewed-By: Nick Lewis
* (#6805) Add a "configurer" applicationNick Lewis2011-03-211-0/+2
| | | | | | | | | This application is similar in basic functionality to the "agent" application, but implemented in terms of interfaces. It currently will retrieve facts, retrieve a catalog, apply the catalog, and submit a report. Options such as noop and daemonize are still to come. Reviewed-By: Pieter van de Bruggen
* (#6806) Improve error checking and reporting for interface naming.Daniel Pittman2011-03-211-5/+5
| | | | | | | | We didn't do enough input checking and sanitization, and missed some edge-cases for naming interfaces. This adds testing, and cleans up some edge cases to handle things better. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
* (#6786) Fixing a number of failing tests.Pieter van de Bruggen2011-03-211-4/+9
| | | | | | | The initial merge of this branch hadn't actually been run against the full suite of specs; a number of specs began failing shortly afterward. Reviewed-By: Daniel Pittman
* (#6786) Removing the #interface method.Pieter van de Bruggen2011-03-211-20/+9
| | | | | | | | Since constants are already being defined for each interface, the #interface method does little but provide another way to access the same data. Reviewed-By: Nick Lewis
* Fixing #13 - showconfig moved to indirectorLuke Kanies2011-03-021-9/+0
| | | | | | | | | I renamed it to 'info', too. It only showed indirector-related info, so this makes sense. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Attempting to skip loading of duplicate actionsLuke Kanies2011-02-241-0/+6
| | | | Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Adding Application options to InterfacesLuke Kanies2011-02-231-1/+1
| | | | | | | | | | | | This allows all of the actions to react to the CLI options. I've also removed the unnecessary 'name' variables I was using in various places - they were just the first of the arguments, and they weren't actually always names. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Fixing 'puppet interface list'Luke Kanies2011-02-221-16/+40
| | | | | | | Also added a test to hopefully confirm it won't break again. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Adding a string form to interfacesLuke Kanies2011-02-221-0/+4
| | | | Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Switching Interfaces to be instancesLuke Kanies2011-02-221-48/+55
| | | | | | | | | They were previously classes, which made a lot of things stupider than they needed to be. This will likely involve some porting, but not much. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Fixing Interface listingLuke Kanies2011-02-201-1/+6
| | | | | | It got broke when the Indirector base class was extracted. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* (#2) Should not assume interfaces have indirectorsDan Bode2011-02-201-66/+1
| | | | | | | | | | | The initial work assumed that all interfaces were just skins on an indirected data type, but some interfaces will be more abstract than that. This commit removes that assumption by extracting all of the indirector work into a new Indirector subclass of Interface and then makes all of the new interfaces a subclass of that rather than of Interface itself.
* Enabling arbitrary interface namesLuke Kanies2011-02-161-2/+9
| | | | | | | | | | | Previously the app, indirection, and interface names had to match exactly; now they can be arbitrary by just defining an overriding 'indirection_name' class method on the interface. I also renamed the file_bucket_file classes accordingly. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Fixing an error messageLuke Kanies2011-02-161-1/+1
| | | | Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Moving 'format' support to the applicationLuke Kanies2011-02-081-4/+11
| | | | | | This allows easier use of the Interfaces in ruby. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Finishing migration from puppet repoLuke Kanies2011-02-081-17/+17
| | | | | | | The whole system seems to work again, as long as you run it against 2.6.next. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Moving data executables to their own moduleLuke Kanies2011-01-301-0/+145
Signed-off-by: Luke Kanies <luke@puppetlabs.com>