From 868aafb263804b176d73d216a2615e982da98d77 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Fri, 13 Mar 2020 14:24:29 -0400 Subject: [PATCH] Filter out managed credential types since we cannot patch them upon import. --- awxkit/awxkit/cli/resource.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/awxkit/awxkit/cli/resource.py b/awxkit/awxkit/cli/resource.py index d404abb878..3f3e0d28e6 100644 --- a/awxkit/awxkit/cli/resource.py +++ b/awxkit/awxkit/cli/resource.py @@ -51,7 +51,7 @@ EXPORTABLE_RESOURCES = [ 'users', 'organizations', 'teams', - # 'credential_types', + 'credential_types', # 'credentials', # 'notification_templates', # 'projects', @@ -316,9 +316,14 @@ class Export(CustomCommand): results = endpoint.get(all_pages=True).results options = self.get_options(endpoint) - return [self.serialize_asset(asset, options) for asset in results] + assets = (self.serialize_asset(asset, options) for asset in results) + return [asset for asset in assets if asset is not None] def serialize_asset(self, asset, options): + # Drop any (credential_type) assets that are being managed by the Tower instance. + if asset.json.get('managed_by_tower'): + return None + fields = { key: asset[key] for key in options if key in asset.json and key not in asset.related