Name | shell-operator JSON |
Version |
0.1.3
JSON |
| download |
home_page | |
Summary | Python SDK for Shell Operator hooks |
upload_time | 2023-01-19 15:23:10 |
maintainer | |
docs_url | None |
author | Eugene Shevchenko |
requires_python | >=3.7.2,<4.0.0 |
license | Apache-2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Deckhouse module SDK
**This package is discontinued in favor of `deckhouse-sdk` and will be deleted soon**
Deckhouse module SDK simplifies writing module hooks for operators:
- [Deckhouse](https://github.com/deckhouse/deckhouse)
- [Addon Operator](https://github.com/flant/addon-operator)
- [Shell Operator](https://github.com/flant/shell-operator) (values are unaccessable)
**NOTE**:
- The API is in alpha stage
- The name will change from `shell-operator` to something more deckhouse-related, probably,
`deckhouse-sdk`
## Install
```bash
pip install shell-operator
```
## Sample hook
```python
# hello.py
from shell_operator import hook
def main(ctx: hook.Context):
# Manipulate kubernetes state
# ... object = { "kind" : "Pod", "apiVersion" : "v1", ... }
ctx.kubernetes.create_or_update(object)
# Export metrics
# ... metric = { "name" : "power", "group": "my_hook", "set" : 9000, ... }
ctx.metrics.collect(metric)
# Use in-memory values for helm chart. Shell Operator does not support values, but Addon Operator and Deckhouse do.
ctx.values.myModule.deployment.replicas = 5
if __name__ == "__main__":
hook.run(main, configpath="hello.yaml") # 'config' arg is also supported for raw string
```
```yaml
# hello.yaml
configVersion: v1
onStartup: 10
```
## How to test
An example for pytest
```python
# hello_test.py
from hello import main
from shell_operator import hook
# Inputs
# initial_values = { ... }
# binding_context = [ { ... } ]
# Outputs
# expected_metrics = [ ... ]
# expected_kube_operations = [ ... ]
# expected_values_patches = [ ... ]
# expected_values = { ... }
def test_hello():
out = hook.testrun(main, binding_context, initial_values)
assert out.metrics.data == expected_metrics
assert out.kube_operations.data == expected_kube_operations
assert out.values_patches.data == expected_values_patches
assert out.values.myModule.deployment.repicas == 5
```
Raw data
{
"_id": null,
"home_page": "",
"name": "shell-operator",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.2,<4.0.0",
"maintainer_email": "",
"keywords": "",
"author": "Eugene Shevchenko",
"author_email": "evgeny.shevchenko@flant.com",
"download_url": "https://files.pythonhosted.org/packages/34/82/e7dfb528b5060661727deb418ddf8a345a360e12f53d51cd7b9f286c0db4/shell_operator-0.1.3.tar.gz",
"platform": null,
"description": "# Deckhouse module SDK\n\n**This package is discontinued in favor of `deckhouse-sdk` and will be deleted soon**\n\nDeckhouse module SDK simplifies writing module hooks for operators:\n\n- [Deckhouse](https://github.com/deckhouse/deckhouse)\n- [Addon Operator](https://github.com/flant/addon-operator)\n- [Shell Operator](https://github.com/flant/shell-operator) (values are unaccessable)\n\n**NOTE**:\n- The API is in alpha stage\n- The name will change from `shell-operator` to something more deckhouse-related, probably,\n `deckhouse-sdk`\n\n## Install\n\n```bash\npip install shell-operator\n```\n\n## Sample hook\n\n```python\n# hello.py\nfrom shell_operator import hook\n\ndef main(ctx: hook.Context):\n # Manipulate kubernetes state\n # ... object = { \"kind\" : \"Pod\", \"apiVersion\" : \"v1\", ... }\n ctx.kubernetes.create_or_update(object)\n\n # Export metrics\n # ... metric = { \"name\" : \"power\", \"group\": \"my_hook\", \"set\" : 9000, ... }\n ctx.metrics.collect(metric)\n\n # Use in-memory values for helm chart. Shell Operator does not support values, but Addon Operator and Deckhouse do.\n ctx.values.myModule.deployment.replicas = 5\n\n\nif __name__ == \"__main__\":\n hook.run(main, configpath=\"hello.yaml\") # 'config' arg is also supported for raw string\n```\n\n```yaml\n# hello.yaml\nconfigVersion: v1\nonStartup: 10\n```\n\n## How to test\n\nAn example for pytest\n\n```python\n# hello_test.py\n\nfrom hello import main\nfrom shell_operator import hook\n\n# Inputs\n# initial_values = { ... }\n# binding_context = [ { ... } ]\n# Outputs\n# expected_metrics = [ ... ]\n# expected_kube_operations = [ ... ]\n# expected_values_patches = [ ... ]\n# expected_values = { ... }\n\ndef test_hello():\n out = hook.testrun(main, binding_context, initial_values)\n\n assert out.metrics.data == expected_metrics\n assert out.kube_operations.data == expected_kube_operations\n assert out.values_patches.data == expected_values_patches\n\n assert out.values.myModule.deployment.repicas == 5\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Python SDK for Shell Operator hooks",
"version": "0.1.3",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6312b14aa5fa0b36416307ca32779154aac2ecbe9d400bc06ccdec1cac122002",
"md5": "e2e9c1df98b512e682f43858f281842f",
"sha256": "e5f2f75745e0a568a295a0064024e2c9511ded20771ed1fe20a02b7b7f3d77f4"
},
"downloads": -1,
"filename": "shell_operator-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e2e9c1df98b512e682f43858f281842f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.2,<4.0.0",
"size": 12746,
"upload_time": "2023-01-19T15:23:09",
"upload_time_iso_8601": "2023-01-19T15:23:09.328852Z",
"url": "https://files.pythonhosted.org/packages/63/12/b14aa5fa0b36416307ca32779154aac2ecbe9d400bc06ccdec1cac122002/shell_operator-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3482e7dfb528b5060661727deb418ddf8a345a360e12f53d51cd7b9f286c0db4",
"md5": "60fc2864bdb93f34bcacd2c8582598d6",
"sha256": "04852369853dc4608a526d2783dc0121d53e4654ba754145f495073fddb813d9"
},
"downloads": -1,
"filename": "shell_operator-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "60fc2864bdb93f34bcacd2c8582598d6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.2,<4.0.0",
"size": 11584,
"upload_time": "2023-01-19T15:23:10",
"upload_time_iso_8601": "2023-01-19T15:23:10.876172Z",
"url": "https://files.pythonhosted.org/packages/34/82/e7dfb528b5060661727deb418ddf8a345a360e12f53d51cd7b9f286c0db4/shell_operator-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-19 15:23:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "shell-operator"
}