Merge pull request #1014 from jberry-suse/source_check-remote-whitelist
check_source: utilize project config to allow for remote entries.
This commit is contained in:
commit
00c88d1641
24
ReviewBot.py
24
ReviewBot.py
@ -27,7 +27,9 @@ import cmdln
|
||||
from collections import namedtuple
|
||||
from collections import OrderedDict
|
||||
from osclib.comments import CommentAPI
|
||||
from osclib.conf import Config
|
||||
from osclib.memoize import memoize
|
||||
from osclib.stagingapi import StagingAPI
|
||||
import signal
|
||||
import datetime
|
||||
import yaml
|
||||
@ -37,7 +39,7 @@ try:
|
||||
except ImportError:
|
||||
import cElementTree as ET
|
||||
|
||||
import osc.conf
|
||||
from osc import conf
|
||||
import osc.core
|
||||
import urllib2
|
||||
|
||||
@ -97,6 +99,16 @@ class ReviewBot(object):
|
||||
else:
|
||||
self.config = self._load_config()
|
||||
|
||||
def staging_api(self, project):
|
||||
if project not in self.staging_apis:
|
||||
config = Config(project)
|
||||
self.staging_apis[project] = StagingAPI(self.apiurl, project)
|
||||
|
||||
config.apply_remote(self.staging_apis[project])
|
||||
self.staging_config[project] = conf.config[project].copy()
|
||||
|
||||
return self.staging_apis[project]
|
||||
|
||||
@property
|
||||
def review_mode(self):
|
||||
return self._review_mode
|
||||
@ -121,6 +133,8 @@ class ReviewBot(object):
|
||||
pass
|
||||
|
||||
def check_requests(self):
|
||||
self.staging_apis = {}
|
||||
self.staging_config = {}
|
||||
|
||||
# give implementations a chance to do something before single requests
|
||||
self.prepare_review()
|
||||
@ -491,10 +505,10 @@ class CommandLineInterface(cmdln.Cmdln):
|
||||
logging.basicConfig(level=level)
|
||||
self.logger = logging.getLogger(self.optparser.prog)
|
||||
|
||||
osc.conf.get_config(override_apiurl = self.options.apiurl)
|
||||
conf.get_config(override_apiurl = self.options.apiurl)
|
||||
|
||||
if (self.options.osc_debug):
|
||||
osc.conf.config['debug'] = 1
|
||||
conf.config['debug'] = 1
|
||||
|
||||
self.checker = self.setup_checker()
|
||||
if self.options.config:
|
||||
@ -511,14 +525,14 @@ class CommandLineInterface(cmdln.Cmdln):
|
||||
|
||||
def setup_checker(self):
|
||||
""" reimplement this """
|
||||
apiurl = osc.conf.config['apiurl']
|
||||
apiurl = conf.config['apiurl']
|
||||
if apiurl is None:
|
||||
raise osc.oscerr.ConfigError("missing apiurl")
|
||||
user = self.options.user
|
||||
group = self.options.group
|
||||
# if no args are given, use the current oscrc "owner"
|
||||
if user is None and group is None:
|
||||
user = osc.conf.get_apiurl_usr(apiurl)
|
||||
user = conf.get_apiurl_usr(apiurl)
|
||||
|
||||
return self.clazz(apiurl = apiurl, \
|
||||
dryrun = self.options.dry, \
|
||||
|
@ -25,8 +25,6 @@ class CheckSource(ReviewBot.ReviewBot):
|
||||
self.only_one_action = True
|
||||
|
||||
self.ignore_devel = False
|
||||
self.devel_whitelist_file = os.path.join(CheckSource.SCRIPT_PATH, 'check_source.whitelist')
|
||||
self.devel_whitelist = None
|
||||
self.review_team = 'opensuse-review-team'
|
||||
self.repo_checker = 'factory-repo-checker'
|
||||
self.staging_group = 'factory-staging'
|
||||
@ -133,12 +131,13 @@ class CheckSource(ReviewBot.ReviewBot):
|
||||
return True
|
||||
|
||||
def is_devel_project(self, source_project, target_project):
|
||||
# Load devel whitelist file if provided and check against before query.
|
||||
if self.devel_whitelist_file and self.devel_whitelist is None:
|
||||
self.devel_whitelist = open(self.devel_whitelist_file).read().splitlines()
|
||||
if self.devel_whitelist is not None and source_project in self.devel_whitelist:
|
||||
# Load project config and allow for remote entries.
|
||||
self.staging_api(target_project)
|
||||
devel_whitelist = self.staging_config[target_project].get('devel-whitelist', '').split()
|
||||
if source_project in devel_whitelist:
|
||||
return True
|
||||
|
||||
# Allow any projects already used as devel projects for other packages.
|
||||
search = {
|
||||
'package': "@project='%s' and devel/@project='%s'" % (target_project, source_project),
|
||||
}
|
||||
@ -245,7 +244,6 @@ class CommandLineInterface(ReviewBot.CommandLineInterface):
|
||||
parser = ReviewBot.CommandLineInterface.get_optparser(self)
|
||||
|
||||
parser.add_option('--ignore-devel', dest='ignore_devel', action='store_true', default=False, help='ignore devel projects for target package')
|
||||
parser.add_option('--devel-whitelist', dest='devel_whitelist_file', metavar='FILE', help='file containing whitelisted projects (one per line)')
|
||||
parser.add_option('--review-team', dest='review_team', metavar='GROUP', help='review team group added to requests with > 8 diff')
|
||||
parser.add_option('--repo-checker', dest='repo_checker', metavar='USER', help='repo checker user added after accepted review')
|
||||
parser.add_option('--staging-group', metavar='GROUP', help='group used by staging process')
|
||||
@ -258,8 +256,6 @@ class CommandLineInterface(ReviewBot.CommandLineInterface):
|
||||
|
||||
if self.options.ignore_devel:
|
||||
bot.ignore_devel = self.options.ignore_devel
|
||||
if self.options.devel_whitelist_file:
|
||||
bot.devel_whitelist_file = self.options.devel_whitelist_file
|
||||
if self.options.review_team:
|
||||
bot.review_team = self.options.review_team
|
||||
if self.options.repo_checker:
|
||||
|
@ -1,13 +0,0 @@
|
||||
devel:languages:D
|
||||
hardware:sdr
|
||||
isv:ownCloud:desktop
|
||||
network:cluster:ohpc
|
||||
network:mail:zarafa
|
||||
Novell:NTS
|
||||
network:messaging:matrix
|
||||
security:tls
|
||||
server:messaging
|
||||
server:php:extensions:php7
|
||||
system:snappy
|
||||
X11:Solus
|
||||
devel:openQA:tested
|
@ -8,6 +8,7 @@ import re
|
||||
import shutil
|
||||
import sys
|
||||
import urlparse
|
||||
import urllib
|
||||
from StringIO import StringIO
|
||||
from osc import conf
|
||||
from osc.core import urlopen
|
||||
@ -108,6 +109,7 @@ class Cache(object):
|
||||
|
||||
@staticmethod
|
||||
def get(url):
|
||||
url = urllib.unquote(url)
|
||||
match, project = Cache.match(url)
|
||||
if match:
|
||||
path = Cache.path(url, project, include_file=True)
|
||||
@ -161,6 +163,7 @@ class Cache(object):
|
||||
|
||||
@staticmethod
|
||||
def put(url, data):
|
||||
url = urllib.unquote(url)
|
||||
match, project = Cache.match(url)
|
||||
if match:
|
||||
path = Cache.path(url, project, include_file=True, makedirs=True)
|
||||
@ -181,6 +184,7 @@ class Cache(object):
|
||||
|
||||
@staticmethod
|
||||
def delete(url):
|
||||
url = urllib.unquote(url)
|
||||
match, project = Cache.match(url)
|
||||
if match:
|
||||
path = Cache.path(url, project, include_file=True)
|
||||
|
@ -7,15 +7,12 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from osc import conf
|
||||
from osclib.conf import Config
|
||||
from osclib.core import binary_list
|
||||
from osclib.core import depends_on
|
||||
from osclib.core import request_staged
|
||||
from osclib.core import target_archs
|
||||
from osclib.cycle import CycleDetector
|
||||
from osclib.memoize import CACHEDIR
|
||||
from osclib.stagingapi import StagingAPI
|
||||
|
||||
import ReviewBot
|
||||
|
||||
@ -34,20 +31,8 @@ class RepoChecker(ReviewBot.ReviewBot):
|
||||
# RepoChecker options.
|
||||
self.skip_cycle = False
|
||||
|
||||
def staging_api(self, project):
|
||||
if project not in self.staging_apis:
|
||||
config = Config(project)
|
||||
self.staging_apis[project] = StagingAPI(self.apiurl, project)
|
||||
|
||||
config.apply_remote(self.staging_apis[project])
|
||||
self.staging_config[project] = conf.config[project].copy()
|
||||
|
||||
return self.staging_apis[project]
|
||||
|
||||
def prepare_review(self):
|
||||
# Reset for request batch.
|
||||
self.staging_apis = {}
|
||||
self.staging_config = {}
|
||||
self.requests_map = {}
|
||||
self.groups = {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user