Merge pull request #2496 from charltonaustin/fix_dockerfile_upload_api
fix(endpoints): appending dockerfile to api call
This commit is contained in:
commit
3a72a8ef9c
2 changed files with 15 additions and 8 deletions
|
@ -4,9 +4,9 @@ import hashlib
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
from urlparse import urlparse
|
||||
|
||||
from flask import request
|
||||
from urlparse import urlparse
|
||||
|
||||
from app import userfiles as user_files, build_logs, log_archive, dockerfile_build_queue
|
||||
from auth.permissions import (ReadRepositoryPermission, ModifyRepositoryPermission,
|
||||
|
@ -24,7 +24,6 @@ from endpoints.building import start_build, PreparedBuild, MaximumBuildsQueuedEx
|
|||
from endpoints.exception import Unauthorized, NotFound, InvalidRequest
|
||||
from util.names import parse_robot_username
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -312,12 +311,19 @@ class RepositoryBuildList(RepositoryParamResource):
|
|||
def get_dockerfile_context(request_json):
|
||||
context = request_json['context'] if 'context' in request_json else os.path.sep
|
||||
if 'subdirectory' in request_json:
|
||||
subdir = request_json["subdirectory"]
|
||||
subdir = request_json['subdirectory']
|
||||
|
||||
context = subdir
|
||||
if not subdir.endswith(os.path.sep):
|
||||
subdir += os.path.sep
|
||||
|
||||
subdir += 'Dockerfile'
|
||||
else:
|
||||
if context.endswith(os.path.sep):
|
||||
subdir = context + "Dockerfile"
|
||||
subdir = context + 'Dockerfile'
|
||||
else:
|
||||
subdir = context + os.path.sep + "Dockerfile"
|
||||
subdir = context + os.path.sep + 'Dockerfile'
|
||||
|
||||
return context, subdir
|
||||
|
||||
@resource('/v1/repository/<apirepopath:repository>/build/<build_uuid>')
|
||||
|
|
|
@ -4,9 +4,10 @@ from endpoints.api.build import RepositoryBuildList
|
|||
|
||||
|
||||
@pytest.mark.parametrize('request_json,subdir,context', [
|
||||
({}, "/Dockerfile", "/"),
|
||||
({"context": "/some_context"}, "/some_context/Dockerfile", "/some_context"),
|
||||
({"subdirectory": "/some_subdir/Dockerfile"}, "/some_subdir/Dockerfile", "/"),
|
||||
({}, '/Dockerfile', '/'),
|
||||
({'context': '/some_context'}, '/some_context/Dockerfile', '/some_context'),
|
||||
({'subdirectory': 'some_context'}, 'some_context/Dockerfile', 'some_context'),
|
||||
({'subdirectory': 'some_context/'}, 'some_context/Dockerfile', 'some_context/'),
|
||||
])
|
||||
def test_extract_dockerfile_args(request_json, subdir, context):
|
||||
actual_context, actual_subdir = RepositoryBuildList.get_dockerfile_context(request_json)
|
||||
|
|
Reference in a new issue