Skip to content
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "lightkube"
version = "1.0.0"
version = "1.0.1"
description = "Lightweight kubernetes client library"
readme = "README.md"
authors = [
Expand Down
9 changes: 7 additions & 2 deletions src/lightkube/config/client_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import ssl
import subprocess
from dataclasses import asdict, dataclass, field
from dataclasses import dataclass, field, fields
from pathlib import Path
from typing import AsyncGenerator, Callable, Dict, Generator, List, Mapping, Optional, Sequence, Tuple, overload

Expand All @@ -14,6 +14,11 @@
from .models import Cluster, FileStr, User, UserExec


def _shallow_asdict(instance) -> dict:
"""Return a dataclass's fields without copying their values."""
return {data_field.name: getattr(instance, data_field.name) for data_field in fields(instance)}


@dataclass
class ConnectionParams:
"""All connection parameters used by Client and AsyncClient"""
Expand All @@ -29,7 +34,7 @@ def httpx_params(self, config: SingleConfig) -> dict:
assert config.user, "Missing user"
verify = verify_cluster(config.cluster, config.user, config.abs_file, trust_env=self.trust_env)
auth = user_auth(config.user)
return dict(base_url=base_url, verify=verify, auth=auth, **asdict(self))
return dict(base_url=base_url, verify=verify, auth=auth, **_shallow_asdict(self))


def Client(config: SingleConfig, conn_parameters: ConnectionParams) -> httpx.Client:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_client_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ def test_user_cert_data():
assert Path(certs[1]).read_text() == "key"


def test_connection_params_preserves_transport():
cfg = single_conf(cluster=models.Cluster(server="https://localhost"), user=models.User(token="token"))
transport = httpx.AsyncHTTPTransport(http2=True)

params = client_adapter.ConnectionParams(transport=transport).httpx_params(cfg)

assert params["transport"] is transport


@unittest.mock.patch("ssl.create_default_context")
def test_verify_cluster_ca_and_cert(create_default_context):
data_dir = Path(__file__).parent.joinpath("data")
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

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

Loading