From 8abd6a8a9cc7e6493d64ca7de084e5eaf3f824d6 Mon Sep 17 00:00:00 2001 From: Fabian von Feilitzsch Date: Fri, 11 Jan 2019 14:35:33 -0500 Subject: [PATCH] take md5 of cache_id to prevent it from being too long (#259) * take md5 of cache_id to prevent it from being too long * remove unecessary decode --- openshift/dynamic/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openshift/dynamic/client.py b/openshift/dynamic/client.py index 3713b5a3..a79d0888 100755 --- a/openshift/dynamic/client.py +++ b/openshift/dynamic/client.py @@ -4,7 +4,7 @@ import sys import copy import json -import base64 +import hashlib import tempfile from functools import partial from six import PY2, PY3 @@ -97,7 +97,7 @@ def __init__(self, client, cache_file=None): default_cache_id = self.configuration.host if PY3: default_cache_id = default_cache_id.encode('utf-8') - default_cachefile_name = 'osrcp-{0}.json'.format(base64.b64encode(default_cache_id).decode('utf-8')) + default_cachefile_name = 'osrcp-{0}.json'.format(hashlib.md5(default_cache_id).hexdigest()) self.__resources = ResourceContainer({}, client=self) self.__cache_file = cache_file or os.path.join(tempfile.gettempdir(), default_cachefile_name) self.__init_cache()