Update the guidelines location, try #2
[1] wasn't fully complete change/preparation for guidelines move which lead to some issues and we had to revert [2]. We revisited [2] and proposed the change again with a few improvements [3]. This patch should change everything we need in refstack in order to merge [3]. [1] https://review.opendev.org/c/osf/refstack/+/790940 [2] https://review.opendev.org/c/osf/interop/+/786116 [3] https://review.opendev.org/c/osf/interop/+/796413 Change-Id: Ib9f083d1f1a713b3fa26c5daca781fedfa4923fc
This commit is contained in:
parent
6ecd3a925c
commit
2a0a147dfa
@ -82,14 +82,14 @@ API_OPTS = [
|
|||||||
),
|
),
|
||||||
cfg.StrOpt('opendev_api_capabilities_url',
|
cfg.StrOpt('opendev_api_capabilities_url',
|
||||||
default='https://opendev.org/api/v1/repos/osf/interop/contents/'
|
default='https://opendev.org/api/v1/repos/osf/interop/contents/'
|
||||||
'previous_guidelines',
|
'guidelines',
|
||||||
help='The GitHub API URL of the repository and location of the '
|
help='The GitHub API URL of the repository and location of the '
|
||||||
'Interop Working Group capability files. This URL is used '
|
'Interop Working Group capability files. This URL is used '
|
||||||
'to get a listing of all capability files.'
|
'to get a listing of all capability files.'
|
||||||
),
|
),
|
||||||
cfg.StrOpt('additional_capability_urls',
|
cfg.StrOpt('additional_capability_urls',
|
||||||
default='https://opendev.org/api/v1/repos/osf/interop/contents/'
|
default='https://opendev.org/api/v1/repos/osf/interop/contents/'
|
||||||
'add-ons/previous_guidelines',
|
'add-ons/guidelines',
|
||||||
help=('The GitHub API URL of the repository and location of '
|
help=('The GitHub API URL of the repository and location of '
|
||||||
'any additional guideline sources which will need to '
|
'any additional guideline sources which will need to '
|
||||||
'be parsed by the refstack API.')),
|
'be parsed by the refstack API.')),
|
||||||
|
@ -16,13 +16,15 @@
|
|||||||
"""Class for retrieving Interop WG guideline information."""
|
"""Class for retrieving Interop WG guideline information."""
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
from oslo_config import cfg
|
|
||||||
from oslo_log import log
|
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
import requests_cache
|
import requests_cache
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@ -77,19 +79,6 @@ class Guidelines:
|
|||||||
for src_url in self.guideline_sources:
|
for src_url in self.guideline_sources:
|
||||||
try:
|
try:
|
||||||
resp = requests.get(src_url)
|
resp = requests.get(src_url)
|
||||||
# The following if-statement enables a transition period for
|
|
||||||
# moving the guidelines to a new location by
|
|
||||||
# https://review.opendev.org/c/osf/interop/+/786116
|
|
||||||
# TODO(kopecmartin) remove this if-statement after the review
|
|
||||||
# is merged.
|
|
||||||
if resp.status_code == 404:
|
|
||||||
if src_url == CONF.api.additional_capability_urls:
|
|
||||||
src_url = 'https://opendev.org/api/v1/repos/osf/'
|
|
||||||
src_url += 'interop/contents/add-ons'
|
|
||||||
elif src_url == CONF.api.opendev_api_capabilities_url:
|
|
||||||
src_url = 'https://opendev.org/api/v1/repos/osf/'
|
|
||||||
src_url += 'interop/contents'
|
|
||||||
resp = requests.get(src_url)
|
|
||||||
|
|
||||||
LOG.debug("Response Status: %s / Used Requests Cache: %s" %
|
LOG.debug("Response Status: %s / Used Requests Cache: %s" %
|
||||||
(resp.status_code,
|
(resp.status_code,
|
||||||
@ -108,8 +97,9 @@ class Guidelines:
|
|||||||
elif 'add-ons' not in rfile['path'] and \
|
elif 'add-ons' not in rfile['path'] and \
|
||||||
rfile['name'] not in map(itemgetter('name'),
|
rfile['name'] not in map(itemgetter('name'),
|
||||||
powered_files):
|
powered_files):
|
||||||
|
basename = os.path.basename(rfile['path'])
|
||||||
file_dict = {'name': rfile['name'],
|
file_dict = {'name': rfile['name'],
|
||||||
'file': rfile['path']}
|
'file': basename}
|
||||||
powered_files.append(file_dict)
|
powered_files.append(file_dict)
|
||||||
else:
|
else:
|
||||||
LOG.warning('Guidelines repo URL (%s) returned '
|
LOG.warning('Guidelines repo URL (%s) returned '
|
||||||
@ -134,9 +124,9 @@ class Guidelines:
|
|||||||
gl_file = '.'.join((gl_file, 'json'))
|
gl_file = '.'.join((gl_file, 'json'))
|
||||||
regex = re.compile("[a-z]*\.([0-9]{4}\.[0-9]{2}|next)\.json")
|
regex = re.compile("[a-z]*\.([0-9]{4}\.[0-9]{2}|next)\.json")
|
||||||
if regex.search(gl_file):
|
if regex.search(gl_file):
|
||||||
guideline_path = 'add-ons/' + gl_file
|
guideline_path = 'add-ons/guidelines/' + gl_file
|
||||||
else:
|
else:
|
||||||
guideline_path = gl_file
|
guideline_path = 'guidelines/' + gl_file
|
||||||
|
|
||||||
file_url = ''.join((self.raw_url.rstrip('/'),
|
file_url = ''.join((self.raw_url.rstrip('/'),
|
||||||
'/', guideline_path))
|
'/', guideline_path))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user