Engine implementation for document replacement

This adds support for document replacement to the
Deckhand engine _only_ for the following scenarios
_only_:

  * generic case (a replaces b, returns a only)
  * substitution case (a replaces b, c substitutes from a instead)

TODO:

  * layering case (a replaces b, c layers with a instead)
  * Modify Document unique constraint to work with
    (schema, name, layer) throughout all of Deckhand
    (including controllers, database models, and anywhere
     else as needed)

Change-Id: Ie2cea2a49ba3b9ebc42706fbe1060d94db2e5daa
This commit is contained in:
Felipe Monteiro
2018-03-14 19:41:38 +00:00
committed by Scott Hussey
parent 1264e5af6c
commit 4799acdbcc
7 changed files with 324 additions and 51 deletions

View File

@@ -261,6 +261,22 @@ class MissingDocumentPattern(DeckhandException):
code = 400
class InvalidDocumentReplacement(DeckhandException):
"""The document replacement is invalid.
**Troubleshoot:**
* Check that the replacement document has the same ``schema`` and
``metadata.name`` as the document it replaces.
* Check that the document with ``replacement: true`` has a parent.
* Check that the document replacement isn't being replaced by another
document. Only one level of replacement is permitted.
"""
msg_fmt = ("Replacement document [%(schema)s, %(layer)s] %(name)s is "
"invalid. Reason: %(reason)s")
code = 400
class UnsupportedActionMethod(DeckhandException):
"""The action is not in the list of supported methods.