Sha256: 3dceed29467994865008b528fbd12092cd530d737ebbdef097413393623d601e

Contents?: true

Size: 1.48 KB

Versions: 30

Compression:

Stored size: 1.48 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
      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.join('-')
    end

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

    def light?
      @light
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
bosh-stemcell-1.2824.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2820.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2818.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2811.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2810.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2809.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2807.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2801.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2798.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2797.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2792.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2789.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2788.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2787.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2786.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2785.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2781.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2780.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2778.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2776.0 lib/bosh/stemcell/definition.rb