Module: SkullIsland::Helpers::Migration
- Included in:
- CLI
- Defined in:
- lib/skull_island/helpers/migration.rb
Overview
Simple helper methods for migrating old configs
Instance Method Summary collapse
- #migrate_0_14_to_1_1(config) ⇒ Object
- #migrate_1_1_to_1_4(config) ⇒ Object
- #migrate_1_4_to_1_5(config) ⇒ Object
- #migrate_1_5_to_2_0(config) ⇒ Object
- #migrate_config(config) ⇒ Object
Instance Method Details
#migrate_0_14_to_1_1(config) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/skull_island/helpers/migration.rb', line 21 def migrate_0_14_to_1_1(config) new_config = config.dup config['plugins']&.each_with_index do |plugin, plugin_index| %w[consumer route service].each do |rtype| if plugin["#{rtype}_id"]&.start_with?('<%=') new_config['plugins'][plugin_index][rtype] = plugin["#{rtype}_id"].dup new_config['plugins'][plugin_index].delete("#{rtype}_id") elsif plugin["#{rtype}_id"] new_config['plugins'][plugin_index][rtype] = { 'id' => plugin["#{rtype}_id"].dup } end end end new_config['version'] = '1.1' new_config end |
#migrate_1_1_to_1_4(config) ⇒ Object
39 40 41 42 43 |
# File 'lib/skull_island/helpers/migration.rb', line 39 def migrate_1_1_to_1_4(config) new_config = config.dup new_config['version'] = '1.4' new_config end |
#migrate_1_4_to_1_5(config) ⇒ Object
45 46 47 48 49 |
# File 'lib/skull_island/helpers/migration.rb', line 45 def migrate_1_4_to_1_5(config) new_config = config.dup new_config['version'] = '1.5' new_config end |
#migrate_1_5_to_2_0(config) ⇒ Object
51 52 53 54 55 |
# File 'lib/skull_island/helpers/migration.rb', line 51 def migrate_1_5_to_2_0(config) new_config = config.dup new_config['version'] = '2.0' new_config end |
#migrate_config(config) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/skull_island/helpers/migration.rb', line 7 def migrate_config(config) if config['version'] == '0.14' migrate_config migrate_0_14_to_1_1(config) elsif ['1.0', '1.1', '1.2', '1.3'].include?(config['version']) migrate_config migrate_1_1_to_1_4(config) elsif config['version'] == '1.4' migrate_config migrate_1_4_to_1_5(config) elsif config['version'] == '1.5' migrate_1_5_to_2_0(config) else false # Just return false if it can't be migrated end end |