Switch to os-service-types
Validation introduced by [1] duplicated code/logic that was subsequently (concurrently, really) released in the os-service-types library. Since then, changes in os-service-types [2] and service-types-authority [3] have caused breakages here in project-config. This change set obviates future issues with service-types-authority schema/format changes and supporting updates to os-service-types by removing the duplicated logic and just using os-service-types instead. Also, update senlin's api-ref publication location. Setting senlin to resource-cluster was premature and was not ever accepted by the senlin team. In service-types-authority we backed off that change [4] (keeping it in aliases in case anyone did pick it up) Switch senlin back to their actual service-type. [1] https://review.openstack.org/#/c/480719/ [2] https://review.openstack.org/#/c/493325/ [3] https://review.openstack.org/#/c/462140/ [4] https://review.openstack.org/#/c/494529/ Co-Authored-By: Eric Fried <efried@us.ibm.com> Change-Id: Idf8b1d091dc1b0ceec164f654c683ce882950700
This commit is contained in:
parent
79223bac38
commit
252673743a
@ -13698,7 +13698,7 @@
|
||||
- openstack-publish-jobs
|
||||
- openstack-releasenotes-jobs
|
||||
- api-ref-jobs:
|
||||
service: resource-cluster
|
||||
service: clustering
|
||||
|
||||
- project:
|
||||
name: senlin-dashboard
|
||||
|
@ -14,13 +14,13 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import io
|
||||
import glob
|
||||
import sys
|
||||
import requests
|
||||
import voluptuous as v
|
||||
|
||||
import os_service_types
|
||||
|
||||
# The files uses YAML extensions like !include, therefore use the
|
||||
# jenkins-job-builder yaml parser for loading.
|
||||
from jenkins_jobs import local_yaml
|
||||
@ -202,74 +202,6 @@ def _check_tox_builder(schema, entry):
|
||||
return count
|
||||
|
||||
|
||||
class ServiceTypeValidator(object):
|
||||
# NOTE(dhellmann): This class will move to os-service-types when
|
||||
# that repo is ready to start accepting code.
|
||||
|
||||
# The location of the service-types-authority data.
|
||||
_URL = 'https://service-types.openstack.org/service-types.json' # noqa
|
||||
|
||||
def __init__(self):
|
||||
# FIXME(dhellmann): Improve error handling and add caching.
|
||||
self._raw = requests.get(self._URL).json()
|
||||
# Store a mapping from the project name to the service
|
||||
# data. Include api_reference_project names when present so
|
||||
# that validation code can look up either type of project.
|
||||
by_project = {}
|
||||
for s in self._raw['services']:
|
||||
for key in ['project', 'api_reference_project']:
|
||||
name = s.get(key)
|
||||
if name:
|
||||
by_project[self._canonical_project_name(name)] = s
|
||||
self._raw['by_project'] = by_project
|
||||
|
||||
def _canonical_project_name(self, name):
|
||||
"Convert repo name to project name."
|
||||
return name.rpartition('/')[-1]
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
"The URL from which the data was retrieved."
|
||||
return self._URL
|
||||
|
||||
@property
|
||||
def version(self):
|
||||
"The version of the data."
|
||||
return self._raw['version']
|
||||
|
||||
@property
|
||||
def forward(self):
|
||||
"Mapping service type names to their aliases."
|
||||
return copy.deepcopy(self._raw['forward'])
|
||||
|
||||
@property
|
||||
def reverse(self):
|
||||
"Mapping aliases to their service type names."
|
||||
return copy.deepcopy(self._raw['reverse'])
|
||||
|
||||
@property
|
||||
def services(self):
|
||||
return copy.deepcopy(self._raw['services'])
|
||||
|
||||
def get_data_for_project(self, name):
|
||||
"""Return the data value associated with the project.
|
||||
|
||||
:param name: A repository or project name in the form
|
||||
``'openstack/project'`` or just ``'project'``.
|
||||
:type name: str
|
||||
:returns: dict
|
||||
:raises: ValueError
|
||||
|
||||
"""
|
||||
key = name.rpartition('/')[-1]
|
||||
try:
|
||||
return self._raw['by_project'][key]
|
||||
except KeyError:
|
||||
raise ValueError(
|
||||
'No service_type was found for {}'.format(key),
|
||||
)
|
||||
|
||||
|
||||
# The jobs for which the service type needs to be checked
|
||||
_API_JOBS = ['install-guide-jobs', 'api-guide-jobs', 'api-ref-jobs']
|
||||
|
||||
@ -279,7 +211,7 @@ def validate_service_types():
|
||||
print("========================")
|
||||
count = 0
|
||||
# Load the current service-type-authority data
|
||||
service_types = ServiceTypeValidator()
|
||||
service_types = os_service_types.ServiceTypes()
|
||||
# Load the project job definitions
|
||||
with io.open('jenkins/jobs/projects.yaml', 'r', encoding='utf-8') as f:
|
||||
file_contents = local_yaml.load(f.read())
|
||||
@ -289,17 +221,16 @@ def validate_service_types():
|
||||
for api_job in _API_JOBS:
|
||||
if api_job not in job:
|
||||
continue
|
||||
try:
|
||||
proj_data = service_types.get_data_for_project(
|
||||
project['name'])
|
||||
except ValueError:
|
||||
print('ERROR: Found service type reference "{}" for {} in {} '
|
||||
'but not in authority list {}'.format(
|
||||
proj_data = service_types.get_service_data_for_project(
|
||||
project['name'])
|
||||
if not proj_data:
|
||||
print('ERROR: Found service type reference "{}" for {} in '
|
||||
'{} but not in authority list {}'.format(
|
||||
job[api_job]['service'],
|
||||
api_job,
|
||||
project['name'],
|
||||
service_types.url))
|
||||
count +=1
|
||||
count += 1
|
||||
else:
|
||||
actual = job[api_job]['service']
|
||||
expected = proj_data['service_type']
|
||||
|
Loading…
x
Reference in New Issue
Block a user