Python library for Shell Operator
Project description
Shell Operator Python Framework
Simplifies writing shell-operator hooks in Python.
Install
pip install shell-operator
Sample hook
# hello.py
from shell_operator import hook
def main(ctx: hook.Context):
# ... object = { "kind" : "Pod", "apiVersion" : "v1", ... }
ctx.output.kubernetes.create_or_update(object)
# ... metric = { "name" : "power", "group": "my_hook", "set" : 9000, ... }
ctx.output.metrics.collect(metric)
if __name__ == "__main__":
hook.run(main, configpath="hello.yaml") # 'config' arg is also supported for raw string
# hello.yaml
configVersion: v1
onStartup: 10
How to test
An example for pytest
# hello_test.py
from hello import main
from shell_operator import hook
# binding_context = [ { ... } ]
# expected_metrics = [ ... ]
# expected_kube_operations = [ ... ]
def test_hello():
out = hook.testrun(main, binding_context)
assert out.metrics.storage.data == expected_metrics
assert out.kubernetes.storage.data == expected_kube_operations
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
shell_operator-0.0.5.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shell_operator-0.0.5.tar.gz.
File metadata
- Download URL: shell_operator-0.0.5.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cdb689f88e3e3451e29c49030c4d4f04e64ab8ddad7ba0a28b9c0946426a462
|
|
| MD5 |
7dceb9248a8901120b7d58d08857c6ad
|
|
| BLAKE2b-256 |
364e31b44e0633b9d0d9a726681e177122dcc9319c326bfaae6c6a5570cdb47d
|
File details
Details for the file shell_operator-0.0.5-py3-none-any.whl.
File metadata
- Download URL: shell_operator-0.0.5-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3485f828bb03d85caf5a5dab7f27de89afce2ce2be5581c4c2e845cd6f5d9b6
|
|
| MD5 |
89a248847d390e0d39f87747669c01c5
|
|
| BLAKE2b-256 |
e2b936f5c46452d557a2dbc4743342dba807881849a6dd3ca3cf865a0ac66972
|