class Bosh::Cli::BuildArtifact
Attributes
dependencies[R]
fingerprint[R]
name[R]
sha1[R]
tarball_path[R]
Public Class Methods
new(name, fingerprint, tarball_path, sha1, dependencies, is_new_version, is_dev_artifact)
click to toggle source
# File lib/cli/build_artifact.rb, line 5 def initialize(name, fingerprint, tarball_path, sha1, dependencies, is_new_version, is_dev_artifact) @name = name @fingerprint = fingerprint @tarball_path = tarball_path @sha1 = sha1 @dependencies = dependencies @is_dev_artifact = is_dev_artifact @notes = [] @is_new_version = is_new_version end
Private Class Methods
checksum(tarball_path)
click to toggle source
# File lib/cli/build_artifact.rb, line 34 def self.checksum(tarball_path) if tarball_path && File.exists?(tarball_path) digest_file(tarball_path) else nil end end
digest_file(filename)
click to toggle source
# File lib/cli/build_artifact.rb, line 42 def self.digest_file(filename) File.file?(filename) ? Digest::SHA1.file(filename).hexdigest : '' end
file_mode(path)
click to toggle source
Git doesn't really track file permissions, it just looks at executable bit and uses 0755 if it's set or 0644 if not. We have to mimic that behavior in the fingerprint calculation to avoid the situation where seemingly clean working copy would trigger new fingerprints for artifacts with changed permissions. Also we don't want current fingerprints to change, hence the exact values below.
# File lib/cli/build_artifact.rb, line 52 def self.file_mode(path) if File.directory?(path) '40755' elsif File.executable?(path) '100755' else '100644' end end
make_fingerprint(resource)
click to toggle source
TODO: be sure we are handling the case in which there was an index, with a pre-defined fingerprint
# File lib/cli/build_artifact.rb, line 63 def self.make_fingerprint(resource) scheme = 2 contents = "v#{scheme}" resource.files.each do |filename, name| contents << resource.format_fingerprint(digest_file(filename), filename, name, file_mode(filename)) end contents << resource.additional_fingerprints.join(",") Digest::SHA1.hexdigest(contents) end
Public Instance Methods
dev_artifact?()
click to toggle source
# File lib/cli/build_artifact.rb, line 24 def dev_artifact? @is_dev_artifact end
new_version?()
click to toggle source
# File lib/cli/build_artifact.rb, line 28 def new_version? @is_new_version end
promote_to_final()
click to toggle source
# File lib/cli/build_artifact.rb, line 16 def promote_to_final @is_dev_artifact = false end
version()
click to toggle source
# File lib/cli/build_artifact.rb, line 20 def version fingerprint end
Private Instance Methods
resource()
click to toggle source
# File lib/cli/build_artifact.rb, line 75 def resource raise end