class OpenShift::Runtime::DeploymentMetadata

Public Class Methods

new(container, deployment_datetime) click to toggle source

Creates a new DeploymentMetadata instance for the given deployment_datetime.

If the file doesn't exist, create it and set the defaults.

If the file does exist, load it from disk.

# File lib/openshift-origin-node/model/deployment_metadata.rb, line 44
def initialize(container, deployment_datetime)
  @file = PathUtils.join(container.container_dir, 'app-deployments', deployment_datetime, 'metadata.json')

  if File.exist?(@file)
    load
  else
    File.new(@file, "w", 0o0644)
    container.set_rw_permission(@file)

    @metadata = defaults

    save
  end
end

Public Instance Methods

as_json(options={}) click to toggle source
# File lib/openshift-origin-node/model/deployment_metadata.rb, line 69
def as_json(options={})
  {
    git_ref: @metadata[:git_ref],
    git_sha1: @metadata[:git_sha1],
    id: @metadata[:id],
    hot_deploy: @metadata[:hot_deploy],
    force_clean_build: @metadata[:force_clean_build],
    activations: @metadata[:activations],
    checksum: @metadata[:checksum]
  }
end
load() click to toggle source
# File lib/openshift-origin-node/model/deployment_metadata.rb, line 59
def load
  File.open(@file, "r") do |f|
    @metadata = HashWithIndifferentAccess.new(JSON.load(f))
  end
end
record_activation() click to toggle source
# File lib/openshift-origin-node/model/deployment_metadata.rb, line 35
def record_activation
  self.activations << Time.now.to_f
end
save() click to toggle source
# File lib/openshift-origin-node/model/deployment_metadata.rb, line 65
def save
  File.open(@file, "w") { |f| f.write JSON.dump(self) }
end

Private Instance Methods

defaults() click to toggle source
# File lib/openshift-origin-node/model/deployment_metadata.rb, line 83
def defaults
  {
    git_ref: 'master',
    git_sha1: nil,
    id: nil,
    hot_deploy: nil,
    force_clean_build: nil,
    activations: [],
    checksum: nil
  }
end