Merge pull request #2110 from coreos-inc/org-delete-bug

Fix bugs due to conflicting operation names in the API
This commit is contained in:
josephschorr 2016-11-14 11:59:23 -05:00 committed by GitHub
commit cd3907b281
5 changed files with 16 additions and 8 deletions

View file

@ -65,6 +65,7 @@ def swagger_route_data(include_internal=False, compact=False):
models = {} models = {}
tags = [] tags = []
tags_added = set() tags_added = set()
operationIds = set()
for rule in app.url_map.iter_rules(): for rule in app.url_map.iter_rules():
endpoint_method = app.view_functions[rule.endpoint] endpoint_method = app.view_functions[rule.endpoint]
@ -125,13 +126,20 @@ def swagger_route_data(include_internal=False, compact=False):
logger.debug('Unable to find method for %s in class %s', method_name, view_class) logger.debug('Unable to find method for %s in class %s', method_name, view_class)
continue continue
operationId = method_metadata(method, 'nickname')
operation_swagger = { operation_swagger = {
'operationId': method_metadata(method, 'nickname'), 'operationId': operationId,
'parameters': [], 'parameters': [],
} }
if operation_swagger['operationId'] is None:
if operationId is None:
continue continue
if operationId in operationIds:
raise Exception('Duplicate operation Id: %s' % operationId)
operationIds.add(operationId)
if not compact: if not compact:
operation_swagger.update({ operation_swagger.update({
'description': method.__doc__.strip() if method.__doc__ else '', 'description': method.__doc__.strip() if method.__doc__ else '',

View file

@ -204,7 +204,7 @@ class Organization(ApiResource):
@require_scope(scopes.ORG_ADMIN) @require_scope(scopes.ORG_ADMIN)
@require_fresh_login @require_fresh_login
@nickname('deleteOrganization') @nickname('deleteAdminedOrganization')
def delete(self, orgname): def delete(self, orgname):
""" Deletes the specified organization. """ """ Deletes the specified organization. """
permission = AdministerOrganizationPermission(orgname) permission = AdministerOrganizationPermission(orgname)

View file

@ -361,7 +361,7 @@ class InviteTeamMember(ApiResource):
@path_param('teamname', 'The name of the team') @path_param('teamname', 'The name of the team')
class TeamPermissions(ApiResource): class TeamPermissions(ApiResource):
""" Resource for listing the permissions an org's team has in the system. """ """ Resource for listing the permissions an org's team has in the system. """
@nickname('getTeamPermissions') @nickname('getOrganizationTeamPermissions')
def get(self, orgname, teamname): def get(self, orgname, teamname):
""" Returns the list of repository permissions for the org's team. """ """ Returns the list of repository permissions for the org's team. """
permission = AdministerOrganizationPermission(orgname) permission = AdministerOrganizationPermission(orgname)

View file

@ -80,7 +80,7 @@ angular.module('quay').factory('RolesService', ['UtilService', 'Restangular', 'A
'teamname': entityName 'teamname': entityName
}; };
ApiService.getTeamPermissions(null, params).then(function(resp) { ApiService.getOrganizationTeamPermissions(null, params).then(function(resp) {
callback(resp.permissions); callback(resp.permissions);
}, errorHandler); }, errorHandler);
} else if (entityKind == 'robot') { } else if (entityKind == 'robot') {

View file

@ -181,6 +181,7 @@ function(ApiService, CookieService, $rootScope, Config, $location) {
return; return;
} }
var errorDisplay = ApiService.errorDisplay('Could not delete namespace', callback);
var deleteNamespaceItself = function() { var deleteNamespaceItself = function() {
info.progress = 1; info.progress = 1;
info.progressMessage = 'Deleting namespace...'; info.progressMessage = 'Deleting namespace...';
@ -194,10 +195,10 @@ function(ApiService, CookieService, $rootScope, Config, $location) {
}, errorDisplay); }, errorDisplay);
} else { } else {
var delParams = { var delParams = {
'name': info.organization.name 'orgname': info.organization.name
}; };
ApiService.deleteOrganization(null, delParams).then(function(resp) { ApiService.deleteAdminedOrganization(null, delParams).then(function(resp) {
// Reload the user. // Reload the user.
userService.load(); userService.load();
callback(true); callback(true);
@ -235,7 +236,6 @@ function(ApiService, CookieService, $rootScope, Config, $location) {
'public': false 'public': false
}; };
var errorDisplay = ApiService.errorDisplay('Could not delete namespace', callback);
ApiService.listRepos(null, params).then(function(resp) { ApiService.listRepos(null, params).then(function(resp) {
repositories = resp['repositories']; repositories = resp['repositories'];
deleteAllRepos(); deleteAllRepos();