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

Set kubernetes_asyncio back to official package #368

Merged
merged 1 commit into from
Dec 1, 2021
Merged
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
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ toml = "^0.10.2"
colorama = "^0.4.4"
pyfiglet = "^0.8.post1"
curlify2 = "^1.0.0"
kubernetes-asyncio-cr-patch = "^12.1.2"
kubernetes_asyncio = "^12.1.2"

[tool.poetry.dev-dependencies]
pytest = "^6.2.4"
Expand Down
9 changes: 6 additions & 3 deletions servo/connectors/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@

import backoff
import kubernetes_asyncio
import kubernetes_asyncio.client.models
import kubernetes_asyncio.client
import kubernetes_asyncio.client.api_client
import kubernetes_asyncio.client.exceptions
import kubernetes_asyncio.client.models
import kubernetes_asyncio.watch
import pydantic

Expand Down Expand Up @@ -304,7 +305,7 @@ def namespace(self, namespace: str):
self.obj.metadata.namespace = namespace

@contextlib.asynccontextmanager
async def api_client(self) -> Generator[Any, None, None]:
async def api_client(self, default_headers: Dict[str, str] = {}) -> Generator[Any, None, None]:
"""The API client for the Kubernetes object. This is determined
by the ``apiVersion`` of the object configuration.

Expand All @@ -326,6 +327,8 @@ async def api_client(self) -> Generator[Any, None, None]:
)
# If we did find it, initialize that client version.
async with kubernetes_asyncio.client.api_client.ApiClient() as api:
for k, v in default_headers.items():
api.set_default_header(k, v)
yield c(api)

@classmethod
Expand Down Expand Up @@ -2384,7 +2387,7 @@ async def read_workfload_ref(self, namespace: str) -> None:

async def patch(self) -> None:
"""Update the changed attributes of the Rollout."""
async with self.api_client() as api_client:
async with self.api_client({'content-type': 'application/merge-patch+json'}) as api_client:
self.obj = RolloutObj.parse_obj(await api_client.patch_namespaced_custom_object(
namespace=self.namespace,
name=self.name,
Expand Down