puppetlabs/puppetdb — pull request #843 by kbarber (2014-02-10 23:34:17+00:00)
Title: PDB-437 Reduce API source code and version inconsistencies

The API code when split between different versions created an opportunity for
inconsistencies to grow. For example, some versioning inside the code supported
this file based way of abstracting versions, but other functions required
version specific handling.

The problem was that the version wasn't always filtered down properly due to a
lack of a structured way of handling versions.

Not only that, whenever a new version of the API is cut the amount of code that
is simply copied and pasted was quite large.

This patch collapses any version specific code into a single unit. For example
the end-points v2/facts and v3/facts can now be handled by the same application.

The way this is achieved is by passing a keyword of the version: :v1, :v2, :v3
from the top level ring app and pass that into any functions that require
'versioned' capabilities. This version can then be used in decision code (ie.
like a case statement) to execute differently dependant on version.

Because the version pattern is consistent, we should be able to ensure that
particular versioned behaviour is also called consistently no matter where in
the stack a function is executed. This should reduce cases like we've seen
before where v3 api end-points still exhibit v2 behavours on very specific
experessions.

For the query parts of the code, we've applied the same versioned pattern.
The tests now iterate across all supported versions for each tests as well
providing more coverage generally.

Signed-off-by: Ken Barber