forked from cloudfoundry/bosh-linux-stemcell-builder
-
Notifications
You must be signed in to change notification settings - Fork 3
/
operating_system.rb
58 lines (49 loc) · 1.41 KB
/
operating_system.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
module Bosh::Stemcell
module OperatingSystem
def self.for(operating_system_name, operating_system_version = nil)
case operating_system_name
when 'centos' then Centos.new(operating_system_version)
when 'rhel' then Rhel.new(operating_system_version)
when 'ubuntu' then Ubuntu.new(operating_system_version)
when 'photonos' then Photonos.new(operating_system_version)
when 'opensuse' then Opensuse.new(operating_system_version)
else raise ArgumentError.new("invalid operating system: #{operating_system_name}")
end
end
class Base
attr_reader :name, :version
def initialize(options = {})
@name = options.fetch(:name)
@version = options.fetch(:version)
end
def ==(other)
name == other.name
end
end
class Rhel < Base
def initialize(version)
super(name: 'rhel', version: version)
end
end
class Centos < Base
def initialize(version)
super(name: 'centos', version: version)
end
end
class Ubuntu < Base
def initialize(version)
super(name: 'ubuntu', version: version)
end
end
class Opensuse < Base
def initialize(version)
super(name: 'opensuse', version: version)
end
end
class Photonos < Base
def initialize(version)
super(name: 'photonos', version: version)
end
end
end
end