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 packages/kubesdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "kubesdk"
version = "0.3.2"
version = "0.3.3"
description = "Fast, fully typed Kubernetes client for Python."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
3 changes: 2 additions & 1 deletion packages/kubesdk/src/kubesdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ def format(self, record):
from .client import APIRequestProcessingConfig, APIRequestLoggingConfig, DryRun, PropagationPolicy, LabelSelectorOp, \
QueryLabelSelectorRequirement, QueryLabelSelector, FieldSelectorOp, FieldSelectorRequirement, FieldSelector, \
K8sQueryParams, K8sAPIRequestLoggingConfig, get_k8s_resource, create_k8s_resource, update_k8s_resource, \
delete_k8s_resource, create_or_update_k8s_resource, WatchEventType, K8sResourceEvent, watch_k8s_resources
delete_k8s_resource, create_or_update_k8s_resource, WatchEventType, K8sResourceEvent, watch_k8s_resources, \
ResourceVersionMatch, FieldValidation
26 changes: 23 additions & 3 deletions packages/kubesdk/src/kubesdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ class LabelSelectorOp(str, Enum):
DoesNotExist = "DoesNotExist"


class ResourceVersionMatch(str, Enum):
NotOlderThan = "NotOlderThan"
Exact = "Exact"


class FieldValidation(str, Enum):
Ignore = "Ignore"
Warn = "Warn"
Strict = "Strict"


@dataclass(kw_only=True, frozen=True)
class QueryLabelSelectorRequirement:
key: str
Expand Down Expand Up @@ -142,14 +153,23 @@ class K8sQueryParams:
labelSelector: QueryLabelSelector | None = None
limit: int | None = None
resourceVersion: str | None = None
resourceVersionMatch: ResourceVersionMatch | None = None
timeoutSeconds: int | None = None
dryRun: DryRun | None = None

# create/update/patch/apply options
fieldManager: str | None = None
fieldValidation: FieldValidation | None = None
force: bool | None = None

# watch
watch: bool | None = None
allowWatchBookmarks: bool | None = None
sendInitialEvents: bool | None = None

# delete options
gracePeriodSeconds: int | None = None
propagationPolicy: PropagationPolicy | None = None
dryRun: DryRun | None = None
fieldManager: str | None = None
force: bool | None = None

def to_http_params(self) -> list[tuple[str, str]]:
items = []
Expand Down
40 changes: 22 additions & 18 deletions packages/kubesdk/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

# Use package-level import to not miss anything in __init__
from kubesdk import QueryLabelSelector, QueryLabelSelectorRequirement, LabelSelectorOp, \
FieldSelectorRequirement, FieldSelectorOp, FieldSelector, K8sQueryParams, DryRun, PropagationPolicy
FieldSelectorRequirement, FieldSelectorOp, FieldSelector, K8sQueryParams, DryRun, PropagationPolicy, \
ResourceVersionMatch, FieldValidation


class TestQueryLabelSelector(unittest.TestCase):
Expand Down Expand Up @@ -115,24 +116,27 @@ def test_basic_scalars_bools_enums(self):
dryRun=DryRun.All,
fieldManager="manager",
force=True,
resourceVersionMatch=ResourceVersionMatch.Exact,
fieldValidation=FieldValidation.Ignore
).to_http_params()
self.assertEqual(
params,
[
("pretty", "true"),
("continue", "token123"),
("limit", "10"),
("resourceVersion", "rv1"),
("timeoutSeconds", "5"),
("watch", "true"),
("allowWatchBookmarks", "false"),
("gracePeriodSeconds", "30"),
("propagationPolicy", "Foreground"),
("dryRun", "All"),
("fieldManager", "manager"),
("force", "true"),
],
)
expected_params = [
("pretty", "true"),
("continue", "token123"),
("limit", "10"),
("resourceVersion", "rv1"),
("timeoutSeconds", "5"),
("watch", "true"),
("allowWatchBookmarks", "false"),
("gracePeriodSeconds", "30"),
("propagationPolicy", "Foreground"),
("dryRun", "All"),
("fieldManager", "manager"),
("force", "true"),
("resourceVersionMatch", "Exact"),
("fieldValidation", "Ignore")
]
for param in expected_params:
self.assertIn(param, params)

def test_field_and_label_selector_objects(self):
field_sel = FieldSelector(
Expand Down
6 changes: 3 additions & 3 deletions uv.lock

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

Loading