コード例 #1
0
    def load_authentication(raw_dict):
        services = set()
        deprecated_keys = [
            "github_app_id",
            "github_app_cert_path",
            "github_token",
            "pagure_user_token",
            "pagure_instance_url",
            "pagure_fork_token",
        ]
        if "authentication" in raw_dict:
            services = get_instances_from_dict(instances=raw_dict["authentication"])
        elif any(key in raw_dict for key in deprecated_keys):
            logger.warning(
                "Please, "
                "use 'authentication' key in the user configuration "
                "to set tokens for GitHub and Pagure. "
                "New method supports more services and direct keys will be removed in the future.\n"
                "Example:\n"
                "authentication:\n"
                "    github.com:\n"
                "        token: GITHUB_TOKEN\n"
                "    pagure:\n"
                "        token: PAGURE_TOKEN\n"
                '        instance_url: "https://src.fedoraproject.org"\n'
                "See our documentation for more information "
                "http://packit.dev/docs/configuration/#user-configuration-file. "
            )
            github_app_id = raw_dict.get("github_app_id")
            github_app_cert_path = raw_dict.get("github_app_cert_path")
            github_token = raw_dict.get("github_token")
            services.add(
                GithubService(
                    token=github_token,
                    github_app_id=github_app_id,
                    github_app_private_key_path=github_app_cert_path,
                )
            )
            pagure_user_token = raw_dict.get("pagure_user_token")
            pagure_instance_url = raw_dict.get(
                "pagure_instance_url", "https://src.fedoraproject.org"
            )
            if raw_dict.get("pagure_fork_token"):
                warnings.warn(
                    "packit no longer accepts 'pagure_fork_token'"
                    " value (https://github.com/packit-service/packit/issues/495)"
                )
            services.add(
                PagureService(token=pagure_user_token, instance_url=pagure_instance_url)
            )

        return services
コード例 #2
0
 def git_services(self):
     if self._git_services is None:
         self._git_services = get_instances_from_dict(
             self.conf.get_auth_configuration())
     return self._git_services