Class: Bosh::Gen::Generators::JobTemplateGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_template_to_specObject



31
32
33
34
35
36
# File 'lib/bosh/gen/generators/job_template_generator.rb', line 31

def add_template_to_spec
  current_spec = YAML.load_file(job_dir("spec"))
  current_spec["templates"] ||= {}
  current_spec["templates"][template_name] = file_path
  create_file job_dir("spec"), YAML.dump(current_spec), :force => true
end

#check_file_pathObject

Raises:

  • (Thor::Error)


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

def check_file_path
  raise Thor::Error.new("'#{file_path}' must be a relative path, such as 'config/httpd.conf'") if file_path[0] == "/"
end

#check_jobObject

Raises:

  • (Thor::Error)


18
19
20
21
# File 'lib/bosh/gen/generators/job_template_generator.rb', line 18

def check_job
  raise Thor::Error.new("'#{job_name}' job does not yet exist; either create or fix spelling") unless File.exist?(job_dir(""))
  raise Thor::Error.new("'jobs/#{job_name}/spec' is missing") unless File.exist?(job_dir("spec"))
end

#check_root_is_releaseObject



12
13
14
15
16
# File 'lib/bosh/gen/generators/job_template_generator.rb', line 12

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

#touch_template_erbObject



27
28
29
# File 'lib/bosh/gen/generators/job_template_generator.rb', line 27

def touch_template_erb
  create_file job_template_dir(template_name)
end