Class: Sambot::Chef::Cookbook

Inherits:
Object
  • Object
show all
Defined in:
lib/sambot/chef/cookbook.rb

Constant Summary collapse

GENERATED_FILES =
{
  'teamcity.sh.erb': { eruby: true, dest: 'teamcity.sh', platform: %i[windows centos] },
  'chefignore': { eruby: false, dest: 'chefignore', platform: %i[windows centos] },
  'docker-compose.yml': { eruby: false, dest: 'docker-compose.yml', platform: %i[windows centos] },
  '.env': { eruby: false, dest: '.env', platform: %i[windows centos] },
  'Berksfile': { eruby: false, dest: 'Berksfile', platform: %i[windows centos] },
  '.rubocop.yml': { eruby: false, dest: '.rubocop.yml', platform: %i[windows centos] },
  '.gitignore.sample': { eruby: false, dest: '.gitignore', platform: %i[windows centos] },
  'Vagrantfile.erb': { eruby: false, dest: 'Vagrantfile.erb', platform: %i[windows centos] },
  'winrm_config': { eruby: false, dest: 'winrm_config', platform: %i[windows] }
}.freeze

Class Method Summary collapse

Class Method Details

.build(config, cloud, local_workflow) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/sambot/chef/cookbook.rb', line 23

def build(config, cloud, local_workflow)
  Generator.from_templates(config, cloud, local_workflow, GENERATED_FILES)
  Kitchen.setup(cloud, config, local_workflow)
  Metadata.generate(config)
  Hooks.copy
  UI.info('The cookbook has been successfully built.')
end

.bumpObject



31
32
33
34
# File 'lib/sambot/chef/cookbook.rb', line 31

def bump
  new_version = Config.bump_version
  UI.info("You have bumped the version of this cookbook to #{new_version}.")
end

.cleanObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/sambot/chef/cookbook.rb', line 36

def clean
  UI.info('Removing all generated files from this cookbook.')
  targets = GENERATED_FILES.map { |_, val| val[:dest] } - ['.gitignore']
  targets.each { |file| Sambot::FS.delete(file) }
  Sambot::FS.delete('bootstrap.sh')
  Sambot::FS.delete('bootstrap.ps1')
  Metadata.clean
  Kitchen.clean
  UI.info('The cookbook has been successfully cleaned.')
end

.create(config) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/sambot/chef/cookbook.rb', line 47

def create(config)
  require 'git'
  Git.init(config.name)
  Dir.chdir(config.name) do
    create_files(config)
  end
  #TeamCity.create_build_configuration(config)
  #SourceControl.create_repository(config)
  UI.info('The cookbook has been successfully created.')
end