Class: Bosh::Cli::Command::Release::CreateRelease

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

Constant Summary collapse

DEFAULT_RELEASE_NAME =
'bosh-release'

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

#create(manifest_file = nil) ⇒ Object



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
# File 'lib/cli/commands/release/create_release.rb', line 22

def create(manifest_file = nil)
  switch_to_release_dir
  check_if_release_dir

  migrate_to_support_multiple_releases

  if manifest_file && File.file?(manifest_file)
    if options[:version]
      err('Cannot specify a custom version number when creating from a manifest. The manifest already specifies a version.'.make_red)
    end

    if options[:'timestamp_version']
      err('Cannot specify timestamp-version when creating from a manifest. The manifest already specifies a version.'.make_red)
    end

    say('Recreating release from the manifest')
    Bosh::Cli::ReleaseCompiler.compile(manifest_file, cache_dir, release.blobstore, [], release.dir)
    release_filename = manifest_file
  else
    if options[:version] && options[:'timestamp_version']
      err('Cannot specify both timestamp-version and version when creating a release.')
    end

    version = nil
    if options[:version]
      version = options[:version]
      version = Bosh::Common::Version::ReleaseVersion.parse(version).to_s unless version.nil?
    end

    release_filename = create_from_spec(version)
  end

  if release_filename
    release.latest_release_filename = release_filename
    release.save_config
  end
rescue SemiSemantic::ParseError
  err("Invalid version: '#{version}'. Please specify a valid version (ex: 1.0.0 or 1.0-beta.2+dev.10).".make_red)
rescue Bosh::Cli::ReleaseVersionError => e
  err(e.message.make_red)
end