Commit 2d1f5058 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Remove token from history

Refs: #4479
parent 20211cbb
......@@ -488,8 +488,12 @@ def set_command_params(parameters):
def run_one_cmd(exe_string, parser, cloud):
global _history
_history = History(parser.arguments['config'].get(
'global', 'history_file'))
try:
token = parser.arguments['config'].get_cloud(cloud, 'token').split()[0]
except Exception:
token = None
_history = History(
parser.arguments['config'].get('global', 'history_file'), token=token)
_history.add(' '.join([exe_string] + argv[1:]))
from kamaki.cli import one_command
one_command.run(cloud, parser, _help)
......
......@@ -37,8 +37,9 @@ import codecs
class History(object):
def __init__(self, filepath):
def __init__(self, filepath, token=None):
self.filepath = filepath
self.token = token
@classmethod
def _match(self, line, match_terms):
......@@ -58,6 +59,7 @@ class History(object):
return result[- limit:]
def add(self, line):
line = line.replace(self.token, '...') if self.token else line
with open(self.filepath, 'a+') as f:
f.write(line + '\n')
......
......@@ -55,7 +55,8 @@ class SynnefoAstakosClient(SynnefoAstakosClientOrig):
recvlog.info('data size: %s' % len(data))
token = request.headers.get('X-Auth-Token', '')
data = data.replace(token, '...') if token else data
recvlog.info('%s\n- - - - - - -' % data)
recvlog.info(data)
recvlog.info('- - - - - - -')
def _call_astakos(self, *args, **kwargs):
r = super(SynnefoAstakosClient, self)._call_astakos(*args, **kwargs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment