Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document a breaking change in the default configuration #1303

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Kubernetes API Version: 1.16.14

Kubernetes API Version: 1.16.14

**Breaking Change:**

- `kubernetes.config.Configuration()` will now return the default "initial" configuration, `kubernetes.config.Configuration.get_default_copy()` will return the default configuration if there is a default set via `Configuration.set_default(c)`, otherwise, it will also return the default "initial" configuration. [OpenAPITools/openapi-generator#4485](https://github.com/OpenAPITools/openapi-generator/pull/4485), [OpenAPITools/openapi-generator#5315](https://github.com/OpenAPITools/openapi-generator/pull/5315)

**API Change:**

- Resolve regression in metadata.managedFields handling in update/patch requests submitted by older API clients ([#91748](https://github.com/kubernetes/kubernetes/pull/91748), [@apelisse](https://github.com/apelisse)) [SIG API Machinery and Testing]
Expand Down
39 changes: 39 additions & 0 deletions kubernetes/test/test_configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# coding: utf-8

import unittest

from kubernetes.client import Configuration

class TestConfiguration(unittest.TestCase):

def setUp(self):
pass

def tearDown(self):
# reset Configuration
Configuration.set_default(None)

def testConfiguration(self):
# check that different instances use different dictionaries
c1 = Configuration()
c2 = Configuration()
self.assertNotEqual(id(c1.api_key), id(c2.api_key))
self.assertNotEqual(id(c1.api_key_prefix), id(c2.api_key_prefix))

def testDefaultConfiguration(self):
# prepare default configuration
c1 = Configuration(host="example.com")
c1.debug = True
Configuration.set_default(c1)

# get default configuration
c2 = Configuration.get_default_copy()
self.assertEqual(c2.host, "example.com")
self.assertTrue(c2.debug)

self.assertNotEqual(id(c1.api_key), id(c2.api_key))
self.assertNotEqual(id(c1.api_key_prefix), id(c2.api_key_prefix))


if __name__ == '__main__':
unittest.main()