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

(PDK-668) Templatedir now reads .sync.yml for config when rendering t… #354

Merged
merged 1 commit into from
Nov 20, 2017

Conversation

HelenCampbell
Copy link
Contributor

…emplates.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 92.627% when pulling 2cd9a3a on HelenCampbell:usesyncyaml into 5945270 on puppetlabs:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 92.627% when pulling 97e1005 on HelenCampbell:usesyncyaml into 5945270 on puppetlabs:master.

@HelenCampbell HelenCampbell changed the title (PDK-668) Templatedir now reads .sync.yml for config when rendering t… (WIP)(PDK-668) Templatedir now reads .sync.yml for config when rendering t… Nov 16, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 92.564% when pulling 9305903 on HelenCampbell:usesyncyaml into 63aaa34 on puppetlabs:master.

Copy link
Contributor

@bmjen bmjen left a comment

Choose a reason for hiding this comment

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

Looks pretty good! Just some minor nits.

@config = {}
end
if @config.nil?
confdefaults = read_config(config_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiny nitpick here, but just for consistency sake, confdefaults and syncconfig should be underscore separated like the other variables are.

file_config = @config.fetch(:global, {})
file_config['module_metadata'] = @module_metadata
file_config.merge!(@config.fetch(dest_path, {})) unless dest_path.nil?
file_config.merge!(@config)
file_config
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is no longer needed since the last line is no longer conditional.

YAML.load(config_defaults) # rubocop:disable Security/YAMLLoad
end

before(:each) do
Copy link
Contributor

Choose a reason for hiding this comment

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

The config_defaults related allows should be moved up to the top level before block for maintenance purposes since they are required to be mocked with or without a sync.yml file.

@@ -236,26 +232,44 @@ def self.files_in_template(dirs)
#
# @api private
def config_for(dest_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be cool if the path to sync.yml could be passed in as an optional parameter here, and if it is nil, then the code below can default the path to the <dest_path>/sync.yml. This will allow us to potentially add support for externally provided sync.yml config in the future.

@@ -236,26 +232,44 @@ def self.files_in_template(dirs)
#
# @api private
def config_for(dest_path)
if @config.nil?
config_path = File.join(@path, 'config_defaults.yml')
sync_config_path = File.join(@path, '/.sync.yml')
Copy link
Contributor

Choose a reason for hiding this comment

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

The / isn't necessary on a File.join. It will actually cause problems on Windows.

@HelenCampbell HelenCampbell changed the title (WIP)(PDK-668) Templatedir now reads .sync.yml for config when rendering t… (PDK-668) Templatedir now reads .sync.yml for config when rendering t… Nov 17, 2017
@HelenCampbell
Copy link
Contributor Author

@bmjen Updated with your changes!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 92.561% when pulling 13f2414 on HelenCampbell:usesyncyaml into 63aaa34 on puppetlabs:master.

@bmjen bmjen merged commit 232862b into puppetlabs:master Nov 20, 2017
@bmjen bmjen added the feature label Dec 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants