예제 #1
0
    def __init__(self, tasker, workflow,
                 compose_ids=tuple(),
                 odcs_url=None, odcs_insecure=False,
                 odcs_openidc_secret_path=None,
                 signing_intent=None):
        """
        constructor

        :param tasker: ContainerTasker instance
        :param workflow: DockerBuildWorkflow instance
        :param compose_ids: use the given compose_ids instead of requesting a new one
        :param odcs_url: URL of ODCS (On Demand Compose Service)
        :param odcs_insecure: If True, don't check SSL certificates for `odcs_url`
        :param odcs_openidc_secret_path: directory to look in for a `token` file (optional)
        :param signing_intent: override the signing intent from git repo configuration
        :
        """
        # call parent constructor
        super(ResolveModuleComposePlugin, self).__init__(tasker, workflow)

        self.signing_intent_name = signing_intent
        self.compose_ids = compose_ids
        self.compose_id = None

        self.odcs_fallback = {
            'api_url': odcs_url,
            'insecure': odcs_insecure,
            'auth': {
                'openidc_dir': odcs_openidc_secret_path
            }
        }
        if not get_odcs(self.workflow, self.odcs_fallback)['api_url']:
            raise RuntimeError("odcs_url is required")

        self.data = None
    def __init__(self, tasker, workflow,
                 compose_ids=tuple(),
                 odcs_url=None, odcs_insecure=False,
                 odcs_openidc_secret_path=None,
                 signing_intent=None,
                 pdc_url=None, pdc_insecure=False):
        """
        constructor

        :param tasker: DockerTasker instance
        :param workflow: DockerBuildWorkflow instance
        :param compose_ids: use the given compose_ids instead of requesting a new one
        :param odcs_url: URL of ODCS (On Demand Compose Service)
        :param odcs_insecure: If True, don't check SSL certificates for `odcs_url`
        :param odcs_openidc_secret_path: directory to look in for a `token` file (optional)
        :param signing_intent: override the signing intent from git repo configuration
        :param pdc_url: unused
        :param pdc_insecure: unused
        :
        """
        # call parent constructor
        super(ResolveModuleComposePlugin, self).__init__(tasker, workflow)

        self.signing_intent_name = signing_intent
        self.compose_ids = compose_ids
        self.compose_id = None

        self.odcs_fallback = {
            'api_url': odcs_url,
            'insecure': odcs_insecure,
            'auth': {
                'openidc_dir': odcs_openidc_secret_path
            }
        }
        if not get_odcs(self.workflow, self.odcs_fallback)['api_url']:
            raise RuntimeError("odcs_url is required")

        self.data = None
    def adjust_config_kwargs(self):
        koji_fallback = {
            'hub_url': self.config_kwargs.get('koji_hub'),
            'root_url': self.config_kwargs.get('koji_root')
        }
        koji_map = get_koji(self.workflow, koji_fallback)
        self.config_kwargs['koji_hub'] = koji_map['hub_url']
        self.config_kwargs['koji_root'] = koji_map['root_url']

        odcs_fallback = {
            'api_url': self.config_kwargs.get('odcs_url'),
            'insecure': self.config_kwargs.get('odcs_insecure')
        }
        odcs_map = get_odcs(self.workflow, odcs_fallback)
        self.config_kwargs['odcs_url'] = odcs_map['api_url']
        self.config_kwargs['odcs_insecure'] = odcs_map.get('insecure', False)

        smtp_fallback = {
            'host': self.config_kwargs.get('smtp_host'),
            'from_address': self.config_kwargs.get('smtp_from'),
            'domain': self.config_kwargs.get('smtp_email_domain'),
            'send_to_submitter': self.config_kwargs.get('smtp_to_submitter'),
            'send_to_pkg_owner': self.config_kwargs.get('smtp_to_pkgowner')
        }
        additional_addresses = self.config_kwargs.get('smtp_error_addresses')
        error_addresses = self.config_kwargs.get('smtp_additional_addresses')

        smtp_fallback['additional_addresses'] =\
            additional_addresses.split(',') if additional_addresses else ()
        smtp_fallback['error_addresses'] = error_addresses.split(
            ',') if error_addresses else ()

        smtp_map = get_smtp(self.workflow, smtp_fallback)
        self.config_kwargs['smtp_additional_addresses'] =\
            ','.join(smtp_map.get('additional_addresses', ()))
        self.config_kwargs['smtp_email_domain'] = smtp_map.get('domain')
        self.config_kwargs['smtp_error_addresses'] = ','.join(
            smtp_map.get('error_addresses', ()))
        self.config_kwargs['smtp_from'] = smtp_map['from_address']
        self.config_kwargs['smtp_host'] = smtp_map['host']
        self.config_kwargs['smtp_to_pkgowner'] = smtp_map.get(
            'send_to_pkg_owner', False)
        self.config_kwargs['smtp_to_submitter'] = smtp_map.get(
            'send_to_submitter', False)

        source_reg = self.config_kwargs.get('source_registry_uri')
        souce_registry = get_source_registry(
            self.workflow,
            {'uri': RegistryURI(source_reg) if source_reg else None})['uri']
        self.config_kwargs[
            'source_registry_uri'] = souce_registry.uri if souce_registry else None

        artifacts = self.config_kwargs.get('artifacts_allowed_domains')
        self.config_kwargs['artifacts_allowed_domains'] =\
            ','.join(get_artifacts_allowed_domains(
                self.workflow, artifacts.split(',') if artifacts else ()))

        equal_labels_fallback = []
        equal_labels_str = self.config_kwargs.get('equal_labels')

        if equal_labels_str:
            label_groups = [x.strip() for x in equal_labels_str.split(',')]

            for label_group in label_groups:
                equal_labels_fallback.append(
                    [label.strip() for label in label_group.split(':')])

        equal_labels = get_image_equal_labels(self.workflow,
                                              equal_labels_fallback)
        if equal_labels:
            equal_labels_sets = []
            for equal_set in equal_labels:
                equal_labels_sets.append(':'.join(equal_set))
            equal_labels_string = ','.join(equal_labels_sets)
            self.config_kwargs['equal_labels'] = equal_labels_string

        self.config_kwargs['prefer_schema1_digest'] =\
            get_prefer_schema1_digest(self.workflow,
                                      self.config_kwargs.get('prefer_schema1_digest'))

        registry_api_ver = self.config_kwargs.get('registry_api_versions')
        self.config_kwargs['registry_api_versions'] =\
            ','.join(get_content_versions(self.workflow,
                                          registry_api_ver.split(',') if registry_api_ver else ()))

        self.config_kwargs['yum_proxy'] =\
            get_yum_proxy(self.workflow, self.config_kwargs.get('yum_proxy'))

        self.config_kwargs['sources_command'] =\
            get_sources_command(self.workflow, self.config_kwargs.get('sources_command'))
    def adjust_config_kwargs(self):
        koji_fallback = {
            'hub_url': self.config_kwargs.get('koji_hub'),
            'root_url': self.config_kwargs.get('koji_root')
        }
        koji_map = get_koji(self.workflow, koji_fallback)
        self.config_kwargs['koji_hub'] = koji_map['hub_url']
        self.config_kwargs['koji_root'] = koji_map['root_url']

        odcs_fallback = {
            'api_url': self.config_kwargs.get('odcs_url'),
            'insecure': self.config_kwargs.get('odcs_insecure')
        }
        odcs_map = get_odcs(self.workflow, odcs_fallback)
        self.config_kwargs['odcs_url'] = odcs_map['api_url']
        self.config_kwargs['odcs_insecure'] = odcs_map.get('insecure', False)

        pulp_fallback = {'name': self.config_kwargs.get('pulp_registry_name')}
        pulp_map = get_pulp(self.workflow, pulp_fallback)
        self.config_kwargs['pulp_registry_name'] = pulp_map['name']

        smtp_fallback = {
            'host': self.config_kwargs.get('smtp_host'),
            'from_address': self.config_kwargs.get('smtp_from'),
            'domain': self.config_kwargs.get('smtp_email_domain'),
            'send_to_submitter': self.config_kwargs.get('smtp_to_submitter'),
            'send_to_pkg_owner': self.config_kwargs.get('smtp_to_pkgowner')
        }
        additional_addresses = self.config_kwargs.get('smtp_error_addresses')
        error_addresses = self.config_kwargs.get('smtp_additional_addresses')

        smtp_fallback['additional_addresses'] =\
            additional_addresses.split(',') if additional_addresses else ()
        smtp_fallback['error_addresses'] = error_addresses.split(',') if error_addresses else ()

        smtp_map = get_smtp(self.workflow, smtp_fallback)
        self.config_kwargs['smtp_additional_addresses'] =\
            ','.join(smtp_map.get('additional_addresses', ()))
        self.config_kwargs['smtp_email_domain'] = smtp_map.get('domain')
        self.config_kwargs['smtp_error_addresses'] = ','.join(smtp_map.get('error_addresses', ()))
        self.config_kwargs['smtp_from'] = smtp_map['from_address']
        self.config_kwargs['smtp_host'] = smtp_map['host']
        self.config_kwargs['smtp_to_pkgowner'] = smtp_map.get('send_to_pkg_owner', False)
        self.config_kwargs['smtp_to_submitter'] = smtp_map.get('send_to_submitter', False)

        source_reg = self.config_kwargs.get('source_registry_uri')
        souce_registry = get_source_registry(self.workflow, {
            'uri': RegistryURI(source_reg) if source_reg else None})['uri']
        self.config_kwargs['source_registry_uri'] = souce_registry.uri if souce_registry else None

        artifacts = self.config_kwargs.get('artifacts_allowed_domains')
        self.config_kwargs['artifacts_allowed_domains'] =\
            ','.join(get_artifacts_allowed_domains(
                self.workflow, artifacts.split(',') if artifacts else ()))

        equal_labels_fallback = []
        equal_labels_str = self.config_kwargs.get('equal_labels')

        if equal_labels_str:
            label_groups = [x.strip() for x in equal_labels_str.split(',')]

            for label_group in label_groups:
                equal_labels_fallback.append([label.strip() for label in label_group.split(':')])

        equal_labels = get_image_equal_labels(self.workflow, equal_labels_fallback)
        if equal_labels:
            equal_labels_sets = []
            for equal_set in equal_labels:
                equal_labels_sets.append(':'.join(equal_set))
            equal_labels_string = ','.join(equal_labels_sets)
            self.config_kwargs['equal_labels'] = equal_labels_string

        self.config_kwargs['prefer_schema1_digest'] =\
            get_prefer_schema1_digest(self.workflow,
                                      self.config_kwargs.get('prefer_schema1_digest'))

        registry_api_ver = self.config_kwargs.get('registry_api_versions')
        self.config_kwargs['registry_api_versions'] =\
            ','.join(get_content_versions(self.workflow,
                                          registry_api_ver.split(',') if registry_api_ver else ()))

        self.config_kwargs['yum_proxy'] =\
            get_yum_proxy(self.workflow, self.config_kwargs.get('yum_proxy'))

        self.config_kwargs['sources_command'] =\
            get_sources_command(self.workflow, self.config_kwargs.get('sources_command'))