refactor(data): add in new config for builder
we are doing phase one of the four phase migration on the builder config
This commit is contained in:
parent
123d003d4e
commit
f701677a8e
4 changed files with 86 additions and 6 deletions
|
@ -1,13 +1,15 @@
|
|||
import json
|
||||
|
||||
from peewee import JOIN_LEFT_OUTER
|
||||
import os
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
from peewee import JOIN_LEFT_OUTER
|
||||
|
||||
import features
|
||||
from data.database import (BuildTriggerService, RepositoryBuildTrigger, Repository, Namespace, User,
|
||||
RepositoryBuild, BUILD_PHASE, db_for_update, db_random_func)
|
||||
from data.model import (InvalidBuildTriggerException, InvalidRepositoryBuildException,
|
||||
db_transaction, user as user_model)
|
||||
|
||||
from data.model.helpers.build_helper import _get_config_expand
|
||||
|
||||
PRESUMED_DEAD_BUILD_AGE = timedelta(days=15)
|
||||
PHASES_NOT_ALLOWED_TO_CANCEL_FROM = (BUILD_PHASE.PUSHING, BUILD_PHASE.COMPLETE,
|
||||
|
@ -15,8 +17,9 @@ PHASES_NOT_ALLOWED_TO_CANCEL_FROM = (BUILD_PHASE.PUSHING, BUILD_PHASE.COMPLETE,
|
|||
|
||||
ARCHIVABLE_BUILD_PHASES = [BUILD_PHASE.COMPLETE, BUILD_PHASE.ERROR, BUILD_PHASE.CANCELLED]
|
||||
|
||||
|
||||
def update_build_trigger(trigger, config, auth_token=None):
|
||||
trigger.config = json.dumps(config or {})
|
||||
trigger.config = json.dumps(_get_config_expand(config or {}))
|
||||
if auth_token is not None:
|
||||
trigger.auth_token = auth_token
|
||||
trigger.save()
|
||||
|
@ -29,10 +32,12 @@ def create_build_trigger(repo, service_name, auth_token, user, pull_robot=None,
|
|||
auth_token=auth_token,
|
||||
connected_user=user,
|
||||
pull_robot=pull_robot,
|
||||
config=json.dumps(config))
|
||||
config=json.dumps(_get_config_expand(config)))
|
||||
return trigger
|
||||
|
||||
|
||||
|
||||
|
||||
def get_build_trigger(trigger_uuid):
|
||||
try:
|
||||
return (RepositoryBuildTrigger
|
||||
|
@ -168,6 +173,7 @@ def update_phase(build_uuid, phase):
|
|||
|
||||
def create_cancel_build_in_queue(build, build_queue):
|
||||
""" A function to cancel a build before it leaves the queue """
|
||||
|
||||
def cancel_build():
|
||||
cancelled = False
|
||||
|
||||
|
@ -184,6 +190,7 @@ def create_cancel_build_in_queue(build, build_queue):
|
|||
|
||||
def create_cancel_build_in_manager(build, build_canceller):
|
||||
""" A function to cancel the build before it starts to push """
|
||||
|
||||
def cancel_build():
|
||||
if build.phase in PHASES_NOT_ALLOWED_TO_CANCEL_FROM:
|
||||
return False
|
||||
|
@ -239,4 +246,3 @@ def get_archivable_build():
|
|||
return RepositoryBuild.get(id=found_id)
|
||||
except RepositoryBuild.DoesNotExist:
|
||||
return None
|
||||
|
||||
|
|
Reference in a new issue