ops.interface-kube-control 0.3.0__tar.gz → 0.3.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.3.0 → ops_interface_kube_control-0.3.2}/PKG-INFO +11 -4
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/README.md +8 -1
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops/interface_kube_control/provides.py +28 -12
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops.interface_kube_control.egg-info/PKG-INFO +11 -4
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/pyproject.toml +1 -1
- ops_interface_kube_control-0.3.2/uv.lock +1413 -0
- ops_interface_kube_control-0.3.0/uv.lock +0 -722
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/MANIFEST.in +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops/interface_kube_control/__init__.py +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops/interface_kube_control/model.py +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops/interface_kube_control/requires.py +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops.interface_kube_control.egg-info/SOURCES.txt +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops.interface_kube_control.egg-info/dependency_links.txt +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops.interface_kube_control.egg-info/requires.txt +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops.interface_kube_control.egg-info/top_level.txt +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/ops.interface_kube_control.egg-info/zip-safe +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/setup.cfg +0 -0
- {ops_interface_kube_control-0.3.0 → ops_interface_kube_control-0.3.2}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ops.interface_kube_control
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Kube-Control Interface for Charmed Operators
|
|
5
5
|
Author-email: Adam Dyess <adam.dyess@canonical.com>, Mateo Florido <mateo.florido@canonical.com>
|
|
6
6
|
License: Apache
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
Requires-Python:
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
Requires-Dist: ops
|
|
20
20
|
Requires-Dist: pydantic<3,>=2
|
|
@@ -40,4 +40,11 @@ tox
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
* Raise your PR and contact maintainers
|
|
43
|
-
* Once merged, tag with an `ops-
|
|
43
|
+
* Once merged, tag with an `ops-X.X.X` to publish a new pypi package
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
git switch main
|
|
47
|
+
git pull
|
|
48
|
+
git tag -a ops-X.X.X
|
|
49
|
+
git push <origin> tag ops-X.X.X
|
|
50
|
+
```
|
|
@@ -19,4 +19,11 @@ tox
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
* Raise your PR and contact maintainers
|
|
22
|
-
* Once merged, tag with an `ops-
|
|
22
|
+
* Once merged, tag with an `ops-X.X.X` to publish a new pypi package
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
git switch main
|
|
26
|
+
git pull
|
|
27
|
+
git tag -a ops-X.X.X
|
|
28
|
+
git push <origin> tag ops-X.X.X
|
|
29
|
+
```
|
|
@@ -3,22 +3,24 @@ import json
|
|
|
3
3
|
import logging
|
|
4
4
|
from typing import Generator, List, Tuple
|
|
5
5
|
|
|
6
|
+
import ops
|
|
6
7
|
from pydantic import TypeAdapter
|
|
7
8
|
|
|
8
9
|
from .model import AuthRequest, Creds, Label, Taint
|
|
9
|
-
from ops import CharmBase, Relation, SecretNotFoundError, Unit
|
|
10
10
|
|
|
11
11
|
log = logging.getLogger("KubeControlProvides")
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
class KubeControlProvides:
|
|
14
|
+
class KubeControlProvides(ops.Object):
|
|
15
15
|
"""Implements the Provides side of the kube-control interface."""
|
|
16
16
|
|
|
17
|
-
def __init__(self, charm: CharmBase, endpoint: str = "kube-control", schemas="0,1"):
|
|
17
|
+
def __init__(self, charm: ops.CharmBase, endpoint: str = "kube-control", schemas="0,1"):
|
|
18
|
+
super().__init__(charm, f"{endpoint}-provider")
|
|
18
19
|
self.charm = charm
|
|
19
20
|
self.endpoint = endpoint
|
|
20
21
|
self.label_adapter = TypeAdapter(Label)
|
|
21
22
|
self.taint_adapter = TypeAdapter(Taint)
|
|
23
|
+
self.framework.observe(charm.on.secret_remove, self._on_secret_remove)
|
|
22
24
|
|
|
23
25
|
@property
|
|
24
26
|
def auth_requests(self) -> List[AuthRequest]:
|
|
@@ -55,7 +57,7 @@ class KubeControlProvides:
|
|
|
55
57
|
]
|
|
56
58
|
|
|
57
59
|
@property
|
|
58
|
-
def relations(self) -> List[Relation]:
|
|
60
|
+
def relations(self) -> List[ops.Relation]:
|
|
59
61
|
"""List of relations on this endpoint."""
|
|
60
62
|
return self.charm.model.relations[self.endpoint]
|
|
61
63
|
|
|
@@ -72,7 +74,7 @@ class KubeControlProvides:
|
|
|
72
74
|
ca_certificate (str): The CA certificate in PEM format.
|
|
73
75
|
"""
|
|
74
76
|
content = {"ca-certificate": ca_certificate}
|
|
75
|
-
secret = self.
|
|
77
|
+
secret = self._refresh_secret_content(
|
|
76
78
|
"ca-certificate", content, "Kubernetes API endpoint CA certificate"
|
|
77
79
|
)
|
|
78
80
|
for relation in self.relations:
|
|
@@ -146,15 +148,29 @@ class KubeControlProvides:
|
|
|
146
148
|
for relation in self.relations:
|
|
147
149
|
relation.data[self.unit]["taints"] = value
|
|
148
150
|
|
|
149
|
-
def
|
|
151
|
+
def _on_secret_remove(self, event: ops.SecretRemoveEvent) -> None:
|
|
152
|
+
"""Remove revisions for secrets matching this object's endpoint.
|
|
153
|
+
Args:
|
|
154
|
+
event (ops.SecretRemoveEvent): The secret removal event.
|
|
155
|
+
"""
|
|
156
|
+
try:
|
|
157
|
+
content = event.secret.get_content()
|
|
158
|
+
except ops.SecretNotFoundError:
|
|
159
|
+
return
|
|
160
|
+
if content.get("endpoint") == self.endpoint:
|
|
161
|
+
log.info(f"Removing secret {event.secret.id}")
|
|
162
|
+
event.secret.remove_revision(event.revision)
|
|
163
|
+
|
|
164
|
+
def _refresh_secret_content(self, label, content, description=None):
|
|
150
165
|
"""Refresh the content of a secret."""
|
|
166
|
+
content = {**content, "endpoint": self.endpoint}
|
|
151
167
|
try:
|
|
152
168
|
secret = self.charm.model.get_secret(label=label)
|
|
153
|
-
|
|
154
|
-
secret.set_content(content)
|
|
155
|
-
secret.set_info(description=description, label=label)
|
|
156
|
-
except SecretNotFoundError:
|
|
169
|
+
except ops.SecretNotFoundError:
|
|
157
170
|
secret = self.charm.app.add_secret(content, label=label, description=description)
|
|
171
|
+
if secret.get_content(refresh=True) != content:
|
|
172
|
+
log.info("Refresh content %s", secret.id)
|
|
173
|
+
secret.set_content(content)
|
|
158
174
|
return secret
|
|
159
175
|
|
|
160
176
|
def closed_auth_creds(self) -> Generator[Tuple[str, Creds], None, None]:
|
|
@@ -224,7 +240,7 @@ class KubeControlProvides:
|
|
|
224
240
|
}
|
|
225
241
|
label = f"{request.user}-creds"
|
|
226
242
|
description = f"Credentials for {request.user}"
|
|
227
|
-
secret = self.
|
|
243
|
+
secret = self._refresh_secret_content(label, content, description)
|
|
228
244
|
if secret.id:
|
|
229
245
|
log.info(f"Granting secret {secret.id} to {request_relation.name}")
|
|
230
246
|
secret.grant(request_relation, unit=request_unit)
|
|
@@ -245,6 +261,6 @@ class KubeControlProvides:
|
|
|
245
261
|
relation.data[self.unit]["creds"] = value
|
|
246
262
|
|
|
247
263
|
@property
|
|
248
|
-
def unit(self) -> Unit:
|
|
264
|
+
def unit(self) -> ops.Unit:
|
|
249
265
|
"""Local unit."""
|
|
250
266
|
return self.charm.unit
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ops.interface_kube_control
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Kube-Control Interface for Charmed Operators
|
|
5
5
|
Author-email: Adam Dyess <adam.dyess@canonical.com>, Mateo Florido <mateo.florido@canonical.com>
|
|
6
6
|
License: Apache
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
Requires-Python:
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
Requires-Dist: ops
|
|
20
20
|
Requires-Dist: pydantic<3,>=2
|
|
@@ -40,4 +40,11 @@ tox
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
* Raise your PR and contact maintainers
|
|
43
|
-
* Once merged, tag with an `ops-
|
|
43
|
+
* Once merged, tag with an `ops-X.X.X` to publish a new pypi package
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
git switch main
|
|
47
|
+
git pull
|
|
48
|
+
git tag -a ops-X.X.X
|
|
49
|
+
git push <origin> tag ops-X.X.X
|
|
50
|
+
```
|
|
@@ -12,7 +12,7 @@ name = "ops.interface_kube_control"
|
|
|
12
12
|
dynamic = ["version"]
|
|
13
13
|
description = "Kube-Control Interface for Charmed Operators"
|
|
14
14
|
readme = "README.md"
|
|
15
|
-
requires-python = "
|
|
15
|
+
requires-python = ">=3.8"
|
|
16
16
|
license = { text = "Apache" }
|
|
17
17
|
authors = [
|
|
18
18
|
{ name= "Adam Dyess", email = "adam.dyess@canonical.com" },
|