Class: Bosh::Gen::Generators::ExtractPackageGenerator

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

Instance Method Summary collapse

Instance Method Details

#check_package_path_is_a_packageObject



25
26
27
28
29
30
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 25

def check_package_path_is_a_package
  parent_dir = File.basename(File.dirname(source_package_path))
  unless parent_dir == "packages"
    raise Thor::Error.new("source package path is not a BOSH package")
  end
end

#check_package_path_within_releaseObject



17
18
19
20
21
22
23
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 17

def check_package_path_within_release
  FileUtils.chdir(source_release_path) do
    unless File.exist?("jobs") && File.exist?("packages")
      raise Thor::Error.new("source package path is not within a BOSH release project")
    end
  end
end

#check_root_is_releaseObject



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

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

#copy_dependent_packagesObject



43
44
45
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 43

def copy_dependent_packages
  @packages.each {|package| directory "packages/#{package}"}
end

#copy_package_spec_filesObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 47

def copy_package_spec_files
  @blobs = false
  @packages.each do |package|
    spec = source_file("packages", package, "spec")
    files = YAML.load_file(spec)["files"]
    
    files.each do |relative_file|
      if File.exist?(source_file("src", relative_file))
        copy_file "src/#{relative_file}"
      elsif File.exist?(source_file("blobs", relative_file))
        copy_file "blobs/#{relative_file}"
        @blobs = true
      end
    end
  end
end

#detect_dependent_packagesObject

Extract target package and all its dependencies



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

def detect_dependent_packages
  spec = YAML.load_file(source_package_dir("spec"))
  @packages = [source_package_name]
  @packages << spec["packages"] if spec["packages"]
end

#readmeObject



64
65
66
67
68
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 64

def readme
  if @blobs
    say_status "readme", "Upload blobs with 'bosh upload blobs'"
  end
end

#using_source_release_for_templatesObject



32
33
34
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 32

def using_source_release_for_templates
  source_paths << File.join(source_release_path)
end