Skip to content

Commit b560372

Browse files
committed
Fix issue where Warnings relying on violation messages were not correctly producing string outputs for Environments
Signed-off-by: Daniel Chaffelson <[email protected]>
1 parent 495c1b6 commit b560372

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/cdpy/environments.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def describe_environment(self, name):
6161
# Describe will fail in certain fault scenarios early in Environment creation
6262
# We helpfully provide the summary listing as a backup set of information
6363
# If the environment truly does not exist, then this will give the same response
64-
self.sdk.throw_warning(CdpWarning(resp.violations['message']))
64+
self.sdk.throw_warning(CdpWarning(resp.violations))
6565
return self.summarize_environment(name)
6666
self.sdk.throw_error(resp)
6767
return resp
@@ -107,7 +107,7 @@ def create_aws_environment(self, **kwargs):
107107
if resp.error_code == 'INVALID_ARGUMENT':
108108
if 'constraintViolations' not in resp.violations:
109109
resp.update(message="Received violation warning:\n%s" % self.sdk.dumps(resp.violations))
110-
self.sdk.throw_warning(CdpWarning(resp.violations['message']))
110+
self.sdk.throw_warning(CdpWarning(resp.violations))
111111
self.sdk.throw_error(resp)
112112
return resp
113113

@@ -121,7 +121,7 @@ def create_azure_environment(self, **kwargs):
121121
if resp.error_code == 'INVALID_ARGUMENT':
122122
if 'constraintViolations' not in resp.violations:
123123
resp.update(message="Received violation warning:\n%s" % self.sdk.dumps(resp.violations))
124-
self.sdk.throw_warning(CdpWarning(resp.violations['message']))
124+
self.sdk.throw_warning(CdpWarning(resp.violations))
125125
self.sdk.throw_error(resp)
126126
return resp
127127

@@ -135,7 +135,7 @@ def create_gcp_environment(self, **kwargs):
135135
if resp.error_code == 'INVALID_ARGUMENT':
136136
if 'constraintViolations' not in resp.violations:
137137
resp.update(message="Received violation warning:\n%s" % self.sdk.dumps(resp.violations))
138-
self.sdk.throw_warning(CdpWarning(resp.violations['message']))
138+
self.sdk.throw_warning(CdpWarning(resp.violations))
139139
self.sdk.throw_error(resp)
140140
return resp
141141

@@ -205,7 +205,7 @@ def sync_users(self, environments=None):
205205
)
206206
if isinstance(resp, CdpError):
207207
if resp.error_code == 'CONFLICT':
208-
operation_match = self.sdk.regex_search(self.sdk.OPERATION_REGEX, resp.violations['message'])
208+
operation_match = self.sdk.regex_search(self.sdk.OPERATION_REGEX, resp.violations)
209209
if operation_match is not None:
210210
existing_op_id = operation_match.group(1)
211211
if not self.sdk.strict_errors:
@@ -264,11 +264,11 @@ def create_aws_credential(self, name, role, description, retries=3, delay=2):
264264
consistency_violations = [
265265
'Unable to verify credential', 'sts:AssumeRole', 'You are not authorized'
266266
]
267-
if any(x in resp.violations['message'] for x in consistency_violations):
267+
if any(x in resp.violations for x in consistency_violations):
268268
retries = retries - 1
269269
self.sdk.throw_warning(
270270
CdpWarning('Got likely AWS IAM eventual consistency error [%s], %d retries left...'
271-
% (resp.violations['message'], retries))
271+
% (resp.violations, retries))
272272
)
273273
self.sdk.sleep(delay)
274274
return self.create_aws_credential(name, role, description, retries, delay)

0 commit comments

Comments
 (0)