Changes for new version of falcon

Moving to falcon 3.0.0+ brings in some changes to the response
object. One of those is the deprecation of the "body" response
field. This PS attempts to get ahead and make the necessary
changes to no longer use deprecated fields.

Change-Id: Iac5d8cd2c658c337dfe7937db8124f3107d77e91
This commit is contained in:
DeJaeger, Darren (dd118r) 2021-06-23 12:06:14 -04:00 committed by Darren DeJaeger
parent 9aadc14777
commit e9a2309e0a
10 changed files with 13 additions and 13 deletions

View File

@ -79,7 +79,7 @@ class BaseResource(object):
raise Exception("%s: Invalid JSON in body: %s" % (req.path, jex))
def return_error(self, resp, status_code, message="", retry=False):
resp.body = json.dumps(
resp.text = json.dumps(
{
'type': 'error',
'message': message,

View File

@ -71,7 +71,7 @@ class Apply(api.BaseResource):
try:
with self.get_tiller(req, resp) as tiller:
msg = self.handle(req, documents, tiller)
resp.body = json.dumps({
resp.text = json.dumps({
'message': msg,
})
resp.content_type = 'application/json'

View File

@ -34,5 +34,5 @@ class Metrics(api.BaseResource):
return self.return_error(
resp, falcon.HTTP_500, message=err_message)
resp.content_type = content_type
resp.body = output
resp.text = output
resp.status = falcon.HTTP_200

View File

@ -33,7 +33,7 @@ class Rollback(api.BaseResource):
try:
with self.get_tiller(req, resp) as tiller:
msg = self.handle(req, release, tiller)
resp.body = json.dumps({
resp.text = json.dumps({
'message': msg,
})
resp.content_type = 'application/json'

View File

@ -53,7 +53,7 @@ class TestReleasesReleaseNameController(api.BaseResource):
'message': 'MESSAGE: Test Fail'
}
resp.body = json.dumps(msg)
resp.text = json.dumps(msg)
resp.status = falcon.HTTP_200
resp.content_type = 'application/json'
except LockException as e:
@ -100,7 +100,7 @@ class TestReleasesManifestController(api.BaseResource):
resp_body['code'] = 400
self.error(req.context, resp_body['message'])
resp.body = json.dumps(resp_body)
resp.text = json.dumps(resp_body)
return result
def _validate_documents(self, req, resp, documents):
@ -170,5 +170,5 @@ class TestReleasesManifestController(api.BaseResource):
message['test']['skipped'].append(release_name)
resp.status = falcon.HTTP_200
resp.body = json.dumps(message)
resp.text = json.dumps(message)
resp.content_type = 'application/json'

View File

@ -35,7 +35,7 @@ class Status(api.BaseResource):
with self.get_tiller(req, resp) as tiller:
message = self.handle(tiller)
resp.status = falcon.HTTP_200
resp.body = json.dumps(message)
resp.text = json.dumps(message)
resp.content_type = 'application/json'
except Exception as e:
@ -66,7 +66,7 @@ class Release(api.BaseResource):
try:
with self.get_tiller(req, resp) as tiller:
releases = self.handle(tiller)
resp.body = json.dumps({
resp.text = json.dumps({
'releases': releases,
})
resp.content_type = 'application/json'

View File

@ -79,7 +79,7 @@ class Validate(api.BaseResource):
resp_body['message'] = 'Armada validations failed'
resp_body['code'] = 400
resp.body = json.dumps(resp_body)
resp.text = json.dumps(resp_body)
except Exception as ex:
err_message = 'Failed to validate Armada Manifest'
self.logger.error(err_message, exc_info=ex)

View File

@ -27,7 +27,7 @@ class Versions(api.BaseResource):
def on_get(self, req, resp):
resp.status = falcon.HTTP_200
resp.body = json.dumps(
resp.text = json.dumps(
{'v1.0': {
'path': '/api/v1.0',
'status': 'stable'

View File

@ -156,7 +156,7 @@ class LoggingMiddleware(object):
user or '-', req_id or '-', external_ctx or '-', end_user or '-',
req.method, req.uri, resp.status)
self.logger.debug("Response body:%s", resp.body)
self.logger.debug("Response text:%s", resp.text)
def _log_headers(self, headers):
""" Log request headers, while scrubbing sensitive values

View File

@ -134,7 +134,7 @@ def format_error_resp(
'retry': retry
}
resp.body = json.dumps(error_response, default=str)
resp.text = json.dumps(error_response, default=str)
resp.content_type = 'application/json'
resp.status = status_code