From a1c5dd091543c49c87de6babc85f62fa42e5194c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wcis=C5=82o?= <33344684+m-wcislo@users.noreply.github.com> Date: Fri, 16 Dec 2022 16:12:45 +0100 Subject: [PATCH] fix disabling cert validation (#124) --- CHANGELOG.md | 6 ++++++ src/KubeLibrary/KubeLibrary.py | 3 +-- src/KubeLibrary/version.py | 2 +- test/test_KubeLibrary.py | 3 +-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b2f42..e8800dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## In progress + +## [0.8.1] - 2022-12-16 +### Added - Add proxy configuration fetched from `HTTP_PROXY` or `http_proxy` environment variable +### Fixed +Fix disabling cert validation [#124](https://github.com/devopsspiral/KubeLibrary/pull/124) + ## [0.8.0] - 2022-10-27 ### Added - Add function list_namespaced_stateful_set_by_pattern [#114](https://github.com/devopsspiral/KubeLibrary/pull/113) by [@siaomingjeng](https://github.com/siaomingjeng) diff --git a/src/KubeLibrary/KubeLibrary.py b/src/KubeLibrary/KubeLibrary.py index 3f73adc..ebff896 100755 --- a/src/KubeLibrary/KubeLibrary.py +++ b/src/KubeLibrary/KubeLibrary.py @@ -1,6 +1,5 @@ import json import re -import ssl import urllib3 from os import environ @@ -276,7 +275,7 @@ def reload_config(self, kube_config=None, context=None, api_url=None, bearer_tok def _add_api(self, reference, class_name): self.__dict__[reference] = class_name(self.api_client) if not self.cert_validation: - self.__dict__[reference].api_client.rest_client.pool_manager.connection_pool_kw['cert_reqs'] = ssl.CERT_NONE + self.__dict__[reference].api_client.configuration.verify_ssl = False def k8s_api_ping(self): """Performs GET on /api/v1/ for simple check of API availability. diff --git a/src/KubeLibrary/version.py b/src/KubeLibrary/version.py index 8675559..73baf8f 100644 --- a/src/KubeLibrary/version.py +++ b/src/KubeLibrary/version.py @@ -1 +1 @@ -version = "0.8.0" +version = "0.8.1" diff --git a/test/test_KubeLibrary.py b/test/test_KubeLibrary.py index b99291b..7cae67e 100644 --- a/test/test_KubeLibrary.py +++ b/test/test_KubeLibrary.py @@ -1,7 +1,6 @@ import json import mock import re -import ssl import unittest from KubeLibrary import KubeLibrary from KubeLibrary.exceptions import BearerTokenWithPrefixException @@ -306,7 +305,7 @@ def test_KubeLibrary_inits_without_cert_validation(self): kl = KubeLibrary(kube_config='test/resources/k3d', cert_validation=False) for api in TestKubeLibrary.apis: target = getattr(kl, api) - self.assertEqual(target.api_client.rest_client.pool_manager.connection_pool_kw['cert_reqs'], ssl.CERT_NONE) + self.assertEqual(target.api_client.configuration.verify_ssl, False) @responses.activate def test_KubeLibrary_inits_with_bearer_token(self):