Skip to main content

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


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)

Uploaded Source

Built Distribution

shell_operator-0.0.4-py3-none-any.whl (9.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page