Merge pull request #2200 from ryanpetrello/custom_venv_allow_bundled

allow the bundled `ansible` virtualenv to be selected on JT/Project
This commit is contained in:
Ryan Petrello 2018-06-18 15:50:16 -04:00 committed by GitHub
commit b4c30576af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 12 deletions

View File

@ -173,11 +173,15 @@ def test_extract_ansible_vars():
def test_get_custom_venv_choices():
assert common.get_custom_venv_choices() == []
bundled_venv = os.path.join(settings.BASE_VENV_PATH, 'ansible', '')
assert common.get_custom_venv_choices() == [bundled_venv]
with TemporaryDirectory(dir=settings.BASE_VENV_PATH) as temp_dir:
with TemporaryDirectory(dir=settings.BASE_VENV_PATH, prefix='tmp') as temp_dir:
os.makedirs(os.path.join(temp_dir, 'bin', 'activate'))
assert common.get_custom_venv_choices() == [os.path.join(temp_dir, '')]
assert sorted(common.get_custom_venv_choices()) == [
bundled_venv,
os.path.join(temp_dir, '')
]
def test_region_sorting():

View File

@ -928,7 +928,7 @@ def get_custom_venv_choices():
return [
os.path.join(custom_venv_path, x.decode('utf-8'), '')
for x in os.listdir(custom_venv_path)
if x not in ('awx', 'ansible') and
if x != 'awx' and
os.path.isdir(os.path.join(custom_venv_path, x)) and
os.path.exists(os.path.join(custom_venv_path, x, 'bin', 'activate'))
]

View File

@ -26,7 +26,10 @@ export default ['$scope', '$rootScope', '$location', '$stateParams',
function init(){
// @issue What is this doing, why
$scope.$emit("HideOrgListHeader");
$scope.custom_virtualenvs_options = ConfigData.custom_virtualenvs;
$scope.custom_virtualenvs_visible = ConfigData.custom_virtualenvs.length > 1;
$scope.custom_virtualenvs_options = ConfigData.custom_virtualenvs.filter(
v => !/\/ansible\/$/.test(v)
);
CreateSelect2({
element: '#organization_custom_virtualenv',
multiple: false,

View File

@ -34,7 +34,10 @@ export default ['$scope', '$location', '$stateParams', 'OrgAdminLookup',
$scope.$emit("HideOrgListHeader");
$scope.instance_groups = InstanceGroupsData;
$scope.custom_virtualenvs_options = ConfigData.custom_virtualenvs;
$scope.custom_virtualenvs_visible = ConfigData.custom_virtualenvs.length > 1;
$scope.custom_virtualenvs_options = ConfigData.custom_virtualenvs.filter(
v => !/\/ansible\/$/.test(v)
);
}

View File

@ -45,7 +45,7 @@ export default ['NotificationsList', 'i18n',
},
custom_virtualenv: {
label: i18n._('Ansible Environment'),
defaultText: i18n._('Default Environment'),
defaultText: i18n._('Use Default Environment'),
type: 'select',
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this organization to run on.") + "</p>",
@ -53,7 +53,7 @@ export default ['NotificationsList', 'i18n',
dataContainer: 'body',
dataPlacement: 'right',
ngDisabled: '!(organization_obj.summary_fields.user_capabilities.edit || canAdd)',
ngShow: 'custom_virtualenvs_options.length > 0'
ngShow: 'custom_virtualenvs_visible'
}
},

View File

@ -206,14 +206,14 @@ export default ['i18n', 'NotificationsList', 'TemplateList',
custom_virtualenv: {
label: i18n._('Ansible Environment'),
type: 'select',
defaultText: i18n._('Default Environment'),
defaultText: i18n._('Use Default Environment'),
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this project to run on.") + "</p>",
dataTitle: i18n._('Ansible Environment'),
dataContainer: 'body',
dataPlacement: 'right',
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
ngShow: 'custom_virtualenvs_options.length > 0'
ngShow: 'custom_virtualenvs_options.length > 1'
},
},

View File

@ -234,14 +234,15 @@ function(NotificationsList, i18n) {
custom_virtualenv: {
label: i18n._('Ansible Environment'),
type: 'select',
defaultText: i18n._('Default Environment'),
defaultText: i18n._('Use Default Environment'),
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this job template to run on.") + "</p>",
dataTitle: i18n._('Ansible Environment'),
dataContainer: 'body',
dataPlacement: 'right',
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAdd)',
ngShow: 'custom_virtualenvs_options.length > 0'
ngShow: 'custom_virtualenvs_options.length > 1'
},
instance_groups: {
label: i18n._('Instance Groups'),