Merge pull request #2479 from charltonaustin/phase_three_config
feat(data): remove writing of old config
This commit is contained in:
commit
38d4af0d8b
4 changed files with 2 additions and 27 deletions
|
@ -9,7 +9,6 @@ from data.database import (BuildTriggerService, RepositoryBuildTrigger, Reposito
|
||||||
RepositoryBuild, BUILD_PHASE, db_for_update, db_random_func)
|
RepositoryBuild, BUILD_PHASE, db_for_update, db_random_func)
|
||||||
from data.model import (InvalidBuildTriggerException, InvalidRepositoryBuildException,
|
from data.model import (InvalidBuildTriggerException, InvalidRepositoryBuildException,
|
||||||
db_transaction, user as user_model)
|
db_transaction, user as user_model)
|
||||||
from data.model.helpers.build_helper import _get_config_expand
|
|
||||||
|
|
||||||
PRESUMED_DEAD_BUILD_AGE = timedelta(days=15)
|
PRESUMED_DEAD_BUILD_AGE = timedelta(days=15)
|
||||||
PHASES_NOT_ALLOWED_TO_CANCEL_FROM = (BUILD_PHASE.PUSHING, BUILD_PHASE.COMPLETE,
|
PHASES_NOT_ALLOWED_TO_CANCEL_FROM = (BUILD_PHASE.PUSHING, BUILD_PHASE.COMPLETE,
|
||||||
|
@ -19,7 +18,7 @@ ARCHIVABLE_BUILD_PHASES = [BUILD_PHASE.COMPLETE, BUILD_PHASE.ERROR, BUILD_PHASE.
|
||||||
|
|
||||||
|
|
||||||
def update_build_trigger(trigger, config, auth_token=None, write_token=None):
|
def update_build_trigger(trigger, config, auth_token=None, write_token=None):
|
||||||
trigger.config = json.dumps(_get_config_expand(config or {}))
|
trigger.config = json.dumps(config or {})
|
||||||
if auth_token is not None:
|
if auth_token is not None:
|
||||||
trigger.auth_token = auth_token
|
trigger.auth_token = auth_token
|
||||||
|
|
||||||
|
@ -30,13 +29,12 @@ def update_build_trigger(trigger, config, auth_token=None, write_token=None):
|
||||||
|
|
||||||
|
|
||||||
def create_build_trigger(repo, service_name, auth_token, user, pull_robot=None, config=None):
|
def create_build_trigger(repo, service_name, auth_token, user, pull_robot=None, config=None):
|
||||||
config = config or {}
|
|
||||||
service = BuildTriggerService.get(name=service_name)
|
service = BuildTriggerService.get(name=service_name)
|
||||||
trigger = RepositoryBuildTrigger.create(repository=repo, service=service,
|
trigger = RepositoryBuildTrigger.create(repository=repo, service=service,
|
||||||
auth_token=auth_token,
|
auth_token=auth_token,
|
||||||
connected_user=user,
|
connected_user=user,
|
||||||
pull_robot=pull_robot,
|
pull_robot=pull_robot,
|
||||||
config=json.dumps(_get_config_expand(config)))
|
config=json.dumps(config or {}))
|
||||||
return trigger
|
return trigger
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
|
|
||||||
def _get_config_expand(config):
|
|
||||||
""" Get config with both context and dockerfile_path written to it """
|
|
||||||
if not config:
|
|
||||||
return {}
|
|
||||||
if 'context' in config:
|
|
||||||
config['subdir'] = config['context']
|
|
||||||
|
|
||||||
return config
|
|
|
@ -1,14 +0,0 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
from data.model.helpers.build_helper import _get_config_expand
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('org_config,expected', [
|
|
||||||
(None, {}),
|
|
||||||
({}, {}),
|
|
||||||
({'some other key': 'some other value'}, {'some other key': 'some other value'}),
|
|
||||||
({'context': 'some/context', 'dockerfile_path': 'some/context/with/Dockerfile'},
|
|
||||||
{'context': 'some/context', 'dockerfile_path': 'some/context/with/Dockerfile', 'subdir': 'some/context'}),
|
|
||||||
])
|
|
||||||
def test_super_user_build_endpoints(org_config, expected):
|
|
||||||
assert _get_config_expand(org_config) == expected
|
|
Reference in a new issue