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:
@@ -13698,7 +13698,7 @@
|
|||||||
- openstack-publish-jobs
|
- openstack-publish-jobs
|
||||||
- openstack-releasenotes-jobs
|
- openstack-releasenotes-jobs
|
||||||
- api-ref-jobs:
|
- api-ref-jobs:
|
||||||
service: resource-cluster
|
service: clustering
|
||||||
|
|
||||||
- project:
|
- project:
|
||||||
name: senlin-dashboard
|
name: senlin-dashboard
|
||||||
|
|||||||
@@ -14,13 +14,13 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import copy
|
|
||||||
import io
|
import io
|
||||||
import glob
|
import glob
|
||||||
import sys
|
import sys
|
||||||
import requests
|
|
||||||
import voluptuous as v
|
import voluptuous as v
|
||||||
|
|
||||||
|
import os_service_types
|
||||||
|
|
||||||
# The files uses YAML extensions like !include, therefore use the
|
# The files uses YAML extensions like !include, therefore use the
|
||||||
# jenkins-job-builder yaml parser for loading.
|
# jenkins-job-builder yaml parser for loading.
|
||||||
from jenkins_jobs import local_yaml
|
from jenkins_jobs import local_yaml
|
||||||
@@ -202,74 +202,6 @@ def _check_tox_builder(schema, entry):
|
|||||||
return count
|
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
|
# The jobs for which the service type needs to be checked
|
||||||
_API_JOBS = ['install-guide-jobs', 'api-guide-jobs', 'api-ref-jobs']
|
_API_JOBS = ['install-guide-jobs', 'api-guide-jobs', 'api-ref-jobs']
|
||||||
|
|
||||||
@@ -279,7 +211,7 @@ def validate_service_types():
|
|||||||
print("========================")
|
print("========================")
|
||||||
count = 0
|
count = 0
|
||||||
# Load the current service-type-authority data
|
# Load the current service-type-authority data
|
||||||
service_types = ServiceTypeValidator()
|
service_types = os_service_types.ServiceTypes()
|
||||||
# Load the project job definitions
|
# Load the project job definitions
|
||||||
with io.open('jenkins/jobs/projects.yaml', 'r', encoding='utf-8') as f:
|
with io.open('jenkins/jobs/projects.yaml', 'r', encoding='utf-8') as f:
|
||||||
file_contents = local_yaml.load(f.read())
|
file_contents = local_yaml.load(f.read())
|
||||||
@@ -289,12 +221,11 @@ def validate_service_types():
|
|||||||
for api_job in _API_JOBS:
|
for api_job in _API_JOBS:
|
||||||
if api_job not in job:
|
if api_job not in job:
|
||||||
continue
|
continue
|
||||||
try:
|
proj_data = service_types.get_service_data_for_project(
|
||||||
proj_data = service_types.get_data_for_project(
|
|
||||||
project['name'])
|
project['name'])
|
||||||
except ValueError:
|
if not proj_data:
|
||||||
print('ERROR: Found service type reference "{}" for {} in {} '
|
print('ERROR: Found service type reference "{}" for {} in '
|
||||||
'but not in authority list {}'.format(
|
'{} but not in authority list {}'.format(
|
||||||
job[api_job]['service'],
|
job[api_job]['service'],
|
||||||
api_job,
|
api_job,
|
||||||
project['name'],
|
project['name'],
|
||||||
|
|||||||
Reference in New Issue
Block a user