Class: PuppetMagnum::CreateGenerator
- Inherits:
-
BaseGenerator
- Object
- Thor::Group
- BaseGenerator
- PuppetMagnum::CreateGenerator
- Defined in:
- lib/puppet-magnum/generators/create_generator.rb
Instance Method Summary collapse
- #write_base_files ⇒ Object
- #write_dirs ⇒ Object
-
#write_git_setup ⇒ Object
due to the ‘git add’ operation, this function should be called last.
- #write_puppet_files ⇒ Object
-
#write_remove_legacy_files_dirs ⇒ Object
first, remove ANY unused legacy files and directories.
- #write_spec_setup ⇒ Object
- #write_util_files ⇒ Object
Methods inherited from BaseGenerator
Instance Method Details
#write_base_files ⇒ Object
58 59 60 61 62 |
# File 'lib/puppet-magnum/generators/create_generator.rb', line 58 def write_base_files template license_file, target.join('LICENSE') template 'base/README.md.erb', target.join('README.md') template 'base/CHANGELOG.md.erb', target.join('CHANGELOG.md') end |
#write_dirs ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet-magnum/generators/create_generator.rb', line 47 def write_dirs dirs = ['manifests', 'data', 'templates', 'files', 'spec', 'spec/fixtures', 'spec/fixtures/modules', 'spec/acceptance', 'spec/acceptance/nodesets', 'spec/acceptance/nodesets/docker', ] dirs.each do |dir| empty_directory target.join("#{dir}") end end |
#write_git_setup ⇒ Object
due to the ‘git add’ operation, this function should be called last.
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/puppet-magnum/generators/create_generator.rb', line 101 def write_git_setup remove_file target.join('.gitignore') template 'git/gitignore.erb', target.join('.gitignore') unless File.exists?(target.join('.git')) inside target do run 'git init', capture: true run 'git add -A', capture: true end end end |
#write_puppet_files ⇒ Object
74 75 76 77 78 79 |
# File 'lib/puppet-magnum/generators/create_generator.rb', line 74 def write_puppet_files template 'puppet/metadata.json.erb', target.join('metadata.json') template 'puppet/init.pp.erb', target.join('manifests/init.pp') template 'puppet/hiera.yaml.erb', target.join('hiera.yaml') template 'puppet/common.yaml.erb', target.join('data/common.yaml') end |
#write_remove_legacy_files_dirs ⇒ Object
first, remove ANY unused legacy files and directories. (migration function from ‘puppet-magnum` 3.x to 4.x)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/puppet-magnum/generators/create_generator.rb', line 25 def write_remove_legacy_files_dirs if File.exist?(target.join('.puppet-magnum.init')) legacy_files = ['.vagrant_puppet', 'Vagrantfile'] legacy_files.each do |legacy_file| if File.exist?(target.join("#{legacy_file}")) remove_file target.join("#{legacy_file}") end end legacy_dirs = ['spec', 'serverspec'] legacy_dirs.each do |legacy_dir| if File.exist?(target.join("#{legacy_dir}")) FileUtils.cp_r target.join("#{legacy_dir}"), target.join("#{legacy_dir}.old") remove_file target.join("#{legacy_dir}") end end remove_file target.join('.puppet-magnum.init') end end |
#write_spec_setup ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/puppet-magnum/generators/create_generator.rb', line 81 def write_spec_setup template 'spec/fixtures.yml.erb', target.join('.fixtures.yml') template 'spec/rspec.erb', target.join('.rspec') template 'spec/spec_helper_acceptance.rb.erb', target.join('spec/spec_helper_acceptance.rb') template 'spec/acceptance/init_spec.rb.erb', target.join("spec/acceptance/#{module_name}_spec.rb") beaker_sut_files = [ 'ubuntu-server-1404-x64.yml', 'ubuntu-server-1604-x64.yml', ] beaker_sut_files.each do |beaker_sut_file| # VirtualBox template "spec/acceptance/#{beaker_sut_file}.erb", target.join("spec/acceptance/nodesets/#{beaker_sut_file}") # Docker template "spec/acceptance/docker/#{beaker_sut_file}.erb", target.join("spec/acceptance/nodesets/docker/#{beaker_sut_file}") end end |
#write_util_files ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/puppet-magnum/generators/create_generator.rb', line 64 def write_util_files remove_file target.join('Gemfile') remove_file target.join('Rakefile') remove_file target.join('.puppet-magnum') template 'util/Gemfile.erb', target.join('Gemfile') template 'util/Rakefile.erb', target.join('Rakefile') template 'util/puppet-magnum.erb', target.join('.puppet-magnum') end |