Class: Bosh::Deployer::JobTemplate
- Inherits:
-
Object
- Object
- Bosh::Deployer::JobTemplate
- Defined in:
- lib/bosh/deployer/job_template.rb
Defined Under Namespace
Classes: FetchError
Instance Attribute Summary collapse
-
#blobstore_id ⇒ Object
readonly
Returns the value of attribute blobstore_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sha1 ⇒ Object
readonly
Returns the value of attribute sha1.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #download_blob ⇒ Object
-
#initialize(template_spec, blobstore) ⇒ JobTemplate
constructor
A new instance of JobTemplate.
Constructor Details
#initialize(template_spec, blobstore) ⇒ JobTemplate
12 13 14 15 16 17 18 |
# File 'lib/bosh/deployer/job_template.rb', line 12 def initialize(template_spec, blobstore) @name = template_spec.fetch('name') @version = template_spec.fetch('version') @sha1 = template_spec.fetch('sha1') @blobstore_id = template_spec.fetch('blobstore_id') @blobstore = blobstore end |
Instance Attribute Details
#blobstore_id ⇒ Object (readonly)
Returns the value of attribute blobstore_id.
10 11 12 |
# File 'lib/bosh/deployer/job_template.rb', line 10 def blobstore_id @blobstore_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/bosh/deployer/job_template.rb', line 10 def name @name end |
#sha1 ⇒ Object (readonly)
Returns the value of attribute sha1.
10 11 12 |
# File 'lib/bosh/deployer/job_template.rb', line 10 def sha1 @sha1 end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/bosh/deployer/job_template.rb', line 10 def version @version end |
Instance Method Details
#download_blob ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bosh/deployer/job_template.rb', line 20 def download_blob uuid = SecureRandom.uuid path = File.join(Dir.tmpdir, "template-#{uuid}") File.open(path, 'w') do |f| blobstore.get(blobstore_id, f) end path rescue Bosh::Blobstore::BlobstoreError => e if e..include?('Could not fetch object') raise FetchError.new else raise e end end |