| |
@@ -24,7 +24,7 @@
|
| |
import requests
|
| |
import sys
|
| |
|
| |
- from libpagure import Pagure
|
| |
+ from ogr import PagureService
|
| |
|
| |
# Set local logging
|
| |
logger = logging.getLogger(__name__)
|
| |
@@ -32,8 +32,9 @@
|
| |
|
| |
|
| |
# Connect to pagure and set it to point to our repo
|
| |
- DEFAULT_PAGURE_DOMAIN = 'https://pagure.io/'
|
| |
- DEFAULT_PAGURE_REPO = 'releng/failed-composes'
|
| |
+ DEFAULT_PAGURE_DOMAIN = 'https://pagure.io/'
|
| |
+ DEFAULT_PAGURE_NAMESPACE = 'releng'
|
| |
+ DEFAULT_PAGURE_REPO = 'failed-composes'
|
| |
|
| |
# URL for linking to koji tasks by ID
|
| |
KOJI_TASK_URL='https://koji.fedoraproject.org/koji/taskinfo?taskID='
|
| |
@@ -60,19 +61,26 @@
|
| |
class Consumer(object):
|
| |
def __init__(self):
|
| |
self.token = os.getenv('PAGURE_TOKEN')
|
| |
- self.pagure_domain = os.getenv('PAGURE_DOMAIN', DEFAULT_PAGURE_DOMAIN)
|
| |
+ pagure_domain = os.getenv('PAGURE_DOMAIN', DEFAULT_PAGURE_DOMAIN)
|
| |
+ pagure_namespace = os.getenv('PAGURE_NAMESPACE', DEFAULT_PAGURE_NAMESPACE)
|
| |
+ pagure_repo = os.getenv('PAGURE_REPO', DEFAULT_PAGURE_REPO)
|
| |
+
|
| |
if self.token:
|
| |
logger.info("Using detected token to talk to pagure.")
|
| |
- self.pg = Pagure(instance_url=self.pagure_domain,
|
| |
- pagure_token=self.token)
|
| |
+ gitservice = PagureService(
|
| |
+ token=self.token,
|
| |
+ instance_url=pagure_domain)
|
| |
else:
|
| |
logger.info("No pagure token was detected.")
|
| |
logger.info("This script will run but won't be able to create new issues.")
|
| |
- self.pg = Pagure(instance_url=self.pagure_domain)
|
| |
+ gitservice = PagureService(instance_url=pagure_domain)
|
| |
|
| |
|
| |
- # Set the repo to create new issues against
|
| |
- self.pg.repo = os.getenv('PAGURE_REPO', DEFAULT_PAGURE_REPO)
|
| |
+ # Grab the project to create new issues against
|
| |
+ logger.info(f'Targeting repo {pagure_namespace}/{pagure_repo} on {pagure_domain}')
|
| |
+ self.gitproject = gitservice.get_project(
|
| |
+ repo=pagure_repo,
|
| |
+ namespace=pagure_namespace)
|
| |
|
| |
# Used for printing out a value when the day has changed
|
| |
self.date = datetime.date.today()
|
| |
@@ -186,13 +194,17 @@
|
| |
|
| |
logger.debug(content)
|
| |
|
| |
- # pull only part of the compose ID for the tag to set
|
| |
- tag = re.search('(.*)-\d{8}', msg['compose_id']).group(1)
|
| |
- #TODO figure out how to set tag on an issue
|
| |
- # Should be able to do this now https://pagure.io/libpagure/issue/31
|
| |
+ # pull only part of the compose ID for the label to set
|
| |
+ label = re.search('(.*)-\d{8}', msg['compose_id']).group(1)
|
| |
+ #TODO set labels on issues when functionality is in ogr
|
| |
+ # https://github.com/packit-service/ogr/issues/147
|
| |
|
| |
if self.token:
|
| |
- self.pg.create_issue(title=title, content=content)
|
| |
+ issue = self.gitproject.create_issue(title=title, body=content)
|
| |
+ url = issue.url.replace('/api/0/','') # have to pull the api/0 part out
|
| |
+ # https://github.com/packit-service/ogr/issues/146
|
| |
+ logger.info(f'Opened issue: {url}')
|
| |
+
|
| |
|
| |
# The code in this file is expected to be run through fedora messaging
|
| |
# However, you can run the script directly for testing purposes. The
|
| |
This will fix issue 20