facter 2.0.2-x86-mingw32 → 2.1.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of facter might be problematic. Click here for more details.

Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +14 -0
  3. data/ext/project_data.yaml +9 -6
  4. data/lib/facter/core/execution/base.rb +3 -3
  5. data/lib/facter/core/suitable.rb +1 -5
  6. data/lib/facter/dhcp_servers.rb +39 -0
  7. data/lib/facter/ec2.rb +33 -26
  8. data/lib/facter/ec2/rest.rb +130 -0
  9. data/lib/facter/fqdn.rb +2 -0
  10. data/lib/facter/gce.rb +16 -0
  11. data/lib/facter/gce/metadata.rb +87 -0
  12. data/lib/facter/kernelmajversion.rb +8 -0
  13. data/lib/facter/kernelrelease.rb +8 -0
  14. data/lib/facter/memory.rb +21 -15
  15. data/lib/facter/netmask.rb +1 -1
  16. data/lib/facter/operatingsystem.rb +20 -0
  17. data/lib/facter/operatingsystemmajrelease.rb +2 -1
  18. data/lib/facter/operatingsystemrelease.rb +19 -0
  19. data/lib/facter/osfamily.rb +3 -1
  20. data/lib/facter/partitions.rb +35 -0
  21. data/lib/facter/physicalprocessorcount.rb +9 -0
  22. data/lib/facter/processor.rb +25 -25
  23. data/lib/facter/util/config.rb +3 -1
  24. data/lib/facter/util/dhcp_servers.rb +43 -0
  25. data/lib/facter/util/ec2.rb +5 -0
  26. data/lib/facter/util/formatter.rb +2 -1
  27. data/lib/facter/util/ip.rb +1 -1
  28. data/lib/facter/util/loader.rb +10 -1
  29. data/lib/facter/util/manufacturer.rb +15 -16
  30. data/lib/facter/util/memory.rb +12 -12
  31. data/lib/facter/util/netmask.rb +1 -1
  32. data/lib/facter/util/operatingsystem.rb +21 -0
  33. data/lib/facter/util/partitions.rb +41 -0
  34. data/lib/facter/util/partitions/linux.rb +65 -0
  35. data/lib/facter/util/posix.rb +16 -0
  36. data/lib/facter/util/processor.rb +8 -10
  37. data/lib/facter/util/resolution.rb +4 -0
  38. data/lib/facter/util/values.rb +29 -0
  39. data/lib/facter/util/virtual.rb +32 -3
  40. data/lib/facter/util/windows_root.rb +2 -32
  41. data/lib/facter/version.rb +1 -1
  42. data/lib/facter/virtual.rb +53 -12
  43. data/spec/fixtures/ifconfig/openbsd_bridge_rules +11 -0
  44. data/spec/fixtures/unit/dhcp_servers/nmcli_devices +4 -0
  45. data/spec/fixtures/unit/dhcp_servers/nmcli_devices_disconnected +4 -0
  46. data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_dhcp +36 -0
  47. data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_static +24 -0
  48. data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_dhcp +49 -0
  49. data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_static +37 -0
  50. data/spec/fixtures/unit/dhcp_servers/route +3 -0
  51. data/spec/fixtures/unit/dhcp_servers/route_nogw +1 -0
  52. data/spec/fixtures/unit/ec2/rest/meta-data/root +20 -0
  53. data/spec/fixtures/unit/gce/metadata/metadata.json +69 -0
  54. data/spec/fixtures/unit/kernelrelease/openbsd-5.3 +2 -0
  55. data/spec/fixtures/unit/kernelrelease/openbsd-5.3-current +3 -0
  56. data/spec/fixtures/unit/memory/aix-svmon +9 -0
  57. data/spec/fixtures/unit/memory/aix-swap_l +2 -0
  58. data/spec/fixtures/unit/memory/darwin-swapinfo-multiple +3 -0
  59. data/spec/fixtures/unit/memory/darwin-swapinfo-single +2 -0
  60. data/spec/fixtures/unit/memory/darwin-vm_stat +13 -0
  61. data/spec/fixtures/unit/memory/dragonfly-vmstat +3 -0
  62. data/spec/fixtures/unit/memory/freebsd-vmstat +3 -0
  63. data/spec/fixtures/unit/memory/linux-proc_meminfo +10 -0
  64. data/spec/fixtures/unit/memory/openbsd-vmstat +3 -0
  65. data/spec/fixtures/unit/memory/smartos_zone_swap_l-single +2 -0
  66. data/spec/fixtures/unit/memory/solaris-prtconf +4 -0
  67. data/spec/fixtures/unit/memory/solaris-swap_l-multiple +3 -0
  68. data/spec/fixtures/unit/memory/solaris-swap_l-single +2 -0
  69. data/spec/fixtures/unit/memory/solaris-vmstat +3 -0
  70. data/spec/fixtures/unit/netmask/ifconfig_aix_7.txt +3 -0
  71. data/spec/fixtures/unit/util/dhcp_servers/route +3 -0
  72. data/spec/fixtures/unit/util/dhcp_servers/route_nogw +1 -0
  73. data/spec/fixtures/unit/util/manufacturer/smartos_smbios +533 -0
  74. data/spec/fixtures/unit/util/operatingsystem/cumuluslinux.txt +8 -0
  75. data/spec/fixtures/unit/util/operatingsystem/redhat-7.txt +12 -0
  76. data/spec/fixtures/unit/util/operatingsystem/sabayon.txt +7 -0
  77. data/spec/fixtures/unit/util/operatingsystem/wheezy.txt +9 -0
  78. data/spec/fixtures/unit/util/partitions/partitions/mount +9 -0
  79. data/spec/fixtures/virtual/proc_1_cgroup/in_a_container +9 -0
  80. data/spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container +8 -0
  81. data/spec/fixtures/virtual/proc_1_cgroup/not_in_a_container +9 -0
  82. data/spec/spec_helper.rb +1 -1
  83. data/spec/unit/core/execution/base_spec.rb +3 -5
  84. data/spec/unit/core/execution/posix_spec.rb +2 -2
  85. data/spec/unit/core/suitable_spec.rb +10 -0
  86. data/spec/unit/dhcp_servers_spec.rb +152 -0
  87. data/spec/unit/ec2/rest_spec.rb +145 -0
  88. data/spec/unit/ec2_spec.rb +87 -147
  89. data/spec/unit/fqdn_spec.rb +16 -0
  90. data/spec/unit/gce/metadata_spec.rb +49 -0
  91. data/spec/unit/gce_spec.rb +34 -0
  92. data/spec/unit/interfaces_spec.rb +9 -9
  93. data/spec/unit/kernelmajversion_spec.rb +14 -9
  94. data/spec/unit/kernelrelease_spec.rb +16 -0
  95. data/spec/unit/macaddress_spec.rb +12 -0
  96. data/spec/unit/memory_spec.rb +53 -122
  97. data/spec/unit/netmask_spec.rb +11 -0
  98. data/spec/unit/operatingsystem_spec.rb +19 -0
  99. data/spec/unit/operatingsystemmajrelease_spec.rb +1 -1
  100. data/spec/unit/operatingsystemrelease_spec.rb +8 -0
  101. data/spec/unit/osfamily_spec.rb +62 -0
  102. data/spec/unit/partitions_spec.rb +48 -0
  103. data/spec/unit/physicalprocessorcount_spec.rb +9 -0
  104. data/spec/unit/processor_spec.rb +15 -7
  105. data/spec/unit/util/config_spec.rb +13 -0
  106. data/spec/unit/util/dhcp_servers_spec.rb +63 -0
  107. data/spec/unit/util/ec2_spec.rb +4 -0
  108. data/spec/unit/util/formatter_spec.rb +50 -0
  109. data/spec/unit/util/loader_spec.rb +4 -4
  110. data/spec/unit/util/macosx_spec.rb +3 -2
  111. data/spec/unit/util/manufacturer_spec.rb +44 -0
  112. data/spec/unit/util/operatingsystem_spec.rb +92 -0
  113. data/spec/unit/util/partitions/partitions_spec.rb +67 -0
  114. data/spec/unit/util/partitions_spec.rb +19 -0
  115. data/spec/unit/util/posix_spec.rb +11 -0
  116. data/spec/unit/util/values_spec.rb +40 -0
  117. data/spec/unit/util/virtual_spec.rb +72 -2
  118. data/spec/unit/virtual_spec.rb +67 -18
  119. metadata +124 -54
  120. data/spec/fixtures/unit/util/loader/nosuchfact.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64f643985bca64231e41c2bfdc6500bf1cc296cc
4
- data.tar.gz: e3aa694f21cb8e42807633b708b59eda05c98575
3
+ metadata.gz: d58657a0fe9d2a305caacc71f35007a163b8d2a5
4
+ data.tar.gz: 1ad521ad3d89e27546b1aa78549459a63354258d
5
5
  SHA512:
6
- metadata.gz: 22151a671acd9b9b10d05ff243950a9a3036a3b2c9d9450a50e2ea11f34db51ef1abe5f5a0dd817399a19f755bf7987c4c3dec001588f517fa4237f09b4a782b
7
- data.tar.gz: 8024c25ae4e13449986cf4f15b19a1532b980a0f42a177d406348a8415553a0e9782d6d935bfdfe2ceb3952416897793267832e61c6e741f4d8c0126337cce22
6
+ metadata.gz: f3224ef984761af60d22aa25a6fb88ba6644b3ebfc3f6e1bd59262f6b3918cf21872ae34b939442571ab51990748125dc9bd3ef0a2a29315f735a384676079a4
7
+ data.tar.gz: 7352719baf45455d0b26e3d43ea28614213ab77ae8d1a344fc33120b6567eb6eb21d2a62245aa2f886a73503966657180fe48962f24415ec019387ba4c43cf87
data/Gemfile CHANGED
@@ -20,6 +20,7 @@ require 'yaml'
20
20
  data = YAML.load_file(File.join(File.dirname(__FILE__), 'ext', 'project_data.yaml'))
21
21
  bundle_platforms = data['bundle_platforms']
22
22
  data['gem_platform_dependencies'].each_pair do |gem_platform, info|
23
+ next if gem_platform =~ /mingw/
23
24
  if bundle_deps = info['gem_runtime_dependencies']
24
25
  bundle_platform = bundle_platforms[gem_platform] or raise "Missing bundle_platform"
25
26
  platform(bundle_platform.intern) do
@@ -30,6 +31,19 @@ data['gem_platform_dependencies'].each_pair do |gem_platform, info|
30
31
  end
31
32
  end
32
33
 
34
+ platform(:mingw_19) do
35
+ gem 'win32console', '~> 1.3.2', :require => false
36
+ end
37
+
38
+ mingw = [:mingw]
39
+ mingw << :x64_mingw if Bundler::Dsl::VALID_PLATFORMS.include?(:x64_mingw)
40
+
41
+ platform(*mingw) do
42
+ gem 'ffi', '~> 1.9.3', :require => false
43
+ gem 'win32-dir', '~> 0.4.8', :require => false
44
+ gem 'win32-security', '~> 0.2.5', :require => false
45
+ end
46
+
33
47
  gem 'facter', ">= 1.0.0", :path => File.expand_path("..", __FILE__)
34
48
 
35
49
  if File.exists? "#{__FILE__}.local"
@@ -19,15 +19,18 @@ gem_platform_dependencies:
19
19
  CFPropertyList: '~> 2.2.6'
20
20
  x86-mingw32:
21
21
  gem_runtime_dependencies:
22
- ffi: '1.9.0'
23
- sys-admin: '1.5.6'
24
- win32-api: '1.4.8'
25
- win32-dir: '~> 0.4.3'
26
- windows-api: '~> 0.4.2'
27
- windows-pr: '~> 1.2.2'
22
+ ffi: '~> 1.9.3'
23
+ win32-dir: '~> 0.4.8'
24
+ win32-security: '~> 0.2.5'
28
25
  win32console: '~> 1.3.2'
26
+ x64-mingw32:
27
+ gem_runtime_dependencies:
28
+ ffi: '~> 1.9.3'
29
+ win32-dir: '~> 0.4.8'
30
+ win32-security: '~> 0.2.5'
29
31
  bundle_platforms:
30
32
  universal-darwin: ruby
31
33
  x86-mingw32: mingw
34
+ x64-mingw32: x64_mingw
32
35
  pre_tasks:
33
36
  'package:apple': 'cfpropertylist'
@@ -31,9 +31,9 @@ class Facter::Core::Execution::Base
31
31
 
32
32
  on_fail = options.fetch(:on_fail, :raise)
33
33
 
34
- ## Set LANG to force i18n to C for the duration of this exec; this ensures that any code that parses the
35
- ## output of the command can expect it to be in a consistent / predictable format / locale
36
- with_env "LANG" => "C" do
34
+ # Set LC_ALL and LANG to force i18n to C for the duration of this exec; this ensures that any code that parses the
35
+ # output of the command can expect it to be in a consistent / predictable format / locale
36
+ with_env 'LC_ALL' => 'C', 'LANG' => 'C' do
37
37
 
38
38
  expanded_command = expand_command(command)
39
39
 
@@ -108,10 +108,6 @@ module Facter::Core::Suitable
108
108
  #
109
109
  # @api private
110
110
  def suitable?
111
- unless defined? @suitable
112
- @suitable = ! @confines.detect { |confine| ! confine.true? }
113
- end
114
-
115
- return @suitable
111
+ @confines.all? { |confine| confine.true? }
116
112
  end
117
113
  end
@@ -0,0 +1,39 @@
1
+ # Fact: dhcp_servers
2
+ #
3
+ # Purpose:
4
+ # Return the DHCP server addresses for all interfaces as a hash.
5
+ # If the interface that is the default gateway is dhcp assigned, there
6
+ # will also be a 'system' entry in the hash.
7
+ #
8
+ # Resolution:
9
+ # Parses the output of nmcli to find the DHCP server for the interface if available
10
+ #
11
+ # Caveats:
12
+ # Requires nmcli to be available and the interface must use network-manager.
13
+ #
14
+
15
+ require 'facter'
16
+ require 'facter/util/dhcp_servers'
17
+
18
+
19
+ Facter.add(:dhcp_servers) do
20
+ confine :kernel => :linux
21
+ confine do
22
+ Facter::Core::Execution.which('nmcli')
23
+ end
24
+
25
+ setcode do
26
+ gwdev = Facter::Util::DHCPServers.gateway_device
27
+ devices = Facter::Util::DHCPServers.devices
28
+
29
+ dhcp_servers = {}
30
+ devices.each do |device|
31
+ if server = Facter::Util::DHCPServers.device_dhcp_server(device)
32
+ dhcp_servers['system'] = server if device == gwdev
33
+ dhcp_servers[device] = server
34
+ end
35
+ end
36
+
37
+ dhcp_servers.keys.length > 0 ? dhcp_servers : nil
38
+ end
39
+ end
@@ -1,37 +1,44 @@
1
- require 'facter/util/ec2'
2
- require 'open-uri'
1
+ require 'facter/ec2/rest'
3
2
 
4
- def metadata(id = "")
5
- open("http://169.254.169.254/2008-02-01/meta-data/#{id||=''}").read.
6
- split("\n").each do |o|
7
- key = "#{id}#{o.gsub(/\=.*$/, '/')}"
8
- if key[-1..-1] != '/'
9
- value = open("http://169.254.169.254/2008-02-01/meta-data/#{key}").read.
10
- split("\n")
11
- symbol = "ec2_#{key.gsub(/\-|\//, '_')}".to_sym
12
- Facter.add(symbol) { setcode { value.join(',') } }
13
- else
14
- metadata(key)
3
+ Facter.define_fact(:ec2_metadata) do
4
+ define_resolution(:rest) do
5
+ confine do
6
+ Facter.value(:virtual).match /^xen/
7
+ end
8
+
9
+ @querier = Facter::EC2::Metadata.new
10
+ confine do
11
+ @querier.reachable?
12
+ end
13
+
14
+ setcode do
15
+ @querier.fetch
15
16
  end
16
17
  end
17
- rescue => details
18
- Facter.warn "Could not retrieve ec2 metadata: #{details.message}"
19
18
  end
20
19
 
21
- def userdata()
22
- Facter.add(:ec2_userdata) do
20
+ Facter.define_fact(:ec2_userdata) do
21
+ define_resolution(:rest) do
22
+ confine do
23
+ Facter.value(:virtual).match /^xen/
24
+ end
25
+
26
+ @querier = Facter::EC2::Userdata.new
27
+ confine do
28
+ @querier.reachable?
29
+ end
30
+
23
31
  setcode do
24
- if userdata = Facter::Util::EC2.userdata
25
- userdata.split
26
- end
32
+ @querier.fetch
27
33
  end
28
34
  end
29
35
  end
30
36
 
31
- if (Facter::Util::EC2.has_euca_mac? || Facter::Util::EC2.has_openstack_mac? ||
32
- Facter::Util::EC2.has_ec2_arp?) && Facter::Util::EC2.can_connect?
33
- metadata
34
- userdata
35
- else
36
- Facter.debug "Not an EC2 host"
37
+ # The flattened version of the EC2 facts are deprecated and will be removed in
38
+ # a future release of Facter.
39
+ if (ec2_metadata = Facter.value(:ec2_metadata))
40
+ ec2_facts = Facter::Util::Values.flatten_structure("ec2", ec2_metadata)
41
+ ec2_facts.each_pair do |factname, factvalue|
42
+ Facter.add(factname, :value => factvalue)
43
+ end
37
44
  end
@@ -0,0 +1,130 @@
1
+ require 'timeout'
2
+ require 'open-uri'
3
+
4
+ module Facter
5
+ module EC2
6
+ CONNECTION_ERRORS = [
7
+ Errno::EHOSTDOWN,
8
+ Errno::EHOSTUNREACH,
9
+ Errno::ENETUNREACH,
10
+ Errno::ECONNABORTED,
11
+ Errno::ECONNREFUSED,
12
+ Errno::ECONNRESET,
13
+ Errno::ETIMEDOUT,
14
+ ]
15
+
16
+ class Base
17
+ def reachable?(retry_limit = 3)
18
+ timeout = 0.2
19
+ able_to_connect = false
20
+ attempts = 0
21
+
22
+ begin
23
+ Timeout.timeout(timeout) do
24
+ open(@baseurl).read
25
+ end
26
+ able_to_connect = true
27
+ rescue OpenURI::HTTPError => e
28
+ if e.message.match /404 Not Found/i
29
+ able_to_connect = false
30
+ else
31
+ attempts = attempts + 1
32
+ retry if attempts < retry_limit
33
+ end
34
+ rescue Timeout::Error
35
+ attempts = attempts + 1
36
+ retry if attempts < retry_limit
37
+ rescue *CONNECTION_ERRORS
38
+ attempts = attempts + 1
39
+ retry if attempts < retry_limit
40
+ end
41
+
42
+ able_to_connect
43
+ end
44
+ end
45
+
46
+ class Metadata < Base
47
+
48
+ DEFAULT_URI = "http://169.254.169.254/latest/meta-data/"
49
+
50
+ def initialize(uri = DEFAULT_URI)
51
+ @baseurl = uri
52
+ end
53
+
54
+ def fetch(path = '')
55
+ results = {}
56
+
57
+ keys = fetch_endpoint(path)
58
+ keys.each do |key|
59
+ if key.match(%r[/$])
60
+ # If a metadata key is suffixed with '/' then it's a general metadata
61
+ # resource, so we have to recursively look up all the keys in the given
62
+ # collection.
63
+ name = key[0..-2]
64
+ results[name] = fetch("#{path}#{key}")
65
+ else
66
+ # This is a simple key/value pair, we can just query the given endpoint
67
+ # and store the results.
68
+ ret = fetch_endpoint("#{path}#{key}")
69
+ results[key] = ret.size > 1 ? ret : ret.first
70
+ end
71
+ end
72
+
73
+ results
74
+ end
75
+
76
+ # @param path [String] The path relative to the object base url
77
+ #
78
+ # @return [Array, NilClass]
79
+ def fetch_endpoint(path)
80
+ uri = @baseurl + path
81
+ body = open(uri).read
82
+ parse_results(body)
83
+ rescue OpenURI::HTTPError => e
84
+ if e.message.match /404 Not Found/i
85
+ return nil
86
+ else
87
+ Facter.log_exception(e, "Failed to fetch ec2 uri #{uri}: #{e.message}")
88
+ return nil
89
+ end
90
+ rescue *CONNECTION_ERRORS => e
91
+ Facter.log_exception(e, "Failed to fetch ec2 uri #{uri}: #{e.message}")
92
+ return nil
93
+ end
94
+
95
+ private
96
+
97
+ def parse_results(body)
98
+ lines = body.split("\n")
99
+ lines.map do |line|
100
+ if (match = line.match(/^(\d+)=.*$/))
101
+ # Metadata arrays are formatted like '<index>=<associated key>/', so
102
+ # we need to extract the index from that output.
103
+ "#{match[1]}/"
104
+ else
105
+ line
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ class Userdata < Base
112
+ DEFAULT_URI = "http://169.254.169.254/latest/user-data/"
113
+
114
+ def initialize(uri = DEFAULT_URI)
115
+ @baseurl = uri
116
+ end
117
+
118
+ def fetch
119
+ open(@baseurl).read
120
+ rescue OpenURI::HTTPError => e
121
+ if e.message.match /404 Not Found/i
122
+ return nil
123
+ else
124
+ Facter.log_exception(e, "Failed to fetch ec2 uri #{uri}: #{e.message}")
125
+ return nil
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
@@ -15,6 +15,8 @@ Facter.add(:fqdn) do
15
15
  domain = Facter.value(:domain)
16
16
  if host and domain
17
17
  [host, domain].join(".")
18
+ elsif host
19
+ host
18
20
  else
19
21
  nil
20
22
  end
@@ -0,0 +1,16 @@
1
+ require 'facter/gce/metadata'
2
+
3
+ Facter.define_fact(:gce) do
4
+ define_resolution(:rest) do
5
+ confine :virtual => 'gce'
6
+
7
+ confine do
8
+ Facter.json?
9
+ end
10
+
11
+ setcode do
12
+ querier = Facter::GCE::Metadata.new
13
+ querier.fetch
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,87 @@
1
+ require 'open-uri'
2
+
3
+ module Facter
4
+ module GCE
5
+
6
+ # @api private
7
+ class Metadata
8
+ CONNECTION_ERRORS = [
9
+ OpenURI::HTTPError,
10
+ Errno::EHOSTDOWN,
11
+ Errno::EHOSTUNREACH,
12
+ Errno::ENETUNREACH,
13
+ Errno::ECONNABORTED,
14
+ Errno::ECONNREFUSED,
15
+ Errno::ECONNRESET,
16
+ Errno::ETIMEDOUT,
17
+ Timeout::Error,
18
+ ]
19
+
20
+ METADATA_URL = "http://metadata/computeMetadata/v1beta1/?recursive=true&alt=json"
21
+
22
+ def initialize(url = METADATA_URL)
23
+ @url = url
24
+ end
25
+
26
+ def fetch
27
+ with_metadata_server do |body|
28
+ # This will only be reached if the confine associated with this class
29
+ # was true which means that JSON was required, but it's a bit
30
+ # questionable that we're relying on JSON being loaded as a side
31
+ # effect of that.
32
+ hash = ::JSON.parse(body)
33
+ transform_metadata!(hash)
34
+ hash
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def with_metadata_server
41
+ retry_limit = 3
42
+ timeout = 0.05
43
+ body = nil
44
+ attempts = 0
45
+
46
+ begin
47
+ Timeout.timeout(timeout) do
48
+ body = open(@url).read
49
+ end
50
+ rescue *CONNECTION_ERRORS => e
51
+ attempts = attempts + 1
52
+ if attempts < retry_limit
53
+ retry
54
+ else
55
+ Facter.log_exception(e, "Unable to fetch metadata from #{@url}: #{e.message}")
56
+ return nil
57
+ end
58
+ end
59
+
60
+ if body
61
+ yield body
62
+ end
63
+ end
64
+
65
+ # @return [void]
66
+ def transform_metadata!(data)
67
+ case data
68
+ when Hash
69
+ data.keys.each do |key|
70
+ value = data[key]
71
+ if ["image", "machineType", "zone", "network"].include? key
72
+ data[key] = value.split('/').last
73
+ elsif key == "sshKeys"
74
+ data['sshKeys'] = value.split("\n")
75
+ end
76
+ transform_metadata!(value)
77
+ end
78
+ when Array
79
+ data.each do |value|
80
+ transform_metadata!(value)
81
+ end
82
+ end
83
+ nil
84
+ end
85
+ end
86
+ end
87
+ end