Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
* Add changelog
Browse files Browse the repository at this point in the history
	* Address reviewer's comments
	* Add six in requirements.txt

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
  • Loading branch information
alinabuzachis committed Mar 31, 2021
1 parent aaaaff7 commit b857e69
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/405-cachefile_dynamic_client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
minor_changes:
- Add logic for cache file name generation (https://github.com/ansible-collections/community.kubernetes/pull/405).
- Add cache_file when DynamicClient is created (https://github.com/ansible-collections/community.kubernetes/pull/405).
7 changes: 3 additions & 4 deletions plugins/module_utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import os
import traceback
import sys
import six
import hashlib
import tempfile
from datetime import datetime
from distutils.version import LooseVersion

Expand Down Expand Up @@ -143,6 +140,7 @@ def get_user():


def get_default_cache_id(configuration):
import six
user = get_user()
if user:
cache_id = "{0}-{1}".format(configuration.host, user)
Expand Down Expand Up @@ -219,13 +217,14 @@ def auth_set(*names):
return client

def generate_cache_file(configuration):
import hashlib
return 'osrcp-{0}.json'.format(hashlib.sha1(get_default_cache_id(configuration)).hexdigest())

kubeclient = kubernetes.client.ApiClient(configuration)
cache_file = generate_cache_file(kubeclient)

try:
client = DynamicClient(kubernetes.client.ApiClient(configuration), cache_file)
client = DynamicClient(kubeclient, cache_file)
except Exception as err:
_raise_or_fail(err, 'Failed to get client due to %s')

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
openshift>=0.6.2
requests-oauthlib
six

0 comments on commit b857e69

Please sign in to comment.