Class: Bosh::Cli::Command::Release::FinalizeRelease

Inherits:
Base
  • Object
show all
Includes:
DependencyHelper, ReleasePrintHelper
Defined in:
lib/cli/commands/release/finalize_release.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_DIRECTOR_PORT

Instance Attribute Summary

Attributes inherited from Base

#args, #exit_code, #info, #options, #out, #runner, #work_dir

Instance Method Summary collapse

Methods included from DependencyHelper

#tsort_packages

Methods inherited from Base

#add_option, #blob_manager, #blobstore, #cache_dir, #config, #confirmed?, #credentials, #deployment, #director, #initialize, #interactive?, #logged_in?, #non_interactive?, #progress_renderer, #redirect, #release, #remove_option, #run_nested_command, #show_current_state, #target, #target_name, #verbose?

Methods included from Bosh::Cli::CommandDiscovery

#desc, #method_added, #option, #register_command, #usage

Methods included from DeploymentHelper

#build_manifest, #cancel_deployment, #deployment_changed?, #inspect_deployment_changes, #job_exists_in_deployment?, #job_unique_in_deployment?, #jobs_and_indexes, #prepare_deployment_manifest, #prompt_for_errand_name, #prompt_for_job_and_index

Constructor Details

This class inherits a constructor from Bosh::Cli::Command::Base

Instance Method Details

#finalize(tarball_path) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/cli/commands/release/finalize_release.rb', line 15

def finalize(tarball_path)
  options[:final] = true

  # validate preconditions
  check_if_release_dir

  tarball = extract_and_validate_tarball(tarball_path)

  manifest = Psych.load(tarball.manifest)

  dev_release_name = manifest["name"]
  dev_release_ver = manifest["version"]
  final_release_name = options[:name] || dev_release_name

  final_release_dir = File.join('releases', final_release_name)
  @release_index = Bosh::Cli::Versions::VersionsIndex.new(final_release_dir)
  final_release_ver = options[:version] || next_final_version

  if options[:version] && @release_index.version_strings.include?(options[:version])
    raise Bosh::Cli::ReleaseVersionError.new('Release version already exists')
  end

  @progress_renderer = Bosh::Cli::InteractiveProgressRenderer.new

  if !options[:dry_run] then
    release.blobstore # prime & validate blobstore config

    manifest["version"] = final_release_ver
    manifest["name"] = final_release_name

    updated_manifest = upload_package_and_job_blobs(manifest, tarball)

    tarball.replace_manifest(updated_manifest)

    FileUtils.mkdir_p(final_release_dir)
    final_release_manifest_path = File.absolute_path(File.join(final_release_dir, "#{final_release_name}-#{final_release_ver}.yml"))
    File.open(final_release_manifest_path, 'w') do |release_manifest_file|
      release_manifest_file.puts(tarball.manifest)
    end

    @release_index.add_version(SecureRandom.uuid, "version" => final_release_ver)

    final_release_tarball_path = File.absolute_path(File.join(final_release_dir, "#{final_release_name}-#{final_release_ver}.tgz"))
    tarball.create_from_unpacked(final_release_tarball_path)

    nl
    say("Creating final release #{final_release_name}/#{final_release_ver} from dev release #{dev_release_name}/#{dev_release_ver}")

    release.latest_release_filename = final_release_manifest_path
    release.save_config

    header('Release summary')
    show_summary(tarball)
    nl

    say("Release name: #{final_release_name.make_green}")
    say("Release version: #{final_release_ver.to_s.make_green}")
    say("Release manifest: #{release.latest_release_filename.make_green}")
    say("Release tarball (#{pretty_size(final_release_tarball_path)}): " + final_release_tarball_path.make_green)
  end
end