Commit e3a60dc2 authored by Idriss Neumann's avatar Idriss Neumann
Browse files

Add documentation

parent a1c65ca9
Pipeline #5535 passed with stages
in 3 minutes and 38 seconds
......@@ -15,7 +15,7 @@ mirror:
kompose-api-x86:
stage: publish
script:
- setsid ./ci/docker-deliver.sh "kompose-api" "2.8" "x86"
- setsid ./ci/docker-deliver.sh "kompose-api" "2.9" "x86"
only:
refs:
- /^(main.*)$/
......
......@@ -9,9 +9,11 @@ ENV ENABLE_KUBECTL_APPLY=false \
FLASK_RUN_HOST=0.0.0.0 \
FLASK_RUN_PORT=8080 \
WERKZEUG_RUN_MAIN=true \
MANIFEST_FILE_PATH=/manifest.json
MANIFEST_FILE_PATH=/manifest.json \
README_FILE_PATH=/README.md \
KOMPOSE_DOC_URL=http://127.0.0.1:8080/doc
COPY ./api.py ./manifest.json ./versions.sh ./konvert.sh ./requirements.txt /
COPY ./README.md ./api.py ./manifest.json ./versions.sh ./konvert.sh ./requirements.txt /
RUN pip3 install --upgrade pip && \
pip3 install -r /requirements.txt && \
......
......@@ -78,6 +78,10 @@ curl https://kompose.comwork.io/versions|jq .
The you'll have to refer to [kompose website](./https://kompose.io/) in order to get more informations such as compatibility matrix with docker-compose and kubernetes, etc.
#### Getting an html rendered documentation
Follow this link: https://kompose.comwork.io/doc
#### Convert a docker-compose file into Kubernetes manifest
```shell
......
......@@ -5,8 +5,8 @@ from subprocess import check_output
from multiprocessing import Process
import os
import json
import re
import uuid
import markdown
app = Flask(__name__)
api = Api(app)
......@@ -50,14 +50,16 @@ class VersionsApi(Resource):
return {
'status': 'ok',
'kompose_versions': get_kompose_available_versions(),
'kubectl_versions': get_available_versions("K8S_VERSION")
'kubectl_versions': get_available_versions("K8S_VERSION"),
'help': "Go see {}".format(os.environ['KOMPOSE_DOC_URL'])
}
class KomposeApi(Resource):
def get(self):
return {
'status': 'ok',
'alive': True
'alive': True,
'help': "Go see {}".format(os.environ['KOMPOSE_DOC_URL'])
}
def post(self):
available_versions = get_kompose_available_versions()
......@@ -110,13 +112,25 @@ class ManifestEndPoint(Resource):
'reason': err
}, 500
class DocEndPoint(Resource):
def get(self):
try:
with open(os.environ['README_FILE_PATH'], 'r') as doc:
html = markdown.markdown(doc.read())
return Response(html, mimetype='text/html')
except IOError as err:
return {'status': 'error', 'reason': err}, 500
kompose_routes = ['/']
versions_routes = ['/versions', '/versions/']
manifest_routes = ['/manifest', '/manifest/']
versions_routes = ['/versions', '/versions/', '/v1/versions', '/v1/versions/']
manifest_routes = ['/manifest', '/manifest/', '/v1/manifest', '/v1/manifest/']
doc_routes = ['/doc', '/doc/', '/v1/doc', '/v1/doc/']
api.add_resource(KomposeApi, *kompose_routes)
api.add_resource(VersionsApi, *versions_routes)
api.add_resource(ManifestEndPoint, *manifest_routes)
api.add_resource(DocEndPoint, *doc_routes)
if __name__ == '__main__':
app.run()
......@@ -6,5 +6,6 @@ services:
user: root
environment:
- FLASK_RUN_PORT=8072
- KOMPOSE_DOC_URL=https://kompose.comwork.io/doc
ports:
- 8072:8072
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment