From 0fece87d8962539cd9d410e368be473275b0cee6 Mon Sep 17 00:00:00 2001 From: Fabian von Feilitzsch Date: Fri, 11 Jan 2019 13:59:08 -0500 Subject: [PATCH 1/2] take md5 of cache_id to prevent it from being too long --- 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..b0d47a49 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().decode('utf-8')) self.__resources = ResourceContainer({}, client=self) self.__cache_file = cache_file or os.path.join(tempfile.gettempdir(), default_cachefile_name) self.__init_cache() From 98c389d21c552cae05762a6198afc99a6c8d8172 Mon Sep 17 00:00:00 2001 From: Fabian von Feilitzsch Date: Fri, 11 Jan 2019 14:09:40 -0500 Subject: [PATCH 2/2] remove unecessary decode --- openshift/dynamic/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openshift/dynamic/client.py b/openshift/dynamic/client.py index b0d47a49..a79d0888 100755 --- a/openshift/dynamic/client.py +++ b/openshift/dynamic/client.py @@ -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(hashlib.md5(default_cache_id).hexdigest().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()