Example #1
0
def _cli_deploy_image(args):
    docker_repository = _resolve_property(args, 'docker_repository')
    try:
        vault_secret = _resolve_property(args, 'vault_secret')
    except ValueError:
        vault_secret = None
    image_tar_path = args.image_tar_path if args.image_tar_path  else find_image_file()

    deploy_docker_image(image_tar_path=image_tar_path,
                        auth_method=args.auth_method,
                        docker_repository=docker_repository,
                        vault_endpoint=_resolve_vault_endpoint(args),
                        vault_secret=vault_secret)
Example #2
0
    def test_should_remove_image_from_local_registry_after_failed_deploy(
            self, remove_docker_image_from_local_registry, tag_image,
            load_image_from_tar, decode_version_number_from_file_name):

        # given
        decode_version_number_from_file_name.return_value = 'version123'
        load_image_from_tar.return_value = 'image_id'

        # when
        with self.assertRaises(ValueError):
            deploy_docker_image('image-version123.tar', 'docker_repository',
                                'invalid_auth_method')

        # then
        load_image_from_tar.assert_called_with('image-version123.tar')
        remove_docker_image_from_local_registry.assert_called_with(
            'version123')
Example #3
0
def _cli_deploy_image(args):
    docker_repository = _resolve_property(args, 'docker_repository')
    try:
        vault_secret = _resolve_property(args, 'vault_secret')
    except ValueError:
        vault_secret = None
    if args.image_tar_path:
        build_ver = _decode_version_number_from_file_name(Path(args.image_tar_path))
        image_id = load_image_from_tar(args.image_tar_path)
        tag_image(image_id, docker_repository, build_ver)
    else:
        build_ver = args.version

    deploy_docker_image(build_ver=build_ver,
                        auth_method=args.auth_method,
                        docker_repository=docker_repository,
                        vault_endpoint=_resolve_vault_endpoint(args),
                        vault_secret=vault_secret)
Example #4
0
    def test_should_remove_image_from_local_registry_after_deploy(
            self, remove_docker_image_from_local_registry,
            _deploy_image_loaded_to_local_registry, load_image_from_tar,
            decode_version_number_from_file_name):
        # given
        decode_version_number_from_file_name.return_value = 'version123'
        load_image_from_tar.return_value = 'image_id'

        # when
        deploy_docker_image('image-version123.tar', 'docker_repository')

        # then
        decode_version_number_from_file_name.assert_called_with(
            Path('image-version123.tar'))
        load_image_from_tar.assert_called_with('image-version123.tar')
        _deploy_image_loaded_to_local_registry.assert_called_with(
            'version123', 'docker_repository', 'image_id', 'local_account',
            None, None)
        remove_docker_image_from_local_registry.assert_called_with(
            'version123')