Skip to content

Commit 8a57124

Browse files
Merge pull request #50 from d4rkstar/issue_100
fix(operator): invalid json in psql
2 parents 0df706b + fc266d8 commit 8a57124

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

actions/devel/psql/__main__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
#
18-
import nuvolaris.config as cfg
19-
import nuvolaris.couchdb_util as cu
20-
import logging, json
18+
import json
19+
from base64 import b64decode
2120

21+
from command.psql import Psql
2222
from common.authorize import Authorize
2323
from common.command_data import CommandData
24-
from command.psql import Psql
25-
from base64 import b64decode
24+
2625

2726
class ApiError(Exception):
2827
pass
@@ -60,10 +59,10 @@ def main(args):
6059
WARNING: the body will be received as base64 encoded string as this action will be deployed with --web raw enabled flag
6160
"""
6261
headers = args['__ow_headers']
63-
if('x-impersonate-auth' not in headers):
62+
if 'x-impersonate-auth' not in headers:
6463
return build_error("invalid request, missing mandatory header: x-impersonate-auth")
6564

66-
if(len(args['__ow_body']) == 0):
65+
if len(args['__ow_body']) == 0:
6766
return build_error("invalid request, no command payload received")
6867

6968
try:

actions/devel/psql/command/psql.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from common.command_data import CommandData
2323
from psycopg.rows import dict_row
24+
import json
2425

2526
class Psql():
2627
"""
@@ -52,7 +53,7 @@ def _query(self, input:CommandData):
5253
with conn.cursor(row_factory=dict_row) as cur:
5354
cur.execute(query)
5455
result = cur.fetchall()
55-
input.result(str(result))
56+
input.result(json.dumps(result))
5657
input.status(200)
5758
return input
5859

0 commit comments

Comments
 (0)