-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ad066d
commit e9c904a
Showing
61 changed files
with
2,222 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.git | ||
.infrabox | ||
Dockerfile | ||
.dockerignore | ||
*.pyc | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.infrabox* | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include README.md | ||
include LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
# cli | ||
CLI for InfraBox | ||
# InfraBox CLI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/python | ||
import infraboxcli | ||
infraboxcli.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM alpine | ||
|
||
RUN adduser -S testuser | ||
USER testuser | ||
|
||
CMD echo "hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"version": 1, | ||
"jobs": [{ | ||
"type": "docker", | ||
"name": "example1", | ||
"docker_file": "Dockerfile", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM alpine | ||
RUN adduser -S testuser | ||
USER testuser | ||
CMD cat /infrabox/inputs/producer/data.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM alpine | ||
RUN adduser -S testuser | ||
USER testuser | ||
CMD echo "hello world" > /infrabox/output/data.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"version": 1, | ||
"jobs": [{ | ||
"type": "docker", | ||
"name": "producer", | ||
"docker_file": "Dockerfile_producer", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048" | ||
}, { | ||
"type": "docker", | ||
"name": "consumer", | ||
"docker_file": "Dockerfile_consumer", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048", | ||
"depends_on": ["producer"] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine | ||
|
||
ADD result.json /result.json | ||
ADD entrypoint.sh /entrypoint.sh | ||
|
||
RUN adduser -S tester | ||
USER tester | ||
|
||
CMD /entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh -e | ||
|
||
# Run your tests and generate the result json file | ||
|
||
cp /result.json /infrabox/upload/testresult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"version": 1, | ||
"jobs": [{ | ||
"type": "docker", | ||
"name": "testresult", | ||
"docker_file": "Dockerfile", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"version": 1, | ||
"tests": [{ | ||
"name": "test 1", | ||
"suite": "Test suite", | ||
"status": "ok", | ||
"duration": 123, | ||
"measurements": [{ | ||
"name": "Custom measurement", | ||
"value": "123", | ||
"unit": "hz" | ||
}] | ||
}, { | ||
"name": "test 2", | ||
"suite": "Test suite", | ||
"status": "error", | ||
"duration": 43, | ||
"message": "TypeError: Again !?!", | ||
"stack": "Traceback (most recent call last):\n File \"e.py\", line 7, in <module>\n raise TypeError(\"Again !?!\")" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM debian | ||
|
||
RUN useradd -ms /bin/bash user | ||
USER user | ||
|
||
CMD echo "hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": 1, | ||
"jobs": [{ | ||
"type": "docker", | ||
"name": "security_scan", | ||
"docker_file": "Dockerfile", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048", | ||
"security": { | ||
"scan_container": true | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM alpine | ||
|
||
RUN adduser -S testuser | ||
USER testuser | ||
|
||
CMD echo "hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM alpine | ||
RUN adduser -S testuser | ||
USER testuser | ||
CMD cat /infrabox/inputs/producer/data.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM alpine | ||
RUN adduser -S testuser | ||
USER testuser | ||
CMD echo "hello world" > /infrabox/output/data.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": 1, | ||
"jobs": [{ | ||
"type": "docker", | ||
"name": "producer", | ||
"docker_file": "Dockerfile_producer", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048" | ||
}, { | ||
"type": "docker", | ||
"name": "consumer", | ||
"docker_file": "Dockerfile_consumer", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048", | ||
"keep": true, | ||
"depends_on": ["producer"] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"version": 1, | ||
"jobs": [{ | ||
"type": "docker", | ||
"name": "pyinfrabox", | ||
"docker_file": "infrabox/pyinfrabox/Dockerfile", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048" | ||
}, { | ||
"type": "docker", | ||
"name": "infraboxcli-python2", | ||
"docker_file": "infrabox/infraboxcli/Dockerfile_python2", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048" | ||
}, { | ||
"type": "docker", | ||
"name": "infraboxcli-python3", | ||
"docker_file": "infrabox/infraboxcli/Dockerfile_python3", | ||
"build_only": false, | ||
"machine_config": "vm-1-2048" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM alpine:3.4 | ||
|
||
RUN apk add --no-cache py-pip py-yaml | ||
RUN pip install coverage | ||
|
||
RUN adduser -S tester | ||
|
||
COPY . /infraboxcli | ||
RUN chown -R tester /infraboxcli | ||
|
||
WORKDIR /infraboxcli | ||
|
||
RUN pip install . | ||
|
||
USER tester | ||
|
||
CMD /infraboxcli/infrabox/infraboxcli/entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM alpine:3.4 | ||
|
||
RUN apk add --no-cache python3 | ||
RUN pip3 install coverage | ||
|
||
RUN adduser -S tester | ||
|
||
COPY . /infraboxcli | ||
RUN chown -R tester /infraboxcli | ||
|
||
WORKDIR /infraboxcli | ||
|
||
RUN pip3 install . | ||
|
||
USER tester | ||
|
||
CMD /infraboxcli/infrabox/infraboxcli/entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh -e | ||
find /infraboxcli -name \*.pyc -delete | ||
|
||
# test help | ||
echo "## Test --help" | ||
infrabox --help | ||
|
||
# test list | ||
echo "## Test list" | ||
infrabox list | ||
|
||
# test validate | ||
echo "## Test validate" | ||
infrabox validate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM stege/baseimage:1 | ||
|
||
RUN apk add --no-cache py-pip py-yaml git | ||
RUN pip install coverage future | ||
|
||
RUN adduser -S tester | ||
|
||
COPY pyinfrabox /pyinfrabox | ||
COPY infrabox/pyinfrabox/entrypoint.sh /pyinfrabox/entrypoint.sh | ||
|
||
RUN chown -R tester /pyinfrabox | ||
|
||
USER tester | ||
|
||
WORKDIR /pyinfrabox | ||
|
||
CMD /pyinfrabox/entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh -e | ||
|
||
mkdir -p /infrabox/upload/badge | ||
mkdir -p /infrabox/upload/markup | ||
|
||
echo "## Run tests" | ||
nosetests --with-coverage --cover-xml --cover-branches --cover-package=pyinfrabox --cover-tests tests/* | ||
|
||
echo "## Download coverage" | ||
git clone https://github.com/InfraBox/coverage.git /tmp/coverage | ||
|
||
echo "## Create coverage result" | ||
export PYTHONPATH=/ | ||
python /tmp/coverage/coverage.py --output /infrabox/upload/markup/coverage.json --input coverage.xml --badge /infrabox/upload/badge/coverage.json --format py-coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import argparse | ||
import os | ||
import sys | ||
|
||
from infraboxcli.push import push | ||
from infraboxcli.run import run | ||
from infraboxcli.graph import graph | ||
from infraboxcli.validate import validate | ||
from infraboxcli.list_jobs import list_jobs | ||
from infraboxcli.log import logger | ||
from infraboxcli.init import init | ||
from infraboxcli.pull import pull | ||
from infraboxcli.version import version | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(prog="infrabox") | ||
parser.add_argument("--host", required=False, default="https://dashboard.infrabox.net") | ||
sub_parser = parser.add_subparsers(help='sub-command help') | ||
|
||
# version | ||
version_init = sub_parser.add_parser('version', help='Show the current version') | ||
version_init.set_defaults(version=version) | ||
|
||
# init | ||
parser_init = sub_parser.add_parser('init', help='Create a simple project') | ||
parser_init.set_defaults(is_init=True) | ||
parser_init.set_defaults(func=init) | ||
|
||
# push | ||
parser_push = sub_parser.add_parser('push', help='Push a local project to InfraBox') | ||
parser_push.add_argument("--show-console", action='store_true', required=False, | ||
help="Show the console output of the jobs") | ||
parser_push.set_defaults(show_console=False) | ||
parser_push.set_defaults(validate_only=False) | ||
parser_push.set_defaults(func=push) | ||
|
||
# push | ||
parser_pull = sub_parser.add_parser('pull', help='Pull a remote job') | ||
parser_pull.add_argument("--job-id", required=True) | ||
parser_pull.set_defaults(func=pull) | ||
|
||
# graph | ||
parser_graph = sub_parser.add_parser('graph', help='Generate a graph of your local jobs') | ||
parser_graph.add_argument("--output", required=True, type=str, | ||
help="Path to the output file") | ||
parser_graph.set_defaults(func=graph) | ||
|
||
# validate | ||
validate_graph = sub_parser.add_parser('validate', help='Validate infrabox.json') | ||
validate_graph.set_defaults(func=validate) | ||
|
||
# list | ||
list_job = sub_parser.add_parser('list', help='List all available jobs') | ||
list_job.set_defaults(func=list_jobs) | ||
|
||
# run | ||
parser_run = sub_parser.add_parser('run', help='Run your jobs locally') | ||
parser_run.add_argument("--job-name", required=False, type=str, | ||
help="Job name to execute") | ||
parser_run.add_argument("--clean", action='store_true', required=False, | ||
help="Runs 'docker-compose rm' before building") | ||
parser_run.add_argument("-e", dest='environment', default=[], required=False, | ||
action='append', type=str, | ||
help="Add environment variable to jobs") | ||
parser_run.set_defaults(clean=False) | ||
parser_run.set_defaults(func=run) | ||
|
||
# Parse args | ||
args = parser.parse_args() | ||
|
||
if 'version' in args: | ||
print('infraboxcli %s' % version) | ||
return | ||
|
||
# Find infrabox.json | ||
p = os.getcwd() | ||
|
||
while p: | ||
tb = os.path.join(p, 'infrabox.json') | ||
if not os.path.exists(tb): | ||
p = p[0:p.rfind('/')] | ||
else: | ||
args.project_root = p | ||
args.infrabox_json = tb | ||
args.project_name = os.path.basename(p) | ||
break | ||
|
||
if 'project_root' not in args and 'is_init' not in args: | ||
logger.error("infrabox.json not found in current or any parent directory") | ||
sys.exit(1) | ||
|
||
# Run command | ||
args.func(args) |
Oops, something went wrong.