Class: Bosh::Director::Models::CompiledPackage
- Defined in:
- lib/bosh/director/models/compiled_package.rb
Class Method Summary collapse
-
.create_cache_key(package, transitive_dependencies, stemcell_sha1) ⇒ Object
Creates a ‘unique’ key to use in the global package cache.
- .generate_build_number(package_model, stemcell_os, stemcell_version) ⇒ Object
-
.split_stemcell_os_and_version(name) ⇒ Object
Marks job template model as being used by release version.
Instance Method Summary collapse
Class Method Details
.create_cache_key(package, transitive_dependencies, stemcell_sha1) ⇒ Object
Creates a ‘unique’ key to use in the global package cache
6 7 8 9 10 |
# File 'lib/bosh/director/models/compiled_package.rb', line 6 def self.create_cache_key(package, transitive_dependencies, stemcell_sha1) dependency_fingerprints = transitive_dependencies.to_a.sort_by(&:name).map {|p| p.fingerprint } hash_input = ([package.fingerprint, stemcell_sha1]+dependency_fingerprints).join('') Digest::SHA1.hexdigest(hash_input) end |
.generate_build_number(package_model, stemcell_os, stemcell_version) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/bosh/director/models/compiled_package.rb', line 45 def self.generate_build_number(package_model, stemcell_os, stemcell_version) attrs = { :package_id => package_model.id, :stemcell_os => stemcell_os, :stemcell_version => stemcell_version, } filter(attrs).max(:build).to_i + 1 end |
.split_stemcell_os_and_version(name) ⇒ Object
Marks job template model as being used by release version
15 16 17 18 19 20 21 22 23 |
# File 'lib/bosh/director/models/compiled_package.rb', line 15 def self.split_stemcell_os_and_version(name) values = name.split('/', 2) unless 2 == values.length raise "Expected value to be in the format of \"{os_name}/{stemcell_version}\", but given \"#{name}\"" end return { os: values[0], version: values[1] } end |
Instance Method Details
#before_save ⇒ Object
31 32 33 34 35 |
# File 'lib/bosh/director/models/compiled_package.rb', line 31 def before_save self.dependency_key_sha1 = Digest::SHA1.hexdigest(self.dependency_key) super end |
#name ⇒ Object
37 38 39 |
# File 'lib/bosh/director/models/compiled_package.rb', line 37 def name package.name end |
#validate ⇒ Object
25 26 27 28 29 |
# File 'lib/bosh/director/models/compiled_package.rb', line 25 def validate validates_presence [:package_id, :stemcell_os, :stemcell_version, :sha1, :blobstore_id, :dependency_key] validates_unique [:package_id, :stemcell_os, :stemcell_version, :dependency_key] validates_unique [:package_id, :stemcell_os, :stemcell_version, :build] end |
#version ⇒ Object
41 42 43 |
# File 'lib/bosh/director/models/compiled_package.rb', line 41 def version package.version end |