update inventory source credential lookup queries for api v2

This commit is contained in:
Jake McDermott 2019-06-06 10:16:44 -04:00 committed by Ryan Petrello
parent 6da445f7c0
commit 2f57a1ea93
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777
3 changed files with 59 additions and 37 deletions

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`]);
}