예제 #1
0
 def test_dockerfile_2(self):
     build_params = {
         "source_type": "dockerfile",
         "source_url": "https://link/to/Dockerfile",
         "target_image_name": "my_image_name",
         "target_image_tag": "my_image_tag"
     }
     valid, message = validate(BuildParams.from_dict(build_params))
     assert valid
     assert message == ''
예제 #2
0
 def test_tar(self):
     build_params = {
         "source_type": "tar",
         "source_url": "https://link/to/my_image.tar",
         "source_username": "******",
         "source_password": "******",
         "target_image_name": "my_image_name",
         "target_image_tag": "my_image_tag"
     }
     valid, message = validate(BuildParams.from_dict(build_params))
     assert valid
     assert message == ''
def post_build():
    """Request building image

    :rtype: Invocation
    """
    build_params = BuildParams.from_dict(connexion.request.get_json())
    valid, message = validate(build_params)
    if not valid:
        return message, 400

    logger.debug(json.dumps(build_params.to_dict(), indent=2))

    inv = invocation_service.invoke(build_params)

    return BuildingStarted(inv.invocation_id), 202
예제 #4
0
 def test_git(self):
     build_params = {
         "source_type": "git",
         "source_repo": {
             "url": "https://url/to/repo.git",
             "username": "******",
             "password": "******",
             "dockerfile": "path/to/Dockerfile",
             "workdir": "."
         },
         "target_image_name": "my_image_name",
         "target_image_tag": "my_image_tag"
     }
     valid, message = validate(BuildParams.from_dict(build_params))
     assert valid
     assert message == ''
예제 #5
0
 def test_dockerfile_1(self):
     build_params = {
         "source_type": "dockerfile",
         "source_url": "https://link/to/Dockerfile",
         "source_username": "******",
         "source_password": "******",
         "build_context": {
             "url": "https://url/to/git/repo/with/build_context.git",
             "username": "******",
             "password": "******"
         },
         "target_image_name": "my_image_name",
         "target_image_tag": "my_image_tag"
     }
     valid, message = validate(BuildParams.from_dict(build_params))
     assert valid
     assert message == ''
예제 #6
0
 def test_fail(self):
     build_params = {
         "source_type":
         "git",
         "build_context": {
             "url": "build_context_url",
             "username": "******",
             "password": "******",
             "subdir": "build_context_workdir"
         },
         "source_password":
         "******",
         "source_repo": {
             "url": "repo_url",
             "username": "******",
             "password": "******",
             "workdir": "docker_workdir",
             "dockerfile": "git_dockerfile"
         },
         "source_url":
         "source_url",
         "source_username":
         "******",
         "target_image_name":
         "target_image_name",
         "target_image_tag":
         "latest",
         "target_images": [{
             "base": "base",
             "image": "image",
             "tag": "tag"
         }, {
             "base": "base",
             "image": "image",
             "tag": "tag"
         }]
     }
     valid, message = validate(BuildParams.from_dict(build_params))
     assert not valid
     assert message != ''