Python library for Shell Operator
Project description
Shell Operator Python Framework
This is a framework for shell-operator for writing hooks im Python.
Install
pip install shell-operator
Sample hook
# hello.py
import shell_operator as operator
def handle(context: operator.HookContext):
print("Hello from Python!")
if __name__ == "__main__":
operator.run(handle, configpath="hello.yaml") # 'config' arg is also supported for raw string
# hello.yaml
configVersion: v1
onStartup: 10
How to test
# hello_test.py
import shell_operator as operator
from hello import handle
binding_context = [
{
# expected binding context
}
]
expected_metrics = []
expected_kubernetes_operations = []
def test_node_metrics():
metrics = operator.MetricsExporter(operator.MemStorage())
kubernetes = operator.KubernetesModifier(operator.MemStorage())
for ctx in binding_context:
hook_ctx = operator.HookContext(ctx, metrics=metrics, kubernetes=kubernetes)
handle(hook_ctx)
assert metrics.storage.data == expected_metrics
assert kubernetes.storage.data == expected_kubernetes_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.4.tar.gz
(8.4 kB
view hashes)
Built Distribution
Close
Hashes for shell_operator-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42c8997241def67e362fea311d8c56d98ef6989e65424ed9a1d0b62f64477598 |
|
MD5 | 1164a5d10fccae30e7a69a7f49ef96bd |
|
BLAKE2b-256 | 8988be0cca0089d686d67b8cc71a06838aa107ec3ad6c53edee9d461b9a5933a |