Merge pull request #3413 from ryanpetrello/bye-bye-v1

remove /api/v1 and deprecated credential fields

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-06-10 17:31:28 +00:00
committed by GitHub
50 changed files with 349 additions and 2281 deletions

View File

@@ -36,11 +36,6 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
$scope.$on(`${list.iterator}_options`, function(event, data){
$scope.options = data.data.actions.GET;
optionsRequestDataProcessing();
});
$scope.$watchCollection(`${$scope.list.name}`, function() {
optionsRequestDataProcessing();
});
function assignCredentialKinds () {
@@ -69,26 +64,6 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
});
}
// iterate over the list and add fields like type label, after the
// OPTIONS request returns, or the list is sorted/paginated/searched
function optionsRequestDataProcessing(){
if ($scope[list.name] !== undefined) {
$scope[list.name].forEach(function(item, item_idx) {
var itm = $scope[list.name][item_idx];
// Set the item type label
if (list.fields.kind && $scope.options &&
$scope.options.hasOwnProperty('kind')) {
$scope.options.kind.choices.forEach(function(choice) {
if (choice[0] === item.kind) {
itm.kind_label = choice[1];
}
});
}
});
}
}
$scope.copyCredential = credential => {
Wait('start');
new Credential('get', credential.id)

View File

@@ -28,7 +28,7 @@ function adhocController($q, $scope, $stateParams,
return {
adhocUrl: GetBasePath('inventory') + id + '/ad_hoc_commands/',
inventoryUrl: GetBasePath('inventory') + id + '/',
machineCredentialUrl: GetBasePath('credentials') + '?kind=ssh'
machineCredentialUrl: GetBasePath('credentials') + '?credential_type__namespace=ssh'
};
};

View File

@@ -133,25 +133,36 @@ export default ['$state', 'ConfigData', '$scope', 'SourcesFormDefinition', 'Pars
});
$scope.lookupCredential = function(){
if($scope.source.value !== "scm" && $scope.source.value !== "custom") {
let kind = ($scope.source.value === "ec2") ? "aws" : $scope.source.value;
$state.go('.credential', {
credential_search: {
kind: kind,
page_size: '5',
page: '1'
}
});
// For most source type selections, we filter for 1-1 matches to credential_type namespace.
let searchKey = 'credential_type__namespace';
let searchValue = $scope.source.value;
// SCM and custom source types are more generic in terms of the credentials they
// accept - any cloud or user-defined credential type can be used. We filter for
// these using the credential_type kind field, which categorizes all cloud and
// user-defined credentials as 'cloud'.
if ($scope.source.value === 'scm') {
searchKey = 'credential_type__kind';
searchValue = 'cloud';
}
else {
$state.go('.credential', {
credential_search: {
credential_type__kind: "cloud",
page_size: '5',
page: '1'
}
});
if ($scope.source.value === 'custom') {
searchKey = 'credential_type__kind';
searchValue = 'cloud';
}
// When the selection is 'ec2' we actually want to filter for the 'aws' namespace.
if ($scope.source.value === 'ec2') {
searchValue = 'aws';
}
$state.go('.credential', {
credential_search: {
[searchKey]: searchValue,
page_size: '5',
page: '1'
}
});
};
$scope.lookupProject = function(){
@@ -169,7 +180,7 @@ export default ['$state', 'ConfigData', '$scope', 'SourcesFormDefinition', 'Pars
$scope.credentialBasePath = GetBasePath('credentials') + '?credential_type__kind__in=cloud,network';
}
else{
$scope.credentialBasePath = (source === 'ec2') ? GetBasePath('credentials') + '?kind=aws' : GetBasePath('credentials') + (source === '' ? '' : '?kind=' + (source));
$scope.credentialBasePath = (source === 'ec2') ? GetBasePath('credentials') + '?credential_type__namespace=aws' : GetBasePath('credentials') + (source === '' ? '' : '?credential_type__namespace=' + (source));
}
if (source === 'ec2' || source === 'custom' || source === 'vmware' || source === 'openstack' || source === 'scm' || source === 'cloudforms' || source === "satellite6" || source === "azure_rm") {
$scope.envParseType = 'yaml';

View File

@@ -302,25 +302,36 @@ export default ['$state', '$scope', 'ParseVariableString', 'ParseTypeChange',
};
$scope.lookupCredential = function(){
if($scope.source.value !== "scm" && $scope.source.value !== "custom") {
let kind = ($scope.source.value === "ec2") ? "aws" : $scope.source.value;
$state.go('.credential', {
credential_search: {
kind: kind,
page_size: '5',
page: '1'
}
});
// For most source type selections, we filter for 1-1 matches to credential_type namespace.
let searchKey = 'credential_type__namespace';
let searchValue = $scope.source.value;
// SCM and custom source types are more generic in terms of the credentials they
// accept - any cloud or user-defined credential type can be used. We filter for
// these using the credential_type kind field, which categorizes all cloud and
// user-defined credentials as 'cloud'.
if ($scope.source.value === 'scm') {
searchKey = 'credential_type__kind';
searchValue = 'cloud';
}
else {
$state.go('.credential', {
credential_search: {
credential_type__kind: "cloud",
page_size: '5',
page: '1'
}
});
if ($scope.source.value === 'custom') {
searchKey = 'credential_type__kind';
searchValue = 'cloud';
}
// When the selection is 'ec2' we actually want to filter for the 'aws' namespace.
if ($scope.source.value === 'ec2') {
searchValue = 'aws';
}
$state.go('.credential', {
credential_search: {
[searchKey]: searchValue,
page_size: '5',
page: '1'
}
});
};
$scope.formCancel = function() {
@@ -384,7 +395,7 @@ export default ['$state', '$scope', 'ParseVariableString', 'ParseTypeChange',
$scope.credentialBasePath = GetBasePath('credentials') + '?credential_type__kind__in=cloud,network';
}
else{
$scope.credentialBasePath = (source === 'ec2') ? GetBasePath('credentials') + '?kind=aws' : GetBasePath('credentials') + (source === '' ? '' : '?kind=' + (source));
$scope.credentialBasePath = (source === 'ec2') ? GetBasePath('credentials') + '?credential_type__namespace=aws' : GetBasePath('credentials') + (source === '' ? '' : 'credential_type__namespace=' + (source));
}
if (source === 'ec2' || source === 'custom' || source === 'vmware' || source === 'openstack' || source === 'scm' || source === 'cloudforms' || source === "satellite6") {
$scope.envParseType = 'yaml';

View File

@@ -39,7 +39,7 @@ export default {
Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$transition$',
(list, qs, $stateParams, GetBasePath, $transition$) => {
const toState = $transition$.to();
toState.params.credential_search.value.kind = _.get($stateParams, 'credential_search.kind', null);
toState.params.credential_search.value.credential_type__namespace = _.get($stateParams, 'credential_search.credential_type__namespace', null);
toState.params.credential_search.value.credential_type__kind = _.get($stateParams, 'credential_search.credential_type__kind', null);
return qs.search(GetBasePath('credentials'), $stateParams[`${list.iterator}_search`]);
}

View File

@@ -20,7 +20,7 @@
*
* ```
* /api/v2/inventories/9/
* /api/v2/credentials/?name=SSH Key&kind=ssh
* /api/v2/credentials/?name=SSH Key&credential_type__namespace=ssh
* ```
*
* When constructing the URL be sure to use the GetBasePath() method found in js/shared/Utilities.js. GetBasePath uses the response objects from /api and

View File

@@ -654,13 +654,13 @@ function(SettingsUtils, i18n, $rootScope) {
else {
switch(base) {
case 'credential':
query += '&kind=ssh&role_level=use_role';
query += '&credential_type__namespace=ssh&role_level=use_role';
break;
case 'scm_credential':
query += '&kind=scm&role_level=use_role';
query += '&redential_type__namespace=scm&role_level=use_role';
break;
case 'network_credential':
query += '&kind=net&role_level=use_role';
query += '&redential_type__namespace=net&role_level=use_role';
break;
case 'cloud_credential':
query += '&cloud=true&role_level=use_role';

View File

@@ -22,5 +22,5 @@ def version(request):
context.get('view'),
'deprecated',
False
) or request.path.startswith('/api/v1/')
)
}