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:
committed by
Scott Hussey
parent
1264e5af6c
commit
4799acdbcc
@@ -214,8 +214,9 @@ class SecretsSubstitution(object):
|
||||
the constructor.
|
||||
|
||||
:param substitution_sources: List of documents that are potential
|
||||
sources for substitution. Should only include concrete documents.
|
||||
:type substitution_sources: List[dict]
|
||||
sources for substitution. Or dict of documents keyed on tuple of
|
||||
(schema, metadata.name). Should only include concrete documents.
|
||||
:type substitution_sources: List[dict] or dict
|
||||
:param bool fail_on_missing_sub_src: Whether to fail on a missing
|
||||
substitution source. Default is True.
|
||||
"""
|
||||
@@ -227,12 +228,16 @@ class SecretsSubstitution(object):
|
||||
self._substitution_sources = {}
|
||||
self._fail_on_missing_sub_src = fail_on_missing_sub_src
|
||||
|
||||
for document in substitution_sources:
|
||||
if not isinstance(document, document_wrapper.DocumentDict):
|
||||
document = document_wrapper.DocumentDict(document)
|
||||
if document.schema and document.name:
|
||||
self._substitution_sources.setdefault(
|
||||
(document.schema, document.name), document)
|
||||
if isinstance(substitution_sources, dict):
|
||||
self._substitution_sources = substitution_sources
|
||||
else:
|
||||
self._substitution_sources = dict()
|
||||
for document in substitution_sources:
|
||||
if not isinstance(document, document_wrapper.DocumentDict):
|
||||
document = document_wrapper.DocumentDict(document)
|
||||
if document.schema and document.name:
|
||||
self._substitution_sources.setdefault(
|
||||
(document.schema, document.name), document)
|
||||
|
||||
def substitute_all(self, documents):
|
||||
"""Substitute all documents that have a `metadata.substitutions` field.
|
||||
|
||||
Reference in New Issue
Block a user