Implements https://trello.com/c/bEMQtVjz - API/UI changes to support su username/password. Adds force_handlers, skip_tasks and start_at_task options to jobs, only exposed via API.

This commit is contained in:
Chris Church
2014-09-11 17:34:31 -04:00
parent 87ed378f6b
commit e427234aec
12 changed files with 809 additions and 82 deletions

View File

@@ -136,7 +136,7 @@ CredentialsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeP
function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, CredentialForm, GenerateForm, Rest, Alert,
ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GenerateList, SearchInit, PaginateInit, LookUpInit, UserList, TeamList,
GetBasePath, GetChoices, Empty, KindChange, OwnerChange, FormSave) {
GetBasePath, GetChoices, Empty, KindChange, OwnerChange, LoginMethodChange, FormSave) {
ClearScope();
@@ -209,6 +209,17 @@ function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $routePar
OwnerChange({ scope: $scope });
}
if (!Empty($routeParams.su_username) || !Empty($routeParams.su_password)) {
$scope.login_method = 'su';
LoginMethodChange({ scope: $scope });
} else if (!Empty($routeParams.sudo_username) || !Empty($routeParams.sudo_password)) {
$scope.login_method = 'sudo';
LoginMethodChange({ scope: $scope });
} else {
$scope.login_method = '';
LoginMethodChange({ scope: $scope });
}
// Handle Kind change
$scope.kindChange = function () {
KindChange({ scope: $scope, form: form, reset: true });
@@ -228,6 +239,11 @@ function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $routePar
OwnerChange({ scope: $scope });
};
// Handle Login Method change
$scope.loginMethodChange = function () {
LoginMethodChange({ scope: $scope });
};
// Reset defaults
$scope.formReset = function () {
//DebugForm({ scope: $scope, form: CredentialForm });
@@ -266,13 +282,13 @@ function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $routePar
CredentialsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'CredentialForm', 'GenerateForm',
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList', 'SearchInit', 'PaginateInit',
'LookUpInit', 'UserList', 'TeamList', 'GetBasePath', 'GetChoices', 'Empty', 'KindChange', 'OwnerChange', 'FormSave'
'LookUpInit', 'UserList', 'TeamList', 'GetBasePath', 'GetChoices', 'Empty', 'KindChange', 'OwnerChange', 'LoginMethodChange', 'FormSave'
];
function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, CredentialForm, GenerateForm, Rest, Alert,
ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, Prompt, GetBasePath, GetChoices,
KindChange, UserList, TeamList, LookUpInit, Empty, OwnerChange, FormSave, Stream, Wait) {
KindChange, UserList, TeamList, LookUpInit, Empty, OwnerChange, LoginMethodChange, FormSave, Stream, Wait) {
ClearScope();
@@ -338,6 +354,7 @@ function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routePa
reset: false
});
OwnerChange({ scope: $scope });
LoginMethodChange({ scope: $scope });
Wait('stop');
});
@@ -377,6 +394,15 @@ function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routePa
}
master.owner = $scope.owner;
if (!Empty($scope.su_username) || !Empty($scope.su_password)) {
$scope.login_method = 'su';
} else if (!Empty($scope.sudo_username) || !Empty($scope.sudo_password)) {
$scope.login_method = 'sudo';
} else {
$scope.login_method = '';
}
master.login_method = $scope.login_method;
for (i = 0; i < $scope.credential_kind_options.length; i++) {
if ($scope.credential_kind_options[i].value === data.kind) {
$scope.kind = $scope.credential_kind_options[i];
@@ -445,6 +471,11 @@ function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routePa
OwnerChange({ scope: $scope });
};
// Handle Login Method change
$scope.loginMethodChange = function () {
LoginMethodChange({ scope: $scope });
};
// Handle Kind change
$scope.kindChange = function () {
KindChange({ scope: $scope, form: form, reset: true });
@@ -459,6 +490,7 @@ function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routePa
setAskCheckboxes();
KindChange({ scope: $scope, form: form, reset: false });
OwnerChange({ scope: $scope });
LoginMethodChange({ scope: $scope });
};
// Related set: Add button
@@ -538,5 +570,5 @@ function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routePa
CredentialsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'CredentialForm',
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'GetChoices', 'KindChange', 'UserList', 'TeamList', 'LookUpInit',
'Empty', 'OwnerChange', 'FormSave', 'Stream', 'Wait'
'Empty', 'OwnerChange', 'LoginMethodChange', 'FormSave', 'Stream', 'Wait'
];

View File

@@ -309,10 +309,29 @@ angular.module('CredentialFormDefinition', [])
awPassMatch: true,
associated: 'ssh_key_unlock'
},
"login_method": {
label: "Login Method", // FIXME: Confirm this label is ok?
type: 'radio_group',
ngChange: "loginMethodChange()",
options: [{
label: 'None', // FIXME: Maybe 'Default' or 'SSH only' instead?
value: '',
selected: true
}, {
label: 'Sudo',
value: 'sudo'
}, {
label: 'Su',
value: 'su'
}],
awPopOver: "<p>A credential may optionally provide a sudo username and password or su username and password to use when running a playbook.</p>",
dataPlacement: 'right',
dataContainer: "body"
},
"sudo_username": {
label: 'Sudo Username',
type: 'text',
ngShow: "kind.value == 'ssh'",
ngShow: "kind.value == 'ssh' && login_method == 'sudo'",
addRequired: false,
editRequired: false,
autocomplete: false
@@ -320,7 +339,7 @@ angular.module('CredentialFormDefinition', [])
"sudo_password": {
label: 'Sudo Password',
type: 'password',
ngShow: "kind.value == 'ssh'",
ngShow: "kind.value == 'ssh' && login_method == 'sudo'",
addRequired: false,
editRequired: false,
ngChange: "clearPWConfirm('sudo_password_confirm')",
@@ -332,13 +351,43 @@ angular.module('CredentialFormDefinition', [])
"sudo_password_confirm": {
label: 'Confirm Sudo Password',
type: 'password',
ngShow: "kind.value == 'ssh'",
ngShow: "kind.value == 'ssh' && login_method == 'sudo'",
addRequired: false,
editRequired: false,
awPassMatch: true,
associated: 'sudo_password',
autocomplete: false
},
"su_username": {
label: 'Su Username',
type: 'text',
ngShow: "kind.value == 'ssh' && login_method == 'su'",
addRequired: false,
editRequired: false,
autocomplete: false
},
"su_password": {
label: 'Su Password',
type: 'password',
ngShow: "kind.value == 'ssh' && login_method == 'su'",
addRequired: false,
editRequired: false,
ngChange: "clearPWConfirm('su_password_confirm')",
ask: true,
clear: true,
associated: 'su_password_confirm',
autocomplete: false
},
"su_password_confirm": {
label: 'Confirm Su Password',
type: 'password',
ngShow: "kind.value == 'ssh' && login_method == 'su'",
addRequired: false,
editRequired: false,
awPassMatch: true,
associated: 'su_password',
autocomplete: false
},
"project": {
label: "Project",
type: 'text',

View File

@@ -102,6 +102,9 @@ angular.module('CredentialsHelper', ['Utilities'])
scope.sudo_username = null;
scope.sudo_password = null;
scope.sudo_password_confirm = null;
scope.su_username = null;
scope.su_password = null;
scope.su_password_confirm = null;
}
// Collapse or open help widget based on whether scm value is selected
@@ -143,6 +146,24 @@ angular.module('CredentialsHelper', ['Utilities'])
])
.factory('LoginMethodChange', [
function () {
return function (params) {
var scope = params.scope,
login_method = scope.login_method;
if (login_method !== 'sudo') {
scope.sudo_username = null;
scope.sudo_password = null;
}
if (login_method !== 'su') {
scope.su_username = null;
scope.su_password = null;
}
};
}
])
.factory('FormSave', ['$location', 'Alert', 'Rest', 'ProcessErrors', 'Empty', 'GetBasePath', 'CredentialForm', 'ReturnToCaller', 'Wait',
function ($location, Alert, Rest, ProcessErrors, Empty, GetBasePath, CredentialForm, ReturnToCaller, Wait) {
return function (params) {