Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #10507: Generic method to edit separate parameters in key="values" line #558

Conversation

ncharles
Copy link
Member

@ncharles ncharles force-pushed the ust_10507/generic_method_to_edit_separate_parameters_in_key_values_line branch from 7add62d to ef3d543 Compare March 28, 2017 15:04
@@ -672,3 +672,38 @@ body edit_defaults ncf_empty_select(select)
max_file_size => "25M";
edit_backup => "timestamp";
}


# Add parameter in key->values line, where -> is key_value_separator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be replaced by edit_line ncf_add_parameter_in_list_with_enclosing_chars with empty separators?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, because the ${match.3} and ${match.4} will be empty, and it will fail :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

# @parameter_constraint leading_char_separator "allow_empty_string" : true
# @parameter_constraint closing_char_separator "allow_empty_string" : true
#
# @class_prefix file_ensure_key_value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file_edit_line_key_value_ensure_parameter_in_list

#
# #### Example
#
# If you have an initial file (/etc/default/grub) containing
Copy link
Member

@amousset amousset Mar 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`/etc/default/grub`

# GRUB_CMDLINE_XEN="dom0_mem=16G"
# ```
#
# To add parameter dom0_max_vcpus=32 in the right hand side of the line, you'll need the following policy
Copy link
Member

@amousset amousset Mar 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`dom0_max_vcpus=32`

@ncharles
Copy link
Member Author

Commit modified

@ncharles ncharles force-pushed the ust_10507/generic_method_to_edit_separate_parameters_in_key_values_line branch from ef3d543 to 76e8c40 Compare March 29, 2017 09:40
# @documentation Edit the file, and ensure it contains the defined parameter in the list of values on the right hand side of a key->values line.
# If the parameter is not there, it will be added at the end, separated by parameter_separator.
# Optionnaly, you can define leading and closing character to enclose the parameters
# If the lhs does not exist in the file, it will report an error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems surprising to me, I would expect this method to add the line, because we have everything we need to do it.

@ncharles
Copy link
Member Author

Commit modified

@ncharles ncharles force-pushed the ust_10507/generic_method_to_edit_separate_parameters_in_key_values_line branch from 76e8c40 to 8d5c2cb Compare March 29, 2017 13:21
# @documentation Edit the file, and ensure it contains the defined parameter in the list of values on the right hand side of a key->values line.
# If the parameter is not there, it will be added at the end, separated by parameter_separator.
# Optionnaly, you can define leading and closing character to enclose the parameters
# If the lhs does not exist in the file, it will be added in the file, along with the parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify the meaning of "lhs"?

@ncharles
Copy link
Member Author

Commit modified

@ncharles ncharles force-pushed the ust_10507/generic_method_to_edit_separate_parameters_in_key_values_line branch from 8d5c2cb to 873d065 Compare March 29, 2017 13:40
#
#####################################################################################

# @name File edit line key value ensure parameter in list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File ensure key value parameter in list

@ncharles
Copy link
Member Author

Commit modified

@ncharles ncharles force-pushed the ust_10507/generic_method_to_edit_separate_parameters_in_key_values_line branch from 873d065 to 2796ba9 Compare March 29, 2017 14:29
@Normation-Quality-Assistant
Copy link
Contributor

This PR is not mergeable to upper versions.
Since it is "Ready for merge" you must merge it by yourself using the following command:
rudder-dev merge https://github.com/Normation/ncf/pull/558
-- Your faithful QA

@ncharles
Copy link
Member Author

OK, merging this PR

@ncharles ncharles merged commit 2796ba9 into Normation:v0.x Mar 29, 2017
@ncharles
Copy link
Member Author

OK, merging this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants