lint: reformat python code with black
This commit is contained in:
parent
331beb01b4
commit
a406a7974b
88 changed files with 2579 additions and 1608 deletions
|
@ -9,7 +9,7 @@ from app.models.tfstate import TerraformState
|
|||
tfstate = Blueprint("tfstate", __name__)
|
||||
|
||||
|
||||
@tfstate.route("/<key>", methods=['GET'])
|
||||
@tfstate.route("/<key>", methods=["GET"])
|
||||
def handle_get(key: str) -> ResponseReturnValue:
|
||||
state = TerraformState.query.filter(TerraformState.key == key).first()
|
||||
if state is None or state.state is None:
|
||||
|
@ -17,16 +17,18 @@ def handle_get(key: str) -> ResponseReturnValue:
|
|||
return Response(state.state, content_type="application/json")
|
||||
|
||||
|
||||
@tfstate.route("/<key>", methods=['POST', 'DELETE', 'UNLOCK'])
|
||||
@tfstate.route("/<key>", methods=["POST", "DELETE", "UNLOCK"])
|
||||
def handle_update(key: str) -> ResponseReturnValue:
|
||||
state = TerraformState.query.filter(TerraformState.key == key).first()
|
||||
if not state:
|
||||
if request.method in ["DELETE", "UNLOCK"]:
|
||||
return "OK", 200
|
||||
state = TerraformState(key=key)
|
||||
if state.lock and not (request.method == "UNLOCK" and request.args.get('ID') is None):
|
||||
if state.lock and not (
|
||||
request.method == "UNLOCK" and request.args.get("ID") is None
|
||||
):
|
||||
# force-unlock seems to not give an ID to verify so accept no ID being present
|
||||
if json.loads(state.lock)['ID'] != request.args.get('ID'):
|
||||
if json.loads(state.lock)["ID"] != request.args.get("ID"):
|
||||
return Response(state.lock, status=409, content_type="application/json")
|
||||
if request.method == "POST":
|
||||
state.state = json.dumps(request.json)
|
||||
|
@ -38,9 +40,11 @@ def handle_update(key: str) -> ResponseReturnValue:
|
|||
return "OK", 200
|
||||
|
||||
|
||||
@tfstate.route("/<key>", methods=['LOCK'])
|
||||
@tfstate.route("/<key>", methods=["LOCK"])
|
||||
def handle_lock(key: str) -> ResponseReturnValue:
|
||||
state = TerraformState.query.filter(TerraformState.key == key).with_for_update().first()
|
||||
state = (
|
||||
TerraformState.query.filter(TerraformState.key == key).with_for_update().first()
|
||||
)
|
||||
if state is None:
|
||||
state = TerraformState(key=key, state="")
|
||||
db.session.add(state)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue