Class: Bosh::Cli::Command::BlobManagement

Inherits:
Base show all
Defined in:
lib/cli/commands/blob_management.rb

Constant Summary

Constants inherited from Base

Bosh::Cli::Command::Base::BLOBS_DIR, Bosh::Cli::Command::Base::BLOBS_INDEX_FILE

Instance Attribute Summary

Attributes inherited from Base

#cache, #config, #options, #out, #usage, #work_dir

Instance Method Summary collapse

Methods inherited from Base

#blob_manager, #blobstore, command, #confirmed?, #director, #dry_run?, #exit_code, #full_target_name, #initialize, #interactive?, #logged_in?, #non_interactive?, #redirect, #release, #run, #show_usage, #target_name, #target_version, #task_report, #verbose?

Constructor Details

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

Instance Method Details

#add(local_path, blob_dir = nil) ⇒ Object

Adds blob to managed blobs

Parameters:

  • local_path (String)

    Local file path

  • blob_dir (optional, String) (defaults to: nil)

    Directory to store blob in, relative to blobs dir



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cli/commands/blob_management.rb', line 15

def add(local_path, blob_dir = nil)
  blob_path = File.basename(local_path)
  if blob_dir
    # We don't need about blobs prefix,
    # but it might be handy for people who rely on auto-completion
    if blob_dir[0..5] == "blobs/"
      blob_dir = blob_dir[6..-1]
    end
    blob_path = File.join(blob_dir, blob_path)
  end
  blob_manager.add_blob(local_path, blob_path)
end

#statusObject

Prints out blobs status



7
8
9
# File 'lib/cli/commands/blob_management.rb', line 7

def status
  blob_manager.print_status
end

#syncObject

Syncs blobs with blobstore



41
42
43
44
# File 'lib/cli/commands/blob_management.rb', line 41

def sync
  blob_manager.sync
  blob_manager.print_status
end

#uploadObject

Uploads all blobs that need to be uploaded



29
30
31
32
33
34
35
36
37
38
# File 'lib/cli/commands/blob_management.rb', line 29

def upload
  blob_manager.print_status

  blob_manager.blobs_to_upload.each do |blob|
    nl
    if confirmed?("Upload blob #{blob.yellow}?")
      blob_manager.upload_blob(blob)
    end
  end
end