Sha256: e29fe67e7d1c9737e2846fbad2de5af316049bd8d1db6276d21a22304edd60a2

Contents?: true

Size: 1.22 KB

Versions: 46

Compression:

Stored size: 1.22 KB

Contents

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

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

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

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

    def stemcell_name
      stemcell_name_parts = [
        infrastructure.name,
        infrastructure.hypervisor,
        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
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
bosh-stemcell-1.2531.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2524.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2513.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2479.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2448.0 lib/bosh/stemcell/definition.rb
bosh-stemcell-1.2446.0 lib/bosh/stemcell/definition.rb