Ejemplo n.º 1
0
    def should_run(self):
        """
        Determine if this is an operator manifest bundle build

        :return: bool, should plugin run?
        """
        if not has_operator_bundle_manifest(self.workflow):
            self.log.info(
                "Not an operator manifest bundle build, skipping plugin")
            return False
        if get_operator_manifests(self.workflow, fallback=None) is None:
            msg = "operator_manifests configuration missing in reactor config map, aborting"
            self.log.warning(msg)
            return False
        return True
    def run_in_orchestrator(self):
        """
        Run plugin in orchestrator. Find all image pullspecs,
        compute their replacements and set build arg for worker
        """
        try:
            self.site_config = get_operator_manifests(self.workflow)
        except KeyError:
            msg = "operator_manifests configuration missing in reactor config map, aborting"
            self.log.warning(msg)
            return

        operator_manifest = self._get_operator_manifest()
        pullspecs = self._get_pullspecs(operator_manifest)

        if pullspecs:
            replacement_pullspecs = self._get_replacement_pullspecs(pullspecs)
            self._set_worker_arg(replacement_pullspecs)
Ejemplo n.º 3
0
    def __init__(self, user_config, workflow):
        """
        Initialize a PullspecReplacer

        :param user_config: container.yaml operator_manifest configuration
        :param workflow: DockerBuildWorkflow, contains reactor config map
        """
        log_name = "atomic_reactor.plugins.{}".format(
            PinOperatorDigestsPlugin.key)
        self.log = logging.getLogger(log_name)

        self.workflow = workflow
        site_config = get_operator_manifests(workflow)

        self.allowed_registries = site_config["allowed_registries"]
        if self.allowed_registries is not None:
            self.allowed_registries = set(self.allowed_registries)

        self.registry_replace = {
            registry["old"]: registry["new"]
            for registry in site_config.get("registry_post_replace", [])
        }

        self.package_mapping_urls = {
            mapping["registry"]: mapping["package_mappings_url"]
            for mapping in site_config.get("repo_replacements", [])
        }
        # Mapping of [url => package mapping]
        # Loaded when needed, see _get_site_mapping
        self.url_package_mappings = {}

        self.user_package_mappings = {
            mapping["registry"]: mapping["package_mappings"]
            for mapping in user_config.get("repo_replacements", [])
        }
        # Final package mapping that you get by combining site mapping with user mapping
        # Loaded when needed, see _get_final_mapping
        self.final_package_mappings = {}

        # RegistryClient instances cached by registry name
        self.registry_clients = {}
Ejemplo n.º 4
0
    def _skip_all(self):
        skip_all = self.user_config.get("skip_all", False)

        if not skip_all:
            return False

        site_config = get_operator_manifests(self.workflow)
        allowed_packages = site_config.get("skip_all_allow_list", [])

        parser = df_parser(self.workflow.builder.df_path,
                           workflow=self.workflow)
        dockerfile_labels = parser.labels
        labels = Labels(dockerfile_labels)

        component_label = labels.get_name(Labels.LABEL_TYPE_COMPONENT)
        component = dockerfile_labels[component_label]

        if component in allowed_packages:
            return True
        else:
            raise RuntimeError(
                "Koji package: {} isn't allowed to use skip_all for operator "
                "bundles".format(component))
Ejemplo n.º 5
0
    def __init__(self,
                 tasker,
                 workflow,
                 replacement_pullspecs=None,
                 operator_csv_modifications_url=None):
        """
        Initialize pin_operator_digests plugin

        :param tasker: ContainerTasker instance
        :param workflow: DockerBuildWorkflow instance
        :param replacement_pullspecs: Dict[str, str], computed in orchestrator,
                                      provided to workers by osbs-client
        :param operator_csv_modifications_url: str, URL to JSON file with operator
                                      CSV modifications
        """
        super(PinOperatorDigestsPlugin, self).__init__(tasker, workflow)
        self.user_config = workflow.source.config.operator_manifests
        self.replacement_pullspecs = replacement_pullspecs or {}
        self.operator_csv_modifications_url = operator_csv_modifications_url

        site_config = get_operator_manifests(self.workflow, fallback={})
        self.operator_csv_modification_allowed_attributes = set(
            tuple(key_path) for key_path in (site_config.get(
                'csv_modifications', {}).get('allowed_attributes', [])))