Method: PDK::Module::Convert#update_metadata

Defined in:
lib/pdk/module/convert.rb

#update_metadata(metadata_path, template_metadata) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/pdk/module/convert.rb', line 109

def (, )
  if File.file?()
    if File.readable?()
      begin
         = PDK::Module::.from_file()
        new_values = PDK::Module::::DEFAULTS.reject { |key, _| .data.key?(key) }
        .update!(new_values)
      rescue ArgumentError
         = PDK::Generate::Module.(options) unless options[:noop] # rubocop:disable Metrics/BlockNesting
      end
    else
      raise PDK::CLI::ExitWithError, _('Unable to update module metadata; %{path} exists but it is not readable.') % {
        path: ,
      }
    end
  elsif File.exist?()
    raise PDK::CLI::ExitWithError, _('Unable to update module metadata; %{path} exists but it is not a file.') % {
      path: ,
    }
  else
    return nil if options[:noop]

    project_dir = File.basename(Dir.pwd)
    options[:module_name] = project_dir.split('-', 2).compact[-1]
    options[:prompt] = false
    options[:'skip-interview'] = true if options[:force]

     = PDK::Generate::Module.(options)
  end

  .update!()
  
end