Configure pull_base_image
550176
def render_pull_base_image(self):
        """"""
        phase = 'prebuild_plugins'
        plugin = 'pull_base_image'

        if self.user_params.parent_images_digests.value:
            self.pt.set_plugin_arg(phase, plugin, 'parent_images_digests',
                                   self.user_params.parent_images_digests.value)
657291
def get_python_base(self, python_version, pull=True):
        
        name = self.get_arca_base_name()
        tag = self.get_python_base_tag(python_version)

        def get_dockerfile():
            base_arca_name, base_arca_tag = self.get_arca_base(pull)

            return f"""
                FROM {base_arca_name}:{base_arca_tag}
                RUN pyenv update && \
                    pyenv install {python_version}
                ENV PYENV_VERSION {python_version}
                ENV PATH "/home/arca/.pyenv/shims:$PATH"
                RUN pip install --upgrade pip setuptools pipenv
                CMD bash -i
            """

        self.get_or_build_image(name, tag, get_dockerfile, pull=pull)

        return name, tag
962143
def allowed_image(self, module_id):
		
		shutit_global.shutit_global_object.yield_to_draw()
		self.log("In allowed_image: " + module_id,level=logging.DEBUG)
		cfg = self.cfg
		if self.build['ignoreimage']:
			self.log("ignoreimage == true, returning true" + module_id,level=logging.DEBUG)
			return True
		self.log(str(cfg[module_id]['shutit.core.module.allowed_images']),level=logging.DEBUG)
		if cfg[module_id]['shutit.core.module.allowed_images']:
			# Try allowed images as regexps
			for regexp in cfg[module_id]['shutit.core.module.allowed_images']:
				if not shutit_util.check_regexp(regexp):
					self.fail('Illegal regexp found in allowed_images: ' + regexp) # pragma: no cover
				if re.match('^' + regexp + '$', self.target['docker_image']):
					return True
		return False
775283
def push_images(base_path, image_namespace, engine_obj, config, **kwargs):
    
    config_path = kwargs.get('config_path', engine_obj.auth_config_path)
    username = kwargs.get('username')
    password = kwargs.get('password')
    push_to = kwargs.get('push_to')
    url = engine_obj.default_registry_url
    registry_name = engine_obj.default_registry_name
    namespace = image_namespace
    save_conductor = config.save_conductor
    repository_prefix = None
    pull_from_url = None

    if push_to:
        if config.get('registries', dict()).get(push_to):
            url = config['registries'][push_to].get('url')
            namespace = config['registries'][push_to].get('namespace', namespace)
            repository_prefix = config['registries'][push_to].get('repository_prefix')
            pull_from_url = config['registries'][push_to].get('pull_from_url')
            if not url:
                raise AnsibleContainerRegistryAttributeException(
                    u"Registry {} missing required attribute 'url'".format(push_to)
                )
        else:
            url, namespace = resolve_push_to(push_to, engine_obj.default_registry_url, namespace)

    if username and not password:
        # If a username was supplied without a password, prompt for it
        if url != engine_obj.default_registry_url:
            registry_name = url
        while not password:
            password = getpass.getpass(u"Enter password for {0} at {1}: ".format(username, registry_name))

    if config_path:
        # Make sure the config_path exists
        #  - gives us a chance to create the file with correct permissions, if it does not exists
        #  - makes sure we mount a path to the conductor for a specific file
        config_path = os.path.normpath(os.path.expanduser(config_path))
        if os.path.exists(config_path) and os.path.isdir(config_path):
            raise AnsibleContainerException(
                u"Expecting --config-path to be a path to a file, not a directory"
            )
        elif not os.path.exists(config_path):
            # Make sure the directory path exists
            if not os.path.exists(os.path.dirname(config_path)):
                try:
                    os.makedirs(os.path.dirname(config_path), 0o750)
                except OSError:
                    raise AnsibleContainerException(
                        u"Failed to create the requested the path {}".format(os.path.dirname(config_path))
                    )
            # Touch the file
            open(config_path, 'w').close()

    # If you ran build with --save-build-container, then you're broken without first removing
    #  the old build container.
    remove_existing_container(engine_obj, 'conductor', remove_volumes=True)

    push_params = {}
    push_params.update(kwargs)
    push_params['config_path'] = config_path
    push_params['password'] = password
    push_params['url'] = url
    push_params['namespace'] = namespace
    push_params['repository_prefix'] = repository_prefix
    push_params['pull_from_url'] = pull_from_url

    # Push
    engine_obj.await_conductor_command('push', dict(config), base_path, push_params, save_container=save_conductor)

    return {'url': url,
            'namespace': namespace,
            'repository_prefix': repository_prefix,
            'pull_from_url': pull_from_url }
529934
def build(self, client, pull=False, usecache=True):
        
        stage = staging.StagedFile(self.sourceimage, self.sourcepath, self.destpath,
                                   cache_from=self.cache_from)
        stage.stage(self.baseimage, self.buildname)
637922
def pull_dependencies(collector, image, **kwargs):
    """"""
    for dep in image.commands.dependent_images:
        kwargs["image"] = dep
        pull_arbitrary(collector, **kwargs)
951051
private function _configureCpResources()
	{
		Event::on(
			View::class,
			View::EVENT_BEFORE_RENDER_TEMPLATE,
			function(TemplateEvent $event)
			{
				$viewService = Craft::$app->getView();
				$viewService->registerAssetBundle(MainAsset::class);
			}
		);
	}
1050444
protected function configure() {
		// set thumbnails path
		$path = $this->options['tmbPath'];
		if ($path) {
			if (!file_exists($path)) {
				if (@mkdir($path)) {
					chmod($path, $this->options['tmbPathMode']);
				} else {
					$path = '';
				}
			} 
			
			if (is_dir($path) && is_readable($path)) {
				$this->tmbPath = $path;
				$this->tmbPathWritable = is_writable($path);
			}
		}

		// set image manipulation library
		$type = preg_match('/^(imagick|gd|auto)$/i', $this->options['imgLib'])
			? strtolower($this->options['imgLib'])
			: 'auto';

		if (($type == 'imagick' || $type == 'auto') && extension_loaded('imagick')) {
			$this->imgLib = 'imagick';
		} else {
			$this->imgLib = function_exists('gd_info') ? 'gd' : '';
		}
		
	}
397992
def pull_all_external(collector, **kwargs):
    """"""
    deps = set()

    images = collector.configuration["images"]
    for layer in Builder().layered(images):
        for image_name, image in layer:
            for dep in image.commands.external_dependencies:
                deps.add(dep)

    for dep in sorted(deps):
        kwargs["image"] = dep
        pull_arbitrary(collector, **kwargs)
457899
def get_default_image_build_conf(self):
        
        target = self.koji_target

        vcs_info = self.workflow.source.get_vcs_info()
        ksurl = '{}#{}'.format(vcs_info.vcs_url, vcs_info.vcs_ref)

        base_urls = []
        for repo in self.repos:
            for url in self.extract_base_url(repo):
                # Imagefactory only supports $arch variable.
                url = url.replace('$basearch', '$arch')
                base_urls.append(url)

        install_tree = base_urls[0] if base_urls else ''

        repo = ','.join(base_urls)

        kwargs = {
            'target': target,
            'ksurl': ksurl,
            'install_tree': install_tree,
            'repo': repo,
        }
        config_fp = StringIO(self.DEFAULT_IMAGE_BUILD_CONF.format(**kwargs))

        config = ConfigParser()
        config.readfp(config_fp)

        self.update_config_from_dockerfile(config)

        return config
8080
def pull(self):
        
        for json_e in self.d.pull(repository=self.name, tag=self.tag, stream=True, decode=True):
            logger.debug(json_e)
            status = graceful_get(json_e, "status")
            if status:
                logger.info(status)
            else:
                error = graceful_get(json_e, "error")
                logger.error(status)
                raise ConuException("There was an error while pulling the image %s: %s",
                                    self.name, error)
        self.using_transport(SkopeoTransport.DOCKER_DAEMON)
1087254
def base_image_inspect(self):
        
        if self._base_image_inspect is None:

            if self.base_from_scratch:
                self._base_image_inspect = {}
            elif self.parents_pulled or self.custom_base_image:
                try:
                    self._base_image_inspect = self.tasker.inspect_image(self.base_image)

                except docker.errors.NotFound:
                    # If the base image cannot be found throw KeyError -
                    # as this property should behave like a dict
                    raise KeyError("Unprocessed base image Dockerfile cannot be inspected")
            else:
                self._base_image_inspect =\
                    atomic_reactor.util.get_inspect_for_image(self.base_image,
                                                              self.base_image.registry,
                                                              self.base_image_insecure,
                                                              self.base_image_dockercfg_path)

            base_image_str = str(self.base_image)
            if base_image_str not in self._parent_images_inspect:
                self._parent_images_inspect[base_image_str] = self._base_image_inspect

        return self._base_image_inspect
239838
private boolean imageRequiresPull(boolean hasImage, ImagePullPolicy pullPolicy, String imageName)
        throws MojoExecutionException {

        // The logic here is like this (see also #96):
        // otherwise: don't pull

        if (pullPolicy == ImagePullPolicy.Never) {
            if (!hasImage) {
                throw new MojoExecutionException(
                    String.format("No image '%s' found and pull policy 'Never' is set. Please chose another pull policy or pull the image yourself)", imageName));
            }
            return false;
        }

        // If the image is not available and mode is not ImagePullPolicy.Never --> pull
        if (!hasImage) {
            return true;
        }

        // If pullPolicy == Always --> pull, otherwise not (we have it already)
        return pullPolicy == ImagePullPolicy.Always;
    }
710374
protected function configure() {
		$this->setName( 'pull' );
		$this->setDescription( 'Pull a snapshot into a WordPress instance.' );
		$this->addArgument( 'snapshot_id', InputArgument::REQUIRED, 'Snapshot ID to pull.' );
		$this->addOption( 'confirm', null, InputOption::VALUE_NONE, 'Confirm pull operation.' );
		$this->addOption( 'repository', null, InputOption::VALUE_REQUIRED, 'Repository to use. Defaults to first repository saved in config.' );
		$this->addOption( 'confirm_wp_download', null, InputOption::VALUE_NONE, 'Confirm WordPress download.' );
		$this->addOption( 'confirm_config_create', null, InputOption::VALUE_NONE, 'Confirm wp-config.php create.' );
		$this->addOption( 'confirm_wp_version_change', null, InputOption::VALUE_NONE, 'Confirm changing WP version to match snapshot.' );
		$this->addOption( 'confirm_ms_constant_update', null, InputOption::VALUE_NONE, 'Confirm updating constants in wp-config.php for multisite.' );

		$this->addOption( 'config_db_host', null, InputOption::VALUE_REQUIRED, 'Config database host.' );
		$this->addOption( 'config_db_name', null, InputOption::VALUE_REQUIRED, 'Config database name.' );
		$this->addOption( 'config_db_user', null, InputOption::VALUE_REQUIRED, 'Config database user.' );
		$this->addOption( 'config_db_password', null, InputOption::VALUE_REQUIRED, 'Config database password.' );

		$this->addOption( 'path', null, InputOption::VALUE_REQUIRED, 'Path to WordPress files.' );

		$this->addOption( 'skip_table_search_replace', [], InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Skip search and replacing specific tables. Leave out table prefix.' );

		$this->addOption( 'db_host', null, InputOption::VALUE_REQUIRED, 'Database host.' );
		$this->addOption( 'db_name', null, InputOption::VALUE_REQUIRED, 'Database name.' );
		$this->addOption( 'db_user', null, InputOption::VALUE_REQUIRED, 'Database user.' );
		$this->addOption( 'db_password', null, InputOption::VALUE_REQUIRED, 'Database password.' );

		/**
		 * Site Mapping JSON should look like this:
		 *
		 * [
		 *  {
		 *      "home_url" : "http://homeurl1",
		 *      "site_url" : "http://siteurl1"
		 *      "blog_id"  : 1
		 *  }
		 *  ...
		 * ]
		 *
		 * If blog_id isn't used, order will be respected as compared to the snapshot meta.
		 */
		$this->addOption( 'site_mapping', null, InputOption::VALUE_REQUIRED, 'JSON or path to site mapping file.' );
		$this->addOption( 'main_domain', null, InputOption::VALUE_REQUIRED, 'Main domain for multisite snapshots' );
	}
402344
def make_image_converters(self, image, configuration, harpoon_spec):
        """"""
        def convert_image(path, val):
            log.info("Converting %s", path)
            everything = path.configuration.root().wrapped()
            meta = Meta(everything, [])
            configuration.converters.started(path)

            base = path.configuration.root().wrapped()
            base.update(configuration.as_dict(ignore=["images"]))
            base.update(val.as_dict(ignore=["images"]))

            base["__image__"] = base
            everything["__image__"] = base

            base["harpoon"] = configuration["harpoon"]
            base["configuration"] = configuration
            return harpoon_spec.image_spec.normalise(meta.at("images").at(image), base)

        converter = Converter(convert=convert_image, convert_path=["images", image])
        configuration.add_converter(converter)

        def convert_tasks(path, val):
            spec = harpoon_spec.tasks_spec(available_actions)
            meta = Meta(path.configuration.root(), []).at("images").at(image).at("tasks")
            configuration.converters.started(path)
            tasks = spec.normalise(meta, val)
            for task in tasks.values():
                task.image = image
            return tasks

        converter = Converter(convert=convert_tasks, convert_path=["images", image, "tasks"])
        configuration.add_converter(converter)
77880
def adjust_for_custom_base_image(self):
        
        plugins = []
        if self.is_custom_base_image():
            # Plugins irrelevant to building base images.
            plugins.append(("prebuild_plugins", "pull_base_image"))
            plugins.append(("prebuild_plugins", "koji_parent"))
            plugins.append(("prebuild_plugins", "inject_parent_image"))
            msg = "removing %s from custom image build request"
        else:
            # Plugins not needed for building non base images.
            plugins.append(("prebuild_plugins", "add_filesystem"))
            msg = "removing %s from non custom image build request"

        for when, which in plugins:
            logger.info(msg, which)
            self.dj.remove_plugin(when, which)
747076
def default_image_loader(filename, flags, **kwargs):
    

    def load(rect=None, flags=None):
        return filename, rect, flags

    return load