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

Commit

Permalink
* Fix parameter error
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis committed Mar 31, 2021
1 parent b857e69 commit fb44b2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions changelogs/fragments/405-cachefile_dynamic_client.yml
Original file line number Diff line number Diff line change
@@ -1,4 +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).
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).
15 changes: 7 additions & 8 deletions plugins/module_utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from ansible_collections.community.kubernetes.plugins.module_utils.args_common import (AUTH_ARG_MAP, AUTH_ARG_SPEC)

from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.six import iteritems, string_types
from ansible.module_utils.six import iteritems, string_types, PY3
from ansible.module_utils._text import to_native, to_bytes, to_text
from ansible.module_utils.common.dict_transformations import dict_merge
from ansible.module_utils.parsing.convert_bool import boolean
Expand Down Expand Up @@ -139,15 +139,14 @@ def get_user():
return None


def get_default_cache_id(configuration):
import six
def get_default_cache_id(client):
user = get_user()
if user:
cache_id = "{0}-{1}".format(configuration.host, user)
cache_id = "{0}-{1}".format(client.configuration.host, user)
else:
cache_id = configuration.host
cache_id = client.configuration.host

if six.PY3:
if PY3:
return cache_id.encode('utf-8')

return cache_id
Expand Down Expand Up @@ -216,9 +215,9 @@ def auth_set(*names):
client = get_api_client._pool[digest]
return client

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

kubeclient = kubernetes.client.ApiClient(configuration)
cache_file = generate_cache_file(kubeclient)
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
openshift>=0.6.2
requests-oauthlib
six

0 comments on commit fb44b2b

Please sign in to comment.