From d20f4741c5ebcea2935c22e459e02c3a6421c954 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Wed, 21 Mar 2018 20:45:14 +0000 Subject: [PATCH] Skip layering for control documents This is to skip layering for control documents (those whose metadata.schema starts with "deckhand/Control") as these documents consist of ValidationPolicy or LayeringPolicy documents -- and it would be both nonsensical and scary to try to layer these types of documents. Documentation for this will be updated during a larger overhaul effort to improve Deckhand's documentation. Change-Id: Ia785e54c4e26a4158b6bdc89da8b96b4455f7b39 --- deckhand/engine/document_wrapper.py | 4 ++++ deckhand/engine/layering.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/deckhand/engine/document_wrapper.py b/deckhand/engine/document_wrapper.py index 35ea4a6c..b1e6dc60 100644 --- a/deckhand/engine/document_wrapper.py +++ b/deckhand/engine/document_wrapper.py @@ -33,6 +33,10 @@ class DocumentDict(dict): return utils.jsonpath_parse( self, 'metadata.layeringDefinition.abstract') is True + @property + def is_control(self): + return self.metadata.get('schema', '').startswith('deckhand/Control') + @property def schema(self): return self.get('schema') or '' diff --git a/deckhand/engine/layering.py b/deckhand/engine/layering.py index e4452413..315fa919 100644 --- a/deckhand/engine/layering.py +++ b/deckhand/engine/layering.py @@ -469,6 +469,9 @@ class DocumentLayering(object): in both the parent and child documents being layered together. """ for doc in self._sorted_documents: + # Control documents don't need to be layered. + if doc.is_control: + continue if doc.parent_selector: parent_meta = self._parents.get((doc.schema, doc.name))