def run(self) -> TaskResults: """ Discover information about organization/user which wants to install packit on his repository Try to allowlist automatically if mapping from github username to FAS account can prove that user is a packager. :return: TaskResults """ InstallationModel.create(event=self.installation_event) # try to add user to allowlist allowlist = Allowlist( fas_user=self.service_config.fas_user, fas_password=self.service_config.fas_password, ) if not allowlist.add_account(self.account_login, self.sender_login): # Create an issue in our repository, so we are notified when someone install the app self.project.create_issue( title= f"{self.account_type} {self.account_login} needs to be approved.", body= (f"Hi @{self.sender_login}, we need to approve you in " "order to start using Packit-as-a-Service. Someone from our team will " "get back to you shortly.\n\n" "For more info, please check out the documentation: " "http://packit.dev/packit-as-a-service/"), ) msg = f"{self.account_type} {self.account_login} needs to be approved manually!" else: msg = f"{self.account_type} {self.account_login} allowlisted!" logger.info(msg) return TaskResults(success=True, details={"msg": msg})
def multiple_installation_entries(installation_events): with get_sa_session() as session: session.query(InstallationModel).delete() yield [ InstallationModel.create(event=installation_events[0],), InstallationModel.create(event=installation_events[1],), ] clean_db()
def run(self) -> TaskResults: """ Discover information about organization/user which wants to install packit on his repository Try to allowlist automatically if mapping from github username to FAS account can prove that user is a packager. :return: TaskResults """ InstallationModel.create(event=self.installation_event) # try to add user to allowlist allowlist = Allowlist( fas_user=self.service_config.fas_user, fas_password=self.service_config.fas_password, ) if not allowlist.add_namespace(f"github.com/{self.account_login}", self.sender_login): # Create an issue in our repository, so we are notified when someone install the app self.project.create_issue( title= f"{self.account_type} {self.account_login} needs to be approved.", body= (f"Hi @{self.sender_login}, we need to approve you in " "order to start using Packit-as-a-Service. " "We are now onboarding Fedora contributors who have a valid " "[Fedora Account System](https://fedoraproject.org/wiki/Account_System) " "account and have signed " "[FPCA](https://fedoraproject.org/wiki/Legal" ":Fedora_Project_Contributor_Agreement). " "If you have such an account, please, provide it in a comment and " "we'd be glad to approve you for using the service.\n\n" "For more info, please check out the documentation: " "https://packit.dev/docs/packit-service"), ) msg = f"{self.account_type} {self.account_login} needs to be approved manually!" else: msg = f"{self.account_type} {self.account_login} allowlisted!" logger.info(msg) return TaskResults(success=True, details={"msg": msg})