ops.interface-kube-control 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ops_interface_kube_control-0.2.2/MANIFEST.in +1 -0
- ops_interface_kube_control-0.2.2/PKG-INFO +43 -0
- ops_interface_kube_control-0.2.2/README.md +22 -0
- {ops_interface_kube_control-0.2.0 → ops_interface_kube_control-0.2.2}/ops/interface_kube_control/model.py +7 -7
- {ops_interface_kube_control-0.2.0 → ops_interface_kube_control-0.2.2}/ops/interface_kube_control/provides.py +37 -20
- {ops_interface_kube_control-0.2.0 → ops_interface_kube_control-0.2.2}/ops/interface_kube_control/requires.py +23 -27
- ops_interface_kube_control-0.2.2/ops.interface_kube_control.egg-info/PKG-INFO +43 -0
- {ops_interface_kube_control-0.2.0 → ops_interface_kube_control-0.2.2}/ops.interface_kube_control.egg-info/SOURCES.txt +3 -1
- ops_interface_kube_control-0.2.2/ops.interface_kube_control.egg-info/requires.txt +2 -0
- ops_interface_kube_control-0.2.2/ops.interface_kube_control.egg-info/top_level.txt +3 -0
- ops_interface_kube_control-0.2.2/pyproject.toml +87 -0
- ops_interface_kube_control-0.2.2/tox.ini +56 -0
- ops_interface_kube_control-0.2.2/uv.lock +1130 -0
- ops_interface_kube_control-0.2.0/PKG-INFO +0 -27
- ops_interface_kube_control-0.2.0/README.md +0 -0
- ops_interface_kube_control-0.2.0/ops.interface_kube_control.egg-info/PKG-INFO +0 -27
- ops_interface_kube_control-0.2.0/ops.interface_kube_control.egg-info/requires.txt +0 -3
- ops_interface_kube_control-0.2.0/ops.interface_kube_control.egg-info/top_level.txt +0 -1
- ops_interface_kube_control-0.2.0/setup.py +0 -33
- ops_interface_kube_control-0.2.0/tox.ini +0 -35
- {ops_interface_kube_control-0.2.0 → ops_interface_kube_control-0.2.2}/ops/interface_kube_control/__init__.py +0 -0
- {ops_interface_kube_control-0.2.0 → ops_interface_kube_control-0.2.2}/ops.interface_kube_control.egg-info/dependency_links.txt +0 -0
- {ops_interface_kube_control-0.2.0 → ops_interface_kube_control-0.2.2}/ops.interface_kube_control.egg-info/zip-safe +0 -0
- {ops_interface_kube_control-0.2.0 → ops_interface_kube_control-0.2.2}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
prune tests
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ops.interface_kube_control
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Kube-Control Interface for Charmed Operators
|
|
5
|
+
Author-email: Adam Dyess <adam.dyess@canonical.com>, Mateo Florido <mateo.florido@canonical.com>
|
|
6
|
+
License: Apache
|
|
7
|
+
Project-URL: Repository, https://github.com/charmed-kubernetes/interface-kube-control
|
|
8
|
+
Keywords: juju,charming,kubernetes,ops,framework,interface
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Requires-Python: >3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: ops
|
|
20
|
+
Requires-Dist: pydantic<2
|
|
21
|
+
|
|
22
|
+
# ops.interface_kube_control
|
|
23
|
+
|
|
24
|
+
## Rationale for this library
|
|
25
|
+
Many project need credentials in a kubernetes cluster to apply their workloads
|
|
26
|
+
using credentials from the kubernetes cluster. Outside the cluster, these charms
|
|
27
|
+
need access to the cluster's API and credentials within that API.
|
|
28
|
+
|
|
29
|
+
This library supports the `kube-control` relation to relate to a kubernetes
|
|
30
|
+
control-plane application, to provide access to that endpoint.
|
|
31
|
+
|
|
32
|
+
## Contributing
|
|
33
|
+
This library provides an interface for `ops` charms to use to connect to this interface.
|
|
34
|
+
|
|
35
|
+
* Make adjustments
|
|
36
|
+
* test the changes by running tox
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
tox
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
* Raise your PR and contact maintainers
|
|
43
|
+
* Once merged, tag with an `ops-vX.X.X` to publish a new pypi package
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# ops.interface_kube_control
|
|
2
|
+
|
|
3
|
+
## Rationale for this library
|
|
4
|
+
Many project need credentials in a kubernetes cluster to apply their workloads
|
|
5
|
+
using credentials from the kubernetes cluster. Outside the cluster, these charms
|
|
6
|
+
need access to the cluster's API and credentials within that API.
|
|
7
|
+
|
|
8
|
+
This library supports the `kube-control` relation to relate to a kubernetes
|
|
9
|
+
control-plane application, to provide access to that endpoint.
|
|
10
|
+
|
|
11
|
+
## Contributing
|
|
12
|
+
This library provides an interface for `ops` charms to use to connect to this interface.
|
|
13
|
+
|
|
14
|
+
* Make adjustments
|
|
15
|
+
* test the changes by running tox
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
tox
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
* Raise your PR and contact maintainers
|
|
22
|
+
* Once merged, tag with an `ops-vX.X.X` to publish a new pypi package
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
from pydantic import Field, AnyHttpUrl, BaseModel, Json
|
|
2
1
|
import json
|
|
3
|
-
import ops
|
|
4
|
-
from typing import List, Dict, Optional
|
|
5
2
|
import re
|
|
3
|
+
from typing import Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
from pydantic import AnyHttpUrl, BaseModel, Field, Json
|
|
6
|
+
|
|
7
|
+
import ops
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class _ValidatedStr:
|
|
@@ -62,7 +64,7 @@ class AuthRequest(BaseModel):
|
|
|
62
64
|
kubelet_user: Optional[str]
|
|
63
65
|
auth_group: Optional[str]
|
|
64
66
|
schema_vers: Json[List[int]] = Field(default_factory=list)
|
|
65
|
-
unit: Optional[str]
|
|
67
|
+
unit: Optional[str] = None
|
|
66
68
|
|
|
67
69
|
def dict(self, **kwds):
|
|
68
70
|
d = super().dict(**kwds)
|
|
@@ -133,9 +135,7 @@ class Data(BaseModel):
|
|
|
133
135
|
if not self.ca_certificate_secret_id:
|
|
134
136
|
return None
|
|
135
137
|
try:
|
|
136
|
-
secret = model.get_secret(
|
|
137
|
-
id=self.ca_certificate_secret_id, label="ca-certificate"
|
|
138
|
-
)
|
|
138
|
+
secret = model.get_secret(id=self.ca_certificate_secret_id, label="ca-certificate")
|
|
139
139
|
return secret.get_content(refresh=True)["ca-certificate"].encode()
|
|
140
140
|
except ops.SecretNotFoundError:
|
|
141
141
|
return None
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import ipaddress
|
|
1
2
|
import json
|
|
2
3
|
import logging
|
|
4
|
+
from typing import Generator, List, Tuple
|
|
5
|
+
import ops
|
|
3
6
|
|
|
4
7
|
from .model import AuthRequest, Creds, Label, Taint
|
|
5
|
-
from ops import CharmBase, Relation, SecretNotFoundError, Unit
|
|
6
|
-
from typing import Generator, List, Tuple
|
|
7
8
|
|
|
8
9
|
log = logging.getLogger("KubeControlProvides")
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
class KubeControlProvides:
|
|
12
|
+
class KubeControlProvides(ops.Object):
|
|
12
13
|
"""Implements the Provides side of the kube-control interface."""
|
|
13
14
|
|
|
14
|
-
def __init__(self, charm: CharmBase, endpoint: str = "kube-control", schemas="0,1"):
|
|
15
|
+
def __init__(self, charm: ops.CharmBase, endpoint: str = "kube-control", schemas="0,1"):
|
|
16
|
+
super().__init__(charm, f"{endpoint}-provider")
|
|
15
17
|
self.charm = charm
|
|
16
18
|
self.endpoint = endpoint
|
|
19
|
+
self.framework.observe(charm.on.secret_remove, self._on_secret_remove)
|
|
17
20
|
|
|
18
21
|
@property
|
|
19
22
|
def auth_requests(self) -> List[AuthRequest]:
|
|
@@ -40,18 +43,18 @@ class KubeControlProvides:
|
|
|
40
43
|
@property
|
|
41
44
|
def ingress_addresses(self) -> List[str]:
|
|
42
45
|
"""Ingress addresses for this endpoint."""
|
|
46
|
+
binding = self.charm.model.get_binding(self.endpoint)
|
|
43
47
|
return [
|
|
44
48
|
# RFC 5280 section 4.2.1.6: "For IP version 6 ... the octet string
|
|
45
49
|
# MUST contain exactly sixteen octets." We'll use .exploded to be
|
|
46
50
|
# safe.
|
|
47
|
-
|
|
48
|
-
for addr in
|
|
49
|
-
|
|
50
|
-
).network.ingress_addresses
|
|
51
|
+
ip.exploded
|
|
52
|
+
for addr in (binding and binding.network.ingress_addresses or [])
|
|
53
|
+
if (ip := ipaddress.ip_address(addr))
|
|
51
54
|
]
|
|
52
55
|
|
|
53
56
|
@property
|
|
54
|
-
def relations(self) -> List[Relation]:
|
|
57
|
+
def relations(self) -> List[ops.Relation]:
|
|
55
58
|
"""List of relations on this endpoint."""
|
|
56
59
|
return self.charm.model.relations[self.endpoint]
|
|
57
60
|
|
|
@@ -68,7 +71,7 @@ class KubeControlProvides:
|
|
|
68
71
|
ca_certificate str: The CA certificate in PEM format.
|
|
69
72
|
"""
|
|
70
73
|
content = {"ca-certificate": ca_certificate}
|
|
71
|
-
secret = self.
|
|
74
|
+
secret = self._refresh_secret_content(
|
|
72
75
|
"ca-certificate", content, "Kubernetes API endpoint CA certificate"
|
|
73
76
|
)
|
|
74
77
|
for relation in self.relations:
|
|
@@ -142,17 +145,29 @@ class KubeControlProvides:
|
|
|
142
145
|
for relation in self.relations:
|
|
143
146
|
relation.data[self.unit]["taints"] = value
|
|
144
147
|
|
|
145
|
-
def
|
|
148
|
+
def _on_secret_remove(self, event: ops.SecretRemoveEvent) -> None:
|
|
149
|
+
"""Remove revisions for secrets matching this object's endpoint.
|
|
150
|
+
Args:
|
|
151
|
+
event (ops.SecretRemoveEvent): The secret removal event.
|
|
152
|
+
"""
|
|
153
|
+
try:
|
|
154
|
+
content = event.secret.get_content()
|
|
155
|
+
except ops.SecretNotFoundError:
|
|
156
|
+
return
|
|
157
|
+
if content.get("endpoint") == self.endpoint:
|
|
158
|
+
log.info(f"Removing secret {event.secret.id}")
|
|
159
|
+
event.secret.remove_revision(event.revision)
|
|
160
|
+
|
|
161
|
+
def _refresh_secret_content(self, label, content, description=None):
|
|
146
162
|
"""Refresh the content of a secret."""
|
|
163
|
+
content = {**content, "endpoint": self.endpoint}
|
|
147
164
|
try:
|
|
148
165
|
secret = self.charm.model.get_secret(label=label)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
secret
|
|
154
|
-
content, label=label, description=description
|
|
155
|
-
)
|
|
166
|
+
except ops.SecretNotFoundError:
|
|
167
|
+
secret = self.charm.app.add_secret(content, label=label, description=description)
|
|
168
|
+
if secret.get_content(refresh=True) != content:
|
|
169
|
+
log.info("Refresh content %s", secret.id)
|
|
170
|
+
secret.set_content(content)
|
|
156
171
|
return secret
|
|
157
172
|
|
|
158
173
|
def closed_auth_creds(self) -> Generator[Tuple[str, Creds], None, None]:
|
|
@@ -197,6 +212,8 @@ class KubeControlProvides:
|
|
|
197
212
|
) -> None:
|
|
198
213
|
"""Send authorization tokens to the requesting unit."""
|
|
199
214
|
creds, request_relation = {}, None
|
|
215
|
+
if not request.unit:
|
|
216
|
+
raise ValueError("Request unit is required")
|
|
200
217
|
request_unit = self.charm.model.get_unit(request.unit)
|
|
201
218
|
|
|
202
219
|
for relation in self.relations:
|
|
@@ -220,7 +237,7 @@ class KubeControlProvides:
|
|
|
220
237
|
}
|
|
221
238
|
label = f"{request.user}-creds"
|
|
222
239
|
description = f"Credentials for {request.user}"
|
|
223
|
-
secret = self.
|
|
240
|
+
secret = self._refresh_secret_content(label, content, description)
|
|
224
241
|
if secret.id:
|
|
225
242
|
log.info(f"Granting secret {secret.id} to {request_relation.name}")
|
|
226
243
|
secret.grant(request_relation, unit=request_unit)
|
|
@@ -241,6 +258,6 @@ class KubeControlProvides:
|
|
|
241
258
|
relation.data[self.unit]["creds"] = value
|
|
242
259
|
|
|
243
260
|
@property
|
|
244
|
-
def unit(self) -> Unit:
|
|
261
|
+
def unit(self) -> ops.Unit:
|
|
245
262
|
"""Local unit."""
|
|
246
263
|
return self.charm.unit
|
|
@@ -8,30 +8,33 @@ style rather than the reactive style.
|
|
|
8
8
|
|
|
9
9
|
import base64
|
|
10
10
|
import logging
|
|
11
|
+
from functools import cached_property
|
|
11
12
|
from os import PathLike
|
|
12
13
|
from pathlib import Path
|
|
13
|
-
from typing import Dict,
|
|
14
|
+
from typing import Any, Dict, List, Mapping, Optional
|
|
14
15
|
|
|
15
16
|
import yaml
|
|
16
|
-
from
|
|
17
|
-
from .model import AuthRequest, Creds, Data, Taint, Label
|
|
18
|
-
from pydantic import ValidationError
|
|
17
|
+
from pydantic import ValidationError, parse_obj_as
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
from
|
|
19
|
+
import ops
|
|
20
|
+
|
|
21
|
+
from .model import AuthRequest, Creds, Data, Label, Taint
|
|
23
22
|
|
|
24
23
|
log = logging.getLogger("KubeControlRequirer")
|
|
25
24
|
JUJU_CLUSTER = "juju-cluster"
|
|
26
25
|
JUJU_CONTEXT = "juju-context"
|
|
27
26
|
|
|
28
27
|
|
|
29
|
-
class
|
|
28
|
+
class RelationNotReady(Exception):
|
|
29
|
+
"""Exception raised when the relation is not ready."""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class KubeControlRequirer(ops.Object):
|
|
30
33
|
"""
|
|
31
34
|
Implements the requirer side of the kube-control interface.
|
|
32
35
|
"""
|
|
33
36
|
|
|
34
|
-
def __init__(self, charm: CharmBase, endpoint: str = "kube-control", schemas="0"):
|
|
37
|
+
def __init__(self, charm: ops.CharmBase, endpoint: str = "kube-control", schemas="0"):
|
|
35
38
|
super().__init__(charm, f"relation-{endpoint}")
|
|
36
39
|
self.endpoint = endpoint
|
|
37
40
|
# comma-separated set of schemas to advertise support
|
|
@@ -40,23 +43,23 @@ class KubeControlRequirer(Object):
|
|
|
40
43
|
self.schema_ver = [int(v) for v in schemas.split(",")]
|
|
41
44
|
|
|
42
45
|
@cached_property
|
|
43
|
-
def relation(self) -> Optional[Relation]:
|
|
46
|
+
def relation(self) -> Optional[ops.Relation]:
|
|
44
47
|
"""The lone relation endpoint or None."""
|
|
45
48
|
return self.model.get_relation(self.endpoint)
|
|
46
49
|
|
|
47
50
|
@cached_property
|
|
48
|
-
def _data(self) ->
|
|
51
|
+
def _data(self) -> Data:
|
|
49
52
|
if self.relation and self.relation.units:
|
|
50
|
-
rx = {}
|
|
53
|
+
rx: Dict[str, str] = {}
|
|
51
54
|
for unit in self.relation.units:
|
|
52
55
|
rx.update(self.relation.data[unit])
|
|
53
|
-
return Data
|
|
54
|
-
|
|
56
|
+
return parse_obj_as(Data, rx)
|
|
57
|
+
raise RelationNotReady("No unit data available")
|
|
55
58
|
|
|
56
59
|
def evaluate_relation(self, event) -> Optional[str]:
|
|
57
60
|
"""Determine if relation is ready."""
|
|
58
61
|
no_relation = not self.relation or (
|
|
59
|
-
isinstance(event, RelationBrokenEvent) and event.relation is self.relation
|
|
62
|
+
isinstance(event, ops.RelationBrokenEvent) and event.relation is self.relation
|
|
60
63
|
)
|
|
61
64
|
if not self.is_ready:
|
|
62
65
|
if no_relation:
|
|
@@ -72,14 +75,12 @@ class KubeControlRequirer(Object):
|
|
|
72
75
|
except ValidationError as ve:
|
|
73
76
|
log.error(f"{self.endpoint} relation data not yet valid. ({ve}")
|
|
74
77
|
return False
|
|
75
|
-
|
|
78
|
+
except RelationNotReady:
|
|
76
79
|
log.error(f"{self.endpoint} relation data not yet available.")
|
|
77
80
|
return False
|
|
78
81
|
return True
|
|
79
82
|
|
|
80
|
-
def create_kubeconfig(
|
|
81
|
-
self, ca: PathLike, kubeconfig: PathLike, user: str, k8s_user: str
|
|
82
|
-
):
|
|
83
|
+
def create_kubeconfig(self, ca: PathLike, kubeconfig: PathLike, user: str, k8s_user: str):
|
|
83
84
|
"""Write kubeconfig based on available creds."""
|
|
84
85
|
creds = self.get_auth_credentials(k8s_user)
|
|
85
86
|
endpoints = self.get_api_endpoints()
|
|
@@ -153,7 +154,7 @@ class KubeControlRequirer(Object):
|
|
|
153
154
|
}
|
|
154
155
|
return None
|
|
155
156
|
|
|
156
|
-
def get_dns(self) -> Mapping[str,
|
|
157
|
+
def get_dns(self) -> Mapping[str, Any]:
|
|
157
158
|
"""
|
|
158
159
|
Return DNS info provided by the control-plane.
|
|
159
160
|
"""
|
|
@@ -170,10 +171,7 @@ class KubeControlRequirer(Object):
|
|
|
170
171
|
"""
|
|
171
172
|
keys = ["port", "domain", "sdn-ip", "enable-kube-dns"]
|
|
172
173
|
dns_info = self.get_dns()
|
|
173
|
-
return (
|
|
174
|
-
set(dns_info.keys()) == set(keys)
|
|
175
|
-
and dns_info["enable-kube-dns"] is not None
|
|
176
|
-
)
|
|
174
|
+
return set(dns_info.keys()) == set(keys) and dns_info["enable-kube-dns"] is not None
|
|
177
175
|
|
|
178
176
|
def set_auth_request(self, user, group="system:nodes") -> None:
|
|
179
177
|
"""Notify control-plane that we are requesting auth.
|
|
@@ -190,9 +188,7 @@ class KubeControlRequirer(Object):
|
|
|
190
188
|
if self.relation:
|
|
191
189
|
req = AuthRequest(kubelet_user=user, auth_group=group)
|
|
192
190
|
req.schema_vers = self.schema_ver
|
|
193
|
-
log.info(
|
|
194
|
-
f"Auth Req for {user} with group {group} on schema {self.schema_ver}"
|
|
195
|
-
)
|
|
191
|
+
log.info(f"Auth Req for {user} with group {group} on schema {self.schema_ver}")
|
|
196
192
|
self.relation.data[self.model.unit].update(req.dict(exclude_none=True))
|
|
197
193
|
|
|
198
194
|
def set_gpu(self, enabled=True):
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ops.interface_kube_control
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Kube-Control Interface for Charmed Operators
|
|
5
|
+
Author-email: Adam Dyess <adam.dyess@canonical.com>, Mateo Florido <mateo.florido@canonical.com>
|
|
6
|
+
License: Apache
|
|
7
|
+
Project-URL: Repository, https://github.com/charmed-kubernetes/interface-kube-control
|
|
8
|
+
Keywords: juju,charming,kubernetes,ops,framework,interface
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Requires-Python: >3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: ops
|
|
20
|
+
Requires-Dist: pydantic<2
|
|
21
|
+
|
|
22
|
+
# ops.interface_kube_control
|
|
23
|
+
|
|
24
|
+
## Rationale for this library
|
|
25
|
+
Many project need credentials in a kubernetes cluster to apply their workloads
|
|
26
|
+
using credentials from the kubernetes cluster. Outside the cluster, these charms
|
|
27
|
+
need access to the cluster's API and credentials within that API.
|
|
28
|
+
|
|
29
|
+
This library supports the `kube-control` relation to relate to a kubernetes
|
|
30
|
+
control-plane application, to provide access to that endpoint.
|
|
31
|
+
|
|
32
|
+
## Contributing
|
|
33
|
+
This library provides an interface for `ops` charms to use to connect to this interface.
|
|
34
|
+
|
|
35
|
+
* Make adjustments
|
|
36
|
+
* test the changes by running tox
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
tox
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
* Raise your PR and contact maintainers
|
|
43
|
+
* Once merged, tag with an `ops-vX.X.X` to publish a new pypi package
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools >= 61.0", "setuptools_scm"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[tool.setuptools_scm]
|
|
6
|
+
version_scheme = "guess-next-dev"
|
|
7
|
+
local_scheme = "node-and-date"
|
|
8
|
+
root = ".."
|
|
9
|
+
|
|
10
|
+
[project]
|
|
11
|
+
name = "ops.interface_kube_control"
|
|
12
|
+
dynamic = ["version"]
|
|
13
|
+
description = "Kube-Control Interface for Charmed Operators"
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
requires-python = ">3.8"
|
|
16
|
+
license = { text = "Apache" }
|
|
17
|
+
authors = [
|
|
18
|
+
{ name= "Adam Dyess", email = "adam.dyess@canonical.com" },
|
|
19
|
+
{ name= "Mateo Florido", email = "mateo.florido@canonical.com" }
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"ops",
|
|
23
|
+
"pydantic<2"
|
|
24
|
+
]
|
|
25
|
+
keywords = [
|
|
26
|
+
"juju",
|
|
27
|
+
"charming",
|
|
28
|
+
"kubernetes",
|
|
29
|
+
"ops",
|
|
30
|
+
"framework",
|
|
31
|
+
"interface",
|
|
32
|
+
]
|
|
33
|
+
classifiers = [
|
|
34
|
+
"License :: OSI Approved :: Apache Software License",
|
|
35
|
+
"Programming Language :: Python",
|
|
36
|
+
"Programming Language :: Python :: 3",
|
|
37
|
+
"Programming Language :: Python :: 3.8",
|
|
38
|
+
"Programming Language :: Python :: 3.9",
|
|
39
|
+
"Programming Language :: Python :: 3.10",
|
|
40
|
+
"Programming Language :: Python :: 3.11",
|
|
41
|
+
"Programming Language :: Python :: 3.12"
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Repository = "https://github.com/charmed-kubernetes/interface-kube-control"
|
|
46
|
+
|
|
47
|
+
# Testing tools configuration
|
|
48
|
+
[tool.coverage.run]
|
|
49
|
+
branch = true
|
|
50
|
+
|
|
51
|
+
[tool.coverage.report]
|
|
52
|
+
show_missing = true
|
|
53
|
+
|
|
54
|
+
[tool.isort]
|
|
55
|
+
line_length = 99
|
|
56
|
+
profile = "black"
|
|
57
|
+
|
|
58
|
+
[tool.mypy]
|
|
59
|
+
explicit_package_bases = true
|
|
60
|
+
namespace_packages = true
|
|
61
|
+
plugins = "pydantic.mypy"
|
|
62
|
+
|
|
63
|
+
[tool.ruff]
|
|
64
|
+
line-length = 99
|
|
65
|
+
extend-exclude = ["__pycache__", "*.egg_info"]
|
|
66
|
+
|
|
67
|
+
[tool.setuptools]
|
|
68
|
+
zip-safe = true
|
|
69
|
+
|
|
70
|
+
[tool.setuptools.packages.find]
|
|
71
|
+
namespaces = true
|
|
72
|
+
|
|
73
|
+
[dependency-groups]
|
|
74
|
+
format = [
|
|
75
|
+
"ruff"
|
|
76
|
+
]
|
|
77
|
+
lint = [
|
|
78
|
+
"mypy",
|
|
79
|
+
"types-PyYAML",
|
|
80
|
+
{include-group = "format"},
|
|
81
|
+
{include-group = "unit"},
|
|
82
|
+
]
|
|
83
|
+
publish = []
|
|
84
|
+
unit = [
|
|
85
|
+
"coverage[toml]>=7.6.1",
|
|
86
|
+
"pytest>=8.3.4",
|
|
87
|
+
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[tox]
|
|
2
|
+
envlist = format,lint,unit
|
|
3
|
+
|
|
4
|
+
[vars]
|
|
5
|
+
ops_path = {toxinidir}/ops/
|
|
6
|
+
tst_path = {toxinidir}/tests/
|
|
7
|
+
all_path = {[vars]ops_path} {[vars]tst_path}
|
|
8
|
+
|
|
9
|
+
[testenv]
|
|
10
|
+
basepython = python3
|
|
11
|
+
setenv =
|
|
12
|
+
PYTHONPATH = {toxinidir}
|
|
13
|
+
|
|
14
|
+
[testenv:lint]
|
|
15
|
+
dependency_groups = lint
|
|
16
|
+
commands =
|
|
17
|
+
ruff check {[vars]all_path}
|
|
18
|
+
mypy {[vars]all_path}
|
|
19
|
+
|
|
20
|
+
[testenv:format]
|
|
21
|
+
description = Apply coding style standards to code
|
|
22
|
+
dependency_groups = format
|
|
23
|
+
commands =
|
|
24
|
+
ruff format {[vars]all_path}
|
|
25
|
+
ruff check --fix {[vars]all_path}
|
|
26
|
+
|
|
27
|
+
[testenv:unit]
|
|
28
|
+
description = Run unit tests
|
|
29
|
+
dependency_groups = unit
|
|
30
|
+
commands =
|
|
31
|
+
uv run coverage run --source={[vars]ops_path} \
|
|
32
|
+
-m pytest -vv \
|
|
33
|
+
--basetemp={envtmpdir} \
|
|
34
|
+
--tb native -s {posargs}
|
|
35
|
+
uv run coverage report --show-missing
|
|
36
|
+
|
|
37
|
+
[testenv:build]
|
|
38
|
+
dependency_groups = publish
|
|
39
|
+
skip_install = True
|
|
40
|
+
skipsdist = True
|
|
41
|
+
allowlist_externals = rm
|
|
42
|
+
setenv =
|
|
43
|
+
SETUPTOOLS_SCM_DEBUG = 1
|
|
44
|
+
commands=
|
|
45
|
+
rm -rf build/ *.egg-info/ dist/
|
|
46
|
+
uv build
|
|
47
|
+
|
|
48
|
+
[testenv:publish]
|
|
49
|
+
dependency_groups = publish
|
|
50
|
+
skip_install = True
|
|
51
|
+
skipsdist = True
|
|
52
|
+
allowlist_externals = rm
|
|
53
|
+
commands=
|
|
54
|
+
rm -rf build/ *.egg-info/ dist/
|
|
55
|
+
uv build
|
|
56
|
+
uv publish {posargs} {toxinidir}/dist/*
|