Sha256: 7d587d3c6b54d5b22d15f31bec9228be927c3aae99604355951c6f8a558d97e6

Contents?: true

Size: 1.66 KB

Versions: 139

Compression:

Stored size: 1.66 KB

Contents

require 'bosh/stemcell/infrastructure'
require 'bosh/stemcell/operating_system'
require 'bosh/stemcell/agent'

module Bosh::Stemcell
  class Definition
    attr_reader :infrastructure, :hypervisor_name, :operating_system, :agent

    def self.for(
      infrastructure_name,
      hypervisor_name,
      operating_system_name,
      operating_system_version,
      agent_name,
      light
    )
      new(
        Bosh::Stemcell::Infrastructure.for(infrastructure_name),
        hypervisor_name,
        Bosh::Stemcell::OperatingSystem.for(operating_system_name, operating_system_version),
        Bosh::Stemcell::Agent.for(agent_name),
        light,
      )
    end

    def initialize(infrastructure, hypervisor_name, operating_system, agent, light)
      @infrastructure = infrastructure
      @hypervisor_name = hypervisor_name
      @operating_system = operating_system
      @agent = agent
      @light = light
    end

    def stemcell_name(disk_format)
      stemcell_name_parts = [
        infrastructure.name,
        hypervisor_name,
        operating_system.name,
      ]
      stemcell_name_parts << operating_system.version if operating_system.version
      stemcell_name_parts << "#{agent.name}_agent" unless agent.name == 'ruby'
      stemcell_name_parts << disk_format unless disk_format == infrastructure.default_disk_format

      stemcell_name_parts.join('-')
    end

    def disk_formats
      infrastructure.disk_formats
    end

    def ==(other)
      infrastructure == other.infrastructure &&
        operating_system == other.operating_system &&
        agent == other.agent &&
        light? == other.light?
    end

    def light?
      @light == true
    end
  end
end

Version data entries

139 entries across 139 versions & 1 rubygems

Version Path
bosh-stemcell-1.3262.24.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3232.24.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3232.14.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3262.4.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3262.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3232.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3215.4.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3215.3.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3215.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3146.10.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3213.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3202.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3200.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3146.9.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3197.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3196.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3146.8.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3192.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3146.7.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.3191.0 lib/bosh/stemcell/definition.rb