def build(target_image): build = Build() build.debug = True build.playbook_path = basic_playbook_path build.base_image = base_image build.target_image = target_image build.metadata = ImageMetadata() build.state = BuildState.NEW build.builder_name = "buildah" # test with all builders return build
def test_find_py_intrprtr_in_fedora_image(image_name, found): build = Build() build.base_image = image_name build.target_image = "starena" bb = BuildahBuilder(build) try: assert bb.find_python_interpreter() except RuntimeError: if found: # interpreter should have been found raise
def test_buildah_sanity_check_extra_args(caplog): set_logging(level=logging.DEBUG) build = Build() build.base_image = base_image build.buildah_from_extra_args = "--help" b = BuildahBuilder(build, debug=True) b.ansible_host = "cacao" with pytest.raises(CalledProcessError): b.sanity_check() for r in caplog.records: if "-h, --help" in r.message: break else: assert 1/0, "it seems that buildah_from_extra_args were not passed to sanity check"
def build_inside_openshift(app): """ This is expected to run inside an openshift pod spawned via custom build :param app: instance of Application """ playbook_path, base_image = okd_get_playbook_base() if playbook_path.startswith("/"): raise RuntimeError( "The path to playbook needs to be relative within the git repo.") uri, ref, target_image = okd_load_metadata() tmp = tempfile.mkdtemp(prefix="ab-okd") try: git_clone_to_path(uri, tmp, ref=ref) playbook_path = os.path.abspath(os.path.join(tmp, playbook_path)) if not playbook_path.startswith(tmp): raise RuntimeError( "The path to playbook points outside of the git repo, this is not allowed." ) build = Build() build.metadata = ImageMetadata() # TODO: needs to be figured out build.playbook_path = playbook_path build.base_image = base_image build.target_image = target_image build.builder_name = "buildah" build.cache_tasks = False # we have local storage in pod, so this doesn't make any sense app.build(build) finally: shutil.rmtree(tmp)