Skip to content

Commit 4551a4d

Browse files
committed
add utils
1 parent cb09438 commit 4551a4d

6 files changed

Lines changed: 34 additions & 0 deletions

File tree

rootfs/helmbroker/celery.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
from celery import Celery
3+
4+
5+
app = Celery(
6+
'helmbroker',
7+
broker=os.environ["HELMBROKER_CELERY_BROKER"],
8+
backend=os.environ["HELMBROKER_CELERY_BACKEND"],
9+
include=['helmbroker.tasks']
10+
)
11+
app.conf.update(result_expires=3600)
12+
13+
14+
if __name__ == '__main__':
15+
app.start()

rootfs/helmbroker/helm.py

Whitespace-only changes.

rootfs/helmbroker/kubectl.py

Whitespace-only changes.

rootfs/helmbroker/tasks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from .celery import app
2+
3+
4+
@app.task
5+
def mul(x, y):
6+
return x * y

rootfs/helmbroker/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import yaml
2+
import json
3+
import subprocess
4+
5+
6+
def command(cmd, *args, output_type="text"):
7+
output = subprocess.getoutput("%s %s" % (cmd, " ".join(args)))
8+
if output_type == "yaml":
9+
return yaml.load(output, Loader=yaml.Loader)
10+
elif output_type == "json":
11+
return json.loads(output)
12+
return output

rootfs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
pyyaml==5.4.1
12
gunicorn==20.1.0
23
openbrokerapi==4.1.2

0 commit comments

Comments
 (0)