Merge pull request #3359 from mabashian/yaml-comments

Show yaml comments when possible on launch prompt

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-03-07 15:14:19 +00:00 committed by GitHub
commit 92a600aaa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 19 deletions

View File

@ -25,14 +25,14 @@ function PromptService (Empty, $filter) {
hasDefaultExtraVars = _.get(params, 'launchConf.defaults.extra_vars');
if(hasCurrentExtraVars && hasDefaultExtraVars) {
extraVars = _.merge(jsyaml.safeLoad(params.launchConf.defaults.extra_vars), params.currentValues.extra_data);
extraVars = jsyaml.safeDump(_.merge(jsyaml.safeLoad(params.launchConf.defaults.extra_vars), params.currentValues.extra_data));
} else if(hasCurrentExtraVars) {
extraVars = params.currentValues.extra_data;
} else if(hasDefaultExtraVars) {
extraVars = jsyaml.safeLoad(params.launchConf.defaults.extra_vars);
extraVars = params.launchConf.defaults.extra_vars;
}
prompts.variables.value = extraVars && extraVars !== '' ? '---\n' + jsyaml.safeDump(extraVars) : '---\n';
prompts.variables.value = extraVars && extraVars !== '' ? extraVars : '---\n';
prompts.verbosity.choices = _.get(params, 'launchOptions.actions.POST.verbosity.choices', []).map(c => ({label: c[1], value: c[0]}));
prompts.verbosity.value = _.has(params, 'currentValues.verbosity') && params.currentValues.verbosity ? _.find(prompts.verbosity.choices, item => item.value === params.currentValues.verbosity) : _.find(prompts.verbosity.choices, item => item.value === params.launchConf.defaults.verbosity);
prompts.jobType.choices = _.get(params, 'launchOptions.actions.POST.job_type.choices', []).map(c => ({label: c[1], value: c[0]}));

View File

@ -11,11 +11,9 @@ export default
vm.strings = strings;
let scope;
let launch;
vm.init = (_scope_, _launch_) => {
vm.init = (_scope_) => {
scope = _scope_;
launch = _launch_;
scope.parseType = 'yaml';

View File

@ -11,7 +11,6 @@ export default
vm.strings = strings;
let scope;
let launch;
let consolidateTags = (tagModel, tagId) => {
let tags = angular.copy(tagModel);
@ -26,17 +25,14 @@ export default
return [...tags.reduce((map, tag) => map.has(tag.value) ? map : map.set(tag.value, tag), new Map()).values()];
};
vm.init = (_scope_, _launch_) => {
vm.init = (_scope_) => {
scope = _scope_;
launch = _launch_;
vm.showJobTags = true;
vm.showSkipTags = true;
scope.parseType = 'yaml';
scope.promptData.extraVars = ToJSON(scope.parseType, scope.promptData.prompts.variables.value, false);
const surveyPasswords = {};
if (scope.promptData.launchConf.ask_tags_on_launch) {
@ -48,6 +44,7 @@ export default
}
if (scope.promptData.launchConf.survey_enabled){
scope.promptData.extraVars = ToJSON(scope.parseType, scope.promptData.prompts.variables.value, false);
scope.promptData.surveyQuestions.forEach(surveyQuestion => {
if (!scope.promptData.extraVars) {
scope.promptData.extraVars = {};
@ -76,16 +73,18 @@ export default
surveyPasswords[surveyQuestion.variable] = '$encrypted$';
}
});
// We don't want to modify the extra vars when we merge them with the survey
// password $encrypted$ strings so we clone it
const extraVarsClone = _.cloneDeep(scope.promptData.extraVars);
// Replace the survey passwords with $encrypted$ to display to the user
const cleansedExtraVars = extraVarsClone ? Object.assign(extraVarsClone, surveyPasswords) : {};
scope.promptExtraVars = $.isEmptyObject(scope.promptData.extraVars) ? '---' : '---\n' + jsyaml.safeDump(cleansedExtraVars);
} else {
scope.promptData.extraVars = scope.promptData.prompts.variables.value;
scope.promptExtraVars = scope.promptData.prompts.variables.value && scope.promptData.prompts.variables.value !== '' ? scope.promptData.prompts.variables.value : '---\n';
}
// We don't want to modify the extra vars when we merge them with the survey
// password $encrypted$ strings so we clone it
const extraVarsClone = _.cloneDeep(scope.promptData.extraVars);
// Replace the survey passwords with $encrypted$ to display to the user
const cleansedExtraVars = extraVarsClone ? Object.assign(extraVarsClone, surveyPasswords) : {};
scope.promptExtraVars = $.isEmptyObject(scope.promptData.extraVars) ? '---' : '---\n' + jsyaml.safeDump(cleansedExtraVars);
ParseTypeChange({
scope: scope,
variable: 'promptExtraVars',