feat(add dockerfile_path to build api): added in a dockerfile to specify path
### Description of Changes this allows people to specify a context and a dockerfile path
This commit is contained in:
parent
3a72a8ef9c
commit
63a2f0c14b
2 changed files with 20 additions and 2 deletions
|
@ -175,7 +175,15 @@ class RepositoryBuildList(RepositoryParamResource):
|
||||||
},
|
},
|
||||||
'subdirectory': {
|
'subdirectory': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'description': 'Subdirectory in which the Dockerfile can be found',
|
'description': 'Subdirectory in which the Dockerfile can be found. You can only specify this or dockerfile_path',
|
||||||
|
},
|
||||||
|
'dockerfile_path': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Path to a dockerfile. You can only specify this or subdirectory.',
|
||||||
|
},
|
||||||
|
'context': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Pass in the context for the dockerfile. This is optional.',
|
||||||
},
|
},
|
||||||
'pull_robot': {
|
'pull_robot': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
|
@ -310,9 +318,14 @@ class RepositoryBuildList(RepositoryParamResource):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_dockerfile_context(request_json):
|
def get_dockerfile_context(request_json):
|
||||||
context = request_json['context'] if 'context' in request_json else os.path.sep
|
context = request_json['context'] if 'context' in request_json else os.path.sep
|
||||||
|
if 'dockerfile_path' in request_json:
|
||||||
|
subdir = request_json['dockerfile_path']
|
||||||
|
if 'context' not in request_json:
|
||||||
|
context = os.path.dirname(subdir)
|
||||||
|
return context, subdir
|
||||||
|
|
||||||
if 'subdirectory' in request_json:
|
if 'subdirectory' in request_json:
|
||||||
subdir = request_json['subdirectory']
|
subdir = request_json['subdirectory']
|
||||||
|
|
||||||
context = subdir
|
context = subdir
|
||||||
if not subdir.endswith(os.path.sep):
|
if not subdir.endswith(os.path.sep):
|
||||||
subdir += os.path.sep
|
subdir += os.path.sep
|
||||||
|
|
|
@ -8,6 +8,11 @@ from endpoints.api.build import RepositoryBuildList
|
||||||
({'context': '/some_context'}, '/some_context/Dockerfile', '/some_context'),
|
({'context': '/some_context'}, '/some_context/Dockerfile', '/some_context'),
|
||||||
({'subdirectory': 'some_context'}, 'some_context/Dockerfile', 'some_context'),
|
({'subdirectory': 'some_context'}, 'some_context/Dockerfile', 'some_context'),
|
||||||
({'subdirectory': 'some_context/'}, 'some_context/Dockerfile', 'some_context/'),
|
({'subdirectory': 'some_context/'}, 'some_context/Dockerfile', 'some_context/'),
|
||||||
|
({'dockerfile_path': 'some_context/Dockerfile'}, 'some_context/Dockerfile', 'some_context'),
|
||||||
|
({'dockerfile_path': 'some_context/Dockerfile', 'context': '/'}, 'some_context/Dockerfile', '/'),
|
||||||
|
({'dockerfile_path': 'some_context/Dockerfile',
|
||||||
|
'context': '/',
|
||||||
|
'subdirectory': 'slime'}, 'some_context/Dockerfile', '/'),
|
||||||
])
|
])
|
||||||
def test_extract_dockerfile_args(request_json, subdir, context):
|
def test_extract_dockerfile_args(request_json, subdir, context):
|
||||||
actual_context, actual_subdir = RepositoryBuildList.get_dockerfile_context(request_json)
|
actual_context, actual_subdir = RepositoryBuildList.get_dockerfile_context(request_json)
|
||||||
|
|
Reference in a new issue