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-715) Transition pdk to use pdk-templates as template repo #380

Merged
merged 1 commit into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/pdk/module/templatedir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TemplateDir
# the template available on disk.
#
# @example Using a git repository as a template
# PDK::Module::TemplateDir.new('https://github.com/puppetlabs/pdk-module-template') do |t|
# PDK::Module::TemplateDir.new('https://github.com/puppetlabs/pdk-templates') do |t|
# t.render do |filename, content|
# File.open(filename, 'w') do |file|
# file.write(content)
Expand All @@ -47,7 +47,7 @@ def initialize(path_or_url, module_metadata = {}, init = false)
# @todo When switching this over to using rugged, cache the cloned
# template repo in `%AppData%` or `$XDG_CACHE_DIR` and update before
# use.
temp_dir = PDK::Util.make_tmpdir_name('pdk-module-template')
temp_dir = PDK::Util.make_tmpdir_name('pdk-templates')
git_ref = PDK::Util.default_template_ref

clone_result = PDK::Util::Git.git('clone', path_or_url, temp_dir)
Expand Down
6 changes: 3 additions & 3 deletions lib/pdk/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ def default_template_url

def puppetlabs_template_url
if package_install?
'file://' + File.join(package_cachedir, 'pdk-module-template.git')
'file://' + File.join(package_cachedir, 'pdk-templates.git')
else
'https://github.com/puppetlabs/pdk-module-template'
'https://github.com/puppetlabs/pdk-templates'
end
end
module_function :puppetlabs_template_url
Expand All @@ -203,7 +203,7 @@ def puppetlabs_template_ref
if PDK::Util.package_install? || PDK::Util.gem_install?
PDK::TEMPLATE_REF
else
'origin/convert' # should be master
'origin/master'
end
end
module_function :puppetlabs_template_ref
Expand Down
2 changes: 1 addition & 1 deletion package-testing/tests/validate_a_new_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
step 'Create a module' do
on(workstation, pdk_command(workstation, "new module #{module_name} --skip-interview")) do
on(workstation, %(cat #{module_name}/metadata.json | egrep '"template-url":'), accept_all_exit_codes: true) do |template_result|
assert_match(%r{"file://.*pdk-module-template\.git",?$}, template_result.stdout.strip, "New module's metadata should refer to vendored pdk-module-template repo")
assert_match(%r{"file://.*pdk-templates\.git",?$}, template_result.stdout.strip, "New module's metadata should refer to vendored pdk-templates repo")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion pdk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'tty-which', '0.3.0'
spec.add_runtime_dependency 'diff-lcs', '1.3'

# Used in the pdk-module-template
# Used in the pdk-templates
spec.add_runtime_dependency 'deep_merge', '~> 1.1'
end
2 changes: 1 addition & 1 deletion spec/unit/pdk/generate/module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
end

it 'uses the vendored template url' do
expect(PDK::Module::TemplateDir).to receive(:new).with('file:///tmp/package/cache/pdk-module-template.git', anything, anything).and_yield(test_template_dir)
expect(PDK::Module::TemplateDir).to receive(:new).with('file:///tmp/package/cache/pdk-templates.git', anything, anything).and_yield(test_template_dir)
expect(PDK.answers).not_to receive(:update!).with(:'template-url' => anything)

described_class.invoke(invoke_opts)
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/pdk/module/template_dir_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
context 'with a valid template path' do
it 'returns config hash with module metadata' do
allow(File).to receive(:directory?).with(anything).and_return(true)
allow(PDK::Util).to receive(:make_tmpdir_name).with('pdk-module-template').and_return('/tmp/path')
allow(PDK::Util).to receive(:make_tmpdir_name).with('pdk-templates').and_return('/tmp/path')
allow(PDK::CLI::Exec).to receive(:git).with('clone', path_or_url, '/tmp/path').and_return(exit_code: 0)
allow(File).to receive(:file?).with(anything).and_return(File.join(path_or_url, 'config_defaults.yml')).and_return(true)
allow(File).to receive(:read).with(File.join(path_or_url, 'config_defaults.yml')).and_return(config_defaults)
Expand Down Expand Up @@ -120,7 +120,7 @@
describe '.render(template_files)' do
before(:each) do
allow(File).to receive(:directory?).with(anything).and_return(true)
allow(PDK::Util).to receive(:make_tmpdir_name).with('pdk-module-template').and_return('/tmp/path')
allow(PDK::Util).to receive(:make_tmpdir_name).with('pdk-templates').and_return('/tmp/path')
allow(PDK::CLI::Exec).to receive(:git).with('clone', path_or_url, '/tmp/path').and_return(exit_code: 0)
end

Expand Down Expand Up @@ -181,7 +181,7 @@
describe '.config_for(dest_path)' do
before(:each) do
allow(File).to receive(:directory?).with(anything).and_return(true)
allow(PDK::Util).to receive(:make_tmpdir_name).with('pdk-module-template').and_return('/tmp/path')
allow(PDK::Util).to receive(:make_tmpdir_name).with('pdk-templates').and_return('/tmp/path')
allow(PDK::CLI::Exec).to receive(:git).with('clone', path_or_url, '/tmp/path').and_return(exit_code: 0)
allow(File).to receive(:file?).with(anything).and_return(File.join(path_or_url, 'config_defaults.yml')).and_return(true)
allow(File).to receive(:read).with(File.join(path_or_url, 'config_defaults.yml')).and_return(config_defaults)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/pdk/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
end

it 'returns the built-in TEMPLATE_REF' do
is_expected.to eq('origin/convert')
is_expected.to eq('origin/master')
end
end
end
Expand Down