Class: Bosh::Gen::Generators::MicroJobGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/bosh/gen/generators/micro_job_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



12
13
14
# File 'lib/bosh/gen/generators/micro_job_generator.rb', line 12

def self.source_root
  File.join(File.dirname(__FILE__), "micro_job_generator", "templates")
end

Instance Method Details

#check_root_is_releaseObject



16
17
18
19
20
# File 'lib/bosh/gen/generators/micro_job_generator.rb', line 16

def check_root_is_release
  unless File.exist?("jobs") && File.exist?("packages")
    raise Thor::Error.new("run inside a BOSH release project")
  end
end

#create_jobObject



22
23
24
25
# File 'lib/bosh/gen/generators/micro_job_generator.rb', line 22

def create_job
  directory "jobs/micro", "jobs/#{job_name}"
  chmod "jobs/#{job_name}/prepare", 0755
end

#gitignoreObject



37
38
39
40
41
42
43
# File 'lib/bosh/gen/generators/micro_job_generator.rb', line 37

def gitignore
  append_file ".gitignore", <<-IGNORE.gsub(/^\s{8}/, '')
  jobs/#{job_name}/monit
  jobs/#{job_name}/spec
  jobs/#{job_name}/templates/
  IGNORE
end

#prepare_spec_defaults_all_jobsObject



27
28
29
30
31
32
33
34
35
# File 'lib/bosh/gen/generators/micro_job_generator.rb', line 27

def prepare_spec_defaults_all_jobs
  jobs = if specific_jobs.size > 0
    specific_jobs
  else
    Dir[File.expand_path("jobs/*")].map {|job| File.basename(job) } - [job_name]
  end
  spec = { "jobs" => jobs }
  create_file "jobs/#{job_name}/prepare_spec", YAML.dump(spec)
end

#readmeObject



45
46
47
48
49
50
51
52
53
# File 'lib/bosh/gen/generators/micro_job_generator.rb', line 45

def readme
  say ""
  say "Edit "; say "jobs/#{job_name}/prepare_spec ", :yellow
    say "with ordered list of jobs to include"
  say "in micro job. The order of jobs implicitly specifies the order in"
  say "which they are started."
  say ""
  say ""
end