Browse Source

Update the guidelines location

This patch updates the guidelines location. The guidelines will be
moved there by [1]. In order to shorten the transition period we
are intentionally doing this *before* [1] is merged (before the
guidelines are actually moved) because it takes some time to get
this change to production. Due to that the patch also implement
a fail-safe mechanism - if the get request for guidelines returns
404, the code will try again with the old (at this moment the
current) location.
When this gets to production, we will merge [1]. Then the
fail-safe mechanism will no longer be needed, therefore it will be
removed in a follow up patch.

[1] https://review.opendev.org/c/osf/interop/+/786116

Change-Id: I5d81d0168601f2b6c3b5cae996b531ebdb33d9d0
changes/40/790940/1
Martin Kopec 1 month ago
parent
commit
81928c2e10
2 changed files with 17 additions and 3 deletions
  1. +4
    -3
      refstack/api/app.py
  2. +13
    -0
      refstack/api/guidelines.py

+ 4
- 3
refstack/api/app.py View File

@ -81,14 +81,15 @@ API_OPTS = [
help='Template for test result 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',
help='The GitHub API URL of the repository and location of the '
'Interop Working Group capability files. This URL is used '
'to get a listing of all capability files.'
),
cfg.StrOpt('additional_capability_urls',
default='https://opendev.org/api/v1/'
'repos/osf/interop/contents/add-ons',
default='https://opendev.org/api/v1/repos/osf/interop/contents/'
'add-ons/previous_guidelines',
help=('The GitHub API URL of the repository and location of '
'any additional guideline sources which will need to '
'be parsed by the refstack API.')),


+ 13
- 0
refstack/api/guidelines.py View File

@ -77,6 +77,19 @@ class Guidelines:
for src_url in self.guideline_sources:
try:
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" %
(resp.status_code,


Loading…
Cancel
Save