Class: CemAcpt::Platform::Gcp::Metadata
- Inherits:
-
Object
- Object
- CemAcpt::Platform::Gcp::Metadata
- Includes:
- Helper
- Defined in:
- lib/cem_acpt/platform/gcp/compute.rb
Overview
This class represents GCP VM metadata
Instance Method Summary collapse
- #cmd_flag ⇒ Object
- #data ⇒ Object
-
#initialize(**data) ⇒ Metadata
constructor
A new instance of Metadata.
Methods included from Helper
#add_cmd, #cmd, #cmd_flag_vars?
Constructor Details
#initialize(**data) ⇒ Metadata
Returns a new instance of Metadata.
131 132 133 |
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 131 def initialize(**data) @data = data.transform_keys(&:to_s) end |
Instance Method Details
#cmd_flag ⇒ Object
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 139 def cmd_flag return unless cmd_flag_vars?(data) data_from_file = data.select { |k, _v| k == 'ssh-keys' }.map { |k, v| "#{k}=#{v}" }.join(',') normalized_data = data.reject { |k, _v| k == 'ssh-keys' }.map { |k, v| "#{k}=#{v}" }.join(',') cmd = [] cmd << "--metadata-from-file=#{data_from_file}" unless data_from_file.empty? cmd << "--metadata=#{normalized_data}" unless normalized_data.empty? cmd.join(' ') end |
#data ⇒ Object
135 136 137 |
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 135 def data format_data(@data) end |