Class: Shiplane::ConvertComposeFile
- Inherits:
-
Object
- Object
- Shiplane::ConvertComposeFile
- Extended by:
- Forwardable
- Defined in:
- lib/shiplane/convert_compose_file.rb
Instance Attribute Summary collapse
-
#project_folder ⇒ Object
Returns the value of attribute project_folder.
-
#sha ⇒ Object
Returns the value of attribute sha.
Class Method Summary collapse
Instance Method Summary collapse
- #compose_config ⇒ Object
- #compose_filepath ⇒ Object
- #convert_output! ⇒ Object
- #converted_compose_hash ⇒ Object
- #converted_output ⇒ Object
-
#initialize(project_folder, sha) ⇒ ConvertComposeFile
constructor
A new instance of ConvertComposeFile.
- #shiplane_config ⇒ Object
Constructor Details
#initialize(project_folder, sha) ⇒ ConvertComposeFile
Returns a new instance of ConvertComposeFile.
12 13 14 15 |
# File 'lib/shiplane/convert_compose_file.rb', line 12 def initialize(project_folder, sha) @project_folder = project_folder @sha = sha end |
Instance Attribute Details
#project_folder ⇒ Object
Returns the value of attribute project_folder.
8 9 10 |
# File 'lib/shiplane/convert_compose_file.rb', line 8 def project_folder @project_folder end |
#sha ⇒ Object
Returns the value of attribute sha.
8 9 10 |
# File 'lib/shiplane/convert_compose_file.rb', line 8 def sha @sha end |
Class Method Details
.convert_output!(project_folder, sha) ⇒ Object
55 56 57 |
# File 'lib/shiplane/convert_compose_file.rb', line 55 def self.convert_output!(project_folder, sha) new(project_folder, sha).convert_output! end |
Instance Method Details
#compose_config ⇒ Object
21 22 23 |
# File 'lib/shiplane/convert_compose_file.rb', line 21 def compose_config @compose_config ||= build_config.fetch('compose', {}) end |
#compose_filepath ⇒ Object
25 26 27 |
# File 'lib/shiplane/convert_compose_file.rb', line 25 def compose_filepath @compose_filepath ||= File.join(project_folder, build_config.fetch('compose_filepath', Shiplane::DEFAULT_COMPOSEFILE_FILEPATH)) end |
#convert_output! ⇒ Object
49 50 51 52 53 |
# File 'lib/shiplane/convert_compose_file.rb', line 49 def convert_output! puts "Converting Compose File..." File.write(compose_filepath, converted_output.to_yaml) puts "Compose File Converted..." end |
#converted_compose_hash ⇒ Object
29 30 31 |
# File 'lib/shiplane/convert_compose_file.rb', line 29 def converted_compose_hash @converted_compose_hash ||= Shiplane::ComposeHash.new(File.new(compose_filepath), compose_config).production_yml end |
#converted_output ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/shiplane/convert_compose_file.rb', line 33 def converted_output @converted_output ||= converted_compose_hash.dup.tap do |hash| build_config.fetch('artifacts', {}).each do |(appname, config)| hash.deep_merge!({ 'services' => { appname => { 'image' => "#{config['repo']}:#{sha}" } } }) end hash.traverse! do |key, value| if (key == 'env_file' && value == '.env.development') [key, '.env.production'] else [key, value] end end end end |
#shiplane_config ⇒ Object
17 18 19 |
# File 'lib/shiplane/convert_compose_file.rb', line 17 def shiplane_config @shiplane_config ||= Shiplane::Configuration.new end |