Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
🚀
This server has been upgraded to GitLab release
15.7
.
🚀
Open sidebar
memoriav
Memobase 2020
services
autodeploy-service
Commits
ca8b7788
Commit
ca8b7788
authored
Oct 07, 2021
by
Jonas Waeber
Browse files
Remove dependence on flask restful.
parent
0f203b73
Pipeline
#34262
passed with stages
in 1 minute and 23 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
autodeploy_service_app/autodeploy.py
View file @
ca8b7788
from
flask_restful
import
Resource
from
flask
import
request
as
flaskRequest
import
json
import
subprocess
from
re
import
match
from
os
import
environ
,
listdir
,
path
,
getenv
from
re
import
match
from
shutil
import
rmtree
from
tempfile
import
mkdtemp
from
flask
import
request
as
flaskRequest
from
flask.views
import
MethodView
from
autodeploy_service_app.app
import
app
class
AutoDeploy
(
Resource
):
class
AutoDeploy
(
MethodView
):
def
post
(
self
):
'''
Deploy on k8s
...
...
autodeploy_service_app/wsgi.py
View file @
ca8b7788
import
logging
from
os
import
path
,
environ
from
flasgger
import
Swagger
from
flask
import
send_from_directory
,
redirect
from
flask.logging
import
default_handler
from
flask_restful
import
Api
from
kubernetes
import
config
from
os
import
path
,
envir
on
import
logging
from
kubernetes.config
import
ConfigExcepti
on
from
autodeploy_service_app.app
import
app
from
autodeploy_service_app.autodeploy
import
AutoDeploy
# TODO : maybe take that to a configuration (development vs pod running in
# k8s cluster)
try
:
# to be used when inside a kubernetes cluster
config
.
load_incluster_config
()
except
Base
Exception
:
except
Config
Exception
:
try
:
# use .kube directory
# for local development
config
.
load_kube_config
()
except
Base
Exception
:
except
Config
Exception
:
app
.
logger
.
error
(
'No kubernetes cluster defined'
)
environ
[
'HELM_EXPERIMENTAL_OCI'
]
=
'1'
# If app is started via gunicorn
...
...
@@ -33,8 +33,6 @@ if __name__ != '__main__':
app
.
logger
.
removeHandler
(
default_handler
)
app
.
logger
.
info
(
'Starting production server'
)
api
=
Api
(
app
)
app
.
config
[
'SWAGGER'
]
=
{
'title'
:
'autodeploy-service'
,
'version'
:
'dev'
,
...
...
@@ -65,7 +63,7 @@ def favicon():
)
ap
i
.
add_
resource
(
A
uto
D
eploy
,
'/v1/a
uto
d
eploy
'
)
ap
p
.
add_
url_rule
(
'/v1/a
uto
d
eploy
'
,
view_func
=
A
uto
D
eploy
.
view_func
)
# If app is started with Flask
if
__name__
==
'__main__'
:
...
...
requirements.txt
View file @
ca8b7788
Flask
kubernetes
flask-restful
flasgger
flake8
autopep8
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment