Project

General

Profile

« Previous | Next » 

Revision f8d94608

Added by Amos Benari over 11 years ago

  • ID f8d946082e58b60213a27ded3e1e5f5373d976de

fixes #832 - adds parameterized class support

Credits:
This patch is based on the original work of Olivier Favre
<> many many thanks!

This patch adds the following features
  • import class parameters, and try to understand their types
  • support a complex matrix of environments, puppet classes and their
    signature - each class can have a different set of parameters per environment.
  • adds an ignore yaml file 'config/ignored_environments.yml.sample' file were
    users can add regexp or class names that the importer should ignore.
    common usage case for this is classes such as ::config, ::install etc.
  • introduce a new type of smart variable - parameterized.
  • adds complex data types to smart vars, arrays, hashes, json, yaml etc are all supported now.

in order to use the new ENC format for puppet 2.6.5+ you should enable the
Parametrized_Classes_in_ENC and Enable_Smart_Variables_in_ENC within Foreman Settings

This is the initial patch just to get param classes support in, follow-up patches
would include a better UI and the relevant UI updates to host edit page etc.

Signed-off-by: Ohad Levy <>

View differences:

public/javascripts/lookup_keys.js
function add_child_node(item) {
// Setup
var assoc = $(item).attr('data-association'); // Name of child
var content = $('#' + assoc + '_fields_template').html(); // Fields template
var template_class = '.' + assoc + '_fields_template';
var content = $(item).parent().find(template_class).html(); // Fields template
if (content == undefined) {content = $(template_class).html()};
// Make the context correct by replacing new_<parents> with the generated ID
// of each of the parent objects
......
content = content.replace(regexp, "new_" + new_id);
var field = '';
if (assoc == 'lookup_keys') {
$('.smart-var-tabs .active, .smart-var-content .active').removeClass('active');
$('#smart_vars .smart-var-tabs .active, #smart_vars .smart-var-content .active').removeClass('active');
var pill = "<li class='active'><a onclick='show_delete_button(this);' data-toggle='pill' href='#new_" + new_id + "' id='pill_new_" + new_id + "'>new<span onclick='remove_node(this);' class='label label-important fr'>&times;</span></a></li>"
$('.smart-var-tabs').prepend(pill);
field = $('.smart-var-content').prepend($(content).addClass('active'));
$('.smart-var-tabs li.active a').show('highlight', 500);
$('#smart_vars .smart-var-tabs').prepend(pill);
field = $('#smart_vars .smart-var-content').prepend($(content).addClass('active'));
$('#smart_vars .smart-var-tabs li.active a').show('highlight', 500);
} else {
field = $(content).insertBefore($(item));
}
......
return false;
}
function toggleMandatory(item){
var mandatory = $(item).is(':checked');
var override = $(item).closest('.fields').find("[id$='_override']");
override.attr('disabled', mandatory ? 'disabled' : null );
}
function toggleOverrideValue(item) {
var override = $(item).is(':checked');
var mandatory = $(item).closest('.fields').find("[id$='_required']");
var type_field = $(item).closest('.fields').find("[id$='_key_type']");
var validator_type_field = $(item).closest('.fields').find("[id$='_validator_type']");
var default_value_field = $(item).closest('.fields').find("[id$='_default_value']");
var override_value_div = $(item).closest('.fields').find("[id$='lookup_key_override_value']");
mandatory.attr('disabled', override ? null : 'disabled');
type_field.attr('disabled', override ? null : 'disabled');
validator_type_field.attr('disabled', override ? null : 'disabled');
default_value_field.attr('disabled', override ? null : 'disabled' );
override_value_div.toggle(override);
}
function filterByEnvironment(item){
if ($(item).val()=="") {
$('ul.smart-var-tabs li[data-used-environments] a').removeClass('grey');
return;
}
var selected = $(item).find('option:selected').text();
$('ul.smart-var-tabs li[data-used-environments] a').addClass('grey');
$('ul.smart-var-tabs li[data-used-environments*="'+selected+'"] a').removeClass('grey');
}

Also available in: Unified diff