charmlibs-interfaces-service-mesh 1.0.0__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.
@@ -0,0 +1,184 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+ cos-tool*
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .coverage-*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+ .report/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ #uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ #poetry.lock
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ #pdm.lock
115
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
116
+ # in version control.
117
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
118
+ .pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
123
+ __pypackages__/
124
+
125
+ # Celery stuff
126
+ celerybeat-schedule
127
+ celerybeat.pid
128
+
129
+ # SageMath parsed files
130
+ *.sage.py
131
+
132
+ # Environments
133
+ .env
134
+ .venv
135
+ env/
136
+ venv/
137
+ ENV/
138
+ env.bak/
139
+ venv.bak/
140
+
141
+ # Spyder project settings
142
+ .spyderproject
143
+ .spyproject
144
+
145
+ # Rope project settings
146
+ .ropeproject
147
+
148
+ # mkdocs documentation
149
+ /site
150
+
151
+ # mypy
152
+ .mypy_cache/
153
+ .dmypy.json
154
+ dmypy.json
155
+
156
+ # Pyre type checker
157
+ .pyre/
158
+
159
+ # pytype static type analyzer
160
+ .pytype/
161
+
162
+ # Cython debug symbols
163
+ cython_debug/
164
+
165
+ # PyCharm
166
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
167
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
168
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
169
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
170
+ .idea/
171
+
172
+ # PyPI configuration file
173
+ .pypirc
174
+
175
+ # packed charms
176
+ .packed
177
+
178
+ # temporary directory for packing charms
179
+ .tmp
180
+
181
+ # uv.lock from example libraries as we don't commit these
182
+ .example/**/uv.lock
183
+ .tutorial/**/uv.lock
184
+ interfaces/.example/**/uv.lock
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ Initial release. Migrated from `charms.istio_beacon_k8s.v0.service_mesh` (v0.19).
@@ -0,0 +1,31 @@
1
+ Metadata-Version: 2.4
2
+ Name: charmlibs-interfaces-service-mesh
3
+ Version: 1.0.0
4
+ Summary: The charmlibs.interfaces.service_mesh package.
5
+ Project-URL: Documentation, https://documentation.ubuntu.com/charmlibs/reference/charmlibs/interfaces/service-mesh
6
+ Project-URL: Repository, https://github.com/canonical/charmlibs/tree/main/interfaces/service-mesh
7
+ Project-URL: Issues, https://github.com/canonical/charmlibs/issues
8
+ Project-URL: Changelog, https://github.com/canonical/charmlibs/blob/main/interfaces/service-mesh/CHANGELOG.md
9
+ Author: Service Mesh
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: canonical-service-mesh<1
17
+ Requires-Dist: ops<3,>=2
18
+ Requires-Dist: pydantic<3,>=2
19
+ Description-Content-Type: text/markdown
20
+
21
+ # charmlibs.interfaces.service_mesh
22
+
23
+ The `service-mesh` interface library.
24
+
25
+ To install, add `charmlibs-interfaces-service-mesh` to your Python dependencies. Then in your Python code, import as:
26
+
27
+ ```py
28
+ from charmlibs.interfaces import service_mesh
29
+ ```
30
+
31
+ See the [reference documentation](https://documentation.ubuntu.com/charmlibs/reference/charmlibs/interfaces/service-mesh) for more.
@@ -0,0 +1,11 @@
1
+ # charmlibs.interfaces.service_mesh
2
+
3
+ The `service-mesh` interface library.
4
+
5
+ To install, add `charmlibs-interfaces-service-mesh` to your Python dependencies. Then in your Python code, import as:
6
+
7
+ ```py
8
+ from charmlibs.interfaces import service_mesh
9
+ ```
10
+
11
+ See the [reference documentation](https://documentation.ubuntu.com/charmlibs/reference/charmlibs/interfaces/service-mesh) for more.
@@ -0,0 +1,75 @@
1
+ [project]
2
+ name = "charmlibs-interfaces-service-mesh"
3
+ description = "The charmlibs.interfaces.service_mesh package."
4
+ readme = "README.md"
5
+ requires-python = ">=3.10"
6
+ authors = [
7
+ {name="Service Mesh"},
8
+ ]
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "License :: OSI Approved :: Apache Software License",
12
+ "Intended Audience :: Developers",
13
+ "Operating System :: POSIX :: Linux",
14
+ "Development Status :: 5 - Production/Stable",
15
+ ]
16
+ dynamic = ["version"]
17
+ dependencies = [
18
+ "ops>=2,<3",
19
+ "pydantic>=2,<3",
20
+ "canonical-service-mesh<1",
21
+ ]
22
+
23
+ [dependency-groups]
24
+ lint = [ # installed for `just lint interfaces/service-mesh` (unit, functional, and integration are also installed)
25
+ # "typing_extensions",
26
+ ]
27
+ unit = [ # installed for `just unit interfaces/service-mesh`
28
+ "ops[testing]",
29
+ ]
30
+ functional = [ # installed for `just functional interfaces/service-mesh`
31
+ ]
32
+ integration = [ # installed for `just integration interfaces/service-mesh`
33
+ "jubilant",
34
+ ]
35
+
36
+ [project.urls]
37
+ "Documentation" = "https://documentation.ubuntu.com/charmlibs/reference/charmlibs/interfaces/service-mesh"
38
+ "Repository" = "https://github.com/canonical/charmlibs/tree/main/interfaces/service-mesh"
39
+ "Issues" = "https://github.com/canonical/charmlibs/issues"
40
+ "Changelog" = "https://github.com/canonical/charmlibs/blob/main/interfaces/service-mesh/CHANGELOG.md"
41
+
42
+ [build-system]
43
+ requires = ["hatchling"]
44
+ build-backend = "hatchling.build"
45
+
46
+ [tool.hatch.build.targets.wheel]
47
+ packages = ["src/charmlibs"]
48
+
49
+ [tool.hatch.version]
50
+ path = "src/charmlibs/interfaces/service_mesh/_version.py"
51
+
52
+ [tool.ruff]
53
+ extend = "../../pyproject.toml"
54
+ src = ["src", "tests/unit"] # correctly sort local imports in tests
55
+
56
+ [tool.ruff.lint.extend-per-file-ignores]
57
+ # add additional per-file-ignores here to avoid overriding repo-level config
58
+ "tests/**/*" = [
59
+ # "E501", # line too long
60
+ ]
61
+
62
+ [tool.pyright]
63
+ extends = "../../pyproject.toml"
64
+ include = ["src", "tests"]
65
+ pythonVersion = "3.10" # check no python > 3.10 features are used
66
+
67
+ [tool.charmlibs.functional]
68
+ ubuntu = [] # ubuntu versions to run functional tests with, e.g. "24.04" (defaults to just "latest")
69
+ pebble = [] # pebble versions to run functional tests with, e.g. "v1.0.0", "master" (defaults to no pebble versions)
70
+ sudo = false # whether to run functional tests with sudo (defaults to false)
71
+
72
+ [tool.charmlibs.integration]
73
+ # tags to run integration tests with (defaults to running once with no tag, i.e. tags = [''])
74
+ # Available in CI in tests/integration/pack.sh and integration tests as CHARMLIBS_TAG
75
+ tags = [] # Not used by the pack.sh and integration tests generated by the template
@@ -0,0 +1,121 @@
1
+ # Copyright 2025 Canonical Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Service mesh interface library.
16
+
17
+ This library facilitates adding your charmed application to a service mesh,
18
+ leveraging the ``service_mesh`` and ``cross_model_mesh`` interfaces to provide
19
+ secure, policy-driven traffic management between applications.
20
+
21
+ What is this library for?
22
+ =========================
23
+
24
+ This library is for enrolling a charm onto a Charmed Service Mesh solution
25
+ and automatically provisioning network policies that restrict cluster-internal
26
+ network traffic between charms.
27
+
28
+ Service meshes provide capabilities for routing, controlling, and monitoring
29
+ traffic between applications. A key feature is the ability to enforce
30
+ authorization policies that govern which pods can communicate with each other
31
+ and on which ports, paths, and HTTP methods. For example, you can define that
32
+ a metrics scraper pod is allowed to ``GET /metrics`` on port ``9090`` from a
33
+ producer pod, while preventing all other pods from accessing it.
34
+
35
+ The ``ServiceMeshConsumer`` subscribes a charm to a related service mesh by
36
+ declaring access policies based on the charm's Juju relations. Since
37
+ application relations often reflect traffic flow patterns (e.g. a database
38
+ consumer connecting to a database provider), the consumer automatically
39
+ generates the appropriate mesh traffic rules. It also handles labelling the
40
+ charm's Kubernetes resources to enroll them in the mesh, and supports
41
+ cross-model relations for multi-model deployments.
42
+
43
+ The ``ServiceMeshProvider`` publishes mesh enrollment labels and the mesh type
44
+ to consumers, and collects the aggregated policies requested by all related
45
+ consumer charms so the mesh control plane can enforce them.
46
+
47
+ Consumer usage::
48
+
49
+ from charmlibs.interfaces.service_mesh import (
50
+ Method, Endpoint, AppPolicy, UnitPolicy, ServiceMeshConsumer,
51
+ )
52
+
53
+ class MyCharm(CharmBase):
54
+ def __init__(self, *args):
55
+ super().__init__(*args)
56
+ self._mesh = ServiceMeshConsumer(
57
+ self,
58
+ policies=[
59
+ AppPolicy(
60
+ relation="data",
61
+ endpoints=[
62
+ Endpoint(
63
+ ports=[HTTP_LISTEN_PORT],
64
+ methods=[Method.get],
65
+ paths=["/data"],
66
+ ),
67
+ ],
68
+ ),
69
+ UnitPolicy(relation="metrics", ports=[HTTP_LISTEN_PORT]),
70
+ ],
71
+ )
72
+
73
+ Provider usage::
74
+
75
+ from charmlibs.interfaces.service_mesh import ServiceMeshProvider, MeshType
76
+
77
+ class MyServiceMeshCharm(CharmBase):
78
+ def __init__(self, *args):
79
+ super().__init__(*args)
80
+ self._mesh = ServiceMeshProvider(
81
+ charm=self,
82
+ labels={"istio.io/dataplane-mode": "ambient"},
83
+ mesh_type=MeshType.istio,
84
+ )
85
+ """
86
+
87
+ from canonical_service_mesh.enums import MeshType, Method, PolicyTargetType
88
+
89
+ from ._service_mesh import (
90
+ AppPolicy,
91
+ CMRData,
92
+ Endpoint,
93
+ MeshPolicy,
94
+ Policy,
95
+ ServiceMeshConsumer,
96
+ ServiceMeshProvider,
97
+ ServiceMeshProviderAppData,
98
+ UnitPolicy,
99
+ build_mesh_policies,
100
+ get_data_from_cmr_relation,
101
+ label_configmap_name_template,
102
+ )
103
+ from ._version import __version__ as __version__
104
+
105
+ __all__ = [
106
+ 'AppPolicy',
107
+ 'CMRData',
108
+ 'Endpoint',
109
+ 'MeshPolicy',
110
+ 'MeshType',
111
+ 'Method',
112
+ 'Policy',
113
+ 'PolicyTargetType',
114
+ 'ServiceMeshConsumer',
115
+ 'ServiceMeshProvider',
116
+ 'ServiceMeshProviderAppData',
117
+ 'UnitPolicy',
118
+ 'build_mesh_policies',
119
+ 'get_data_from_cmr_relation',
120
+ 'label_configmap_name_template',
121
+ ]