Class: Orchestration::InstallGenerator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Orchestration::InstallGenerator
- Includes:
- FileHelpers
- Defined in:
- lib/orchestration/install_generator.rb
Instance Method Summary collapse
- #docker_compose ⇒ Object
- #dockerfile ⇒ Object
- #gitignore ⇒ Object
-
#initialize(*_args) ⇒ InstallGenerator
constructor
A new instance of InstallGenerator.
- #makefile ⇒ Object
- #orchestration_configuration ⇒ Object
Constructor Details
#initialize(*_args) ⇒ InstallGenerator
Returns a new instance of InstallGenerator.
10 11 12 13 14 |
# File 'lib/orchestration/install_generator.rb', line 10 def initialize(*_args) super @env = Environment.new(environment: 'test') @terminal ||= Terminal.new end |
Instance Method Details
#docker_compose ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/orchestration/install_generator.rb', line 56 def docker_compose path = Rails.root.join('docker-compose.yml') return if File.exist?(path) docker_compose = DockerCompose::Services.new( database: configuration(:database), mongo: configuration(:mongo), rabbitmq: configuration(:rabbitmq) ) write_file(path, docker_compose.structure.to_yaml) end |
#dockerfile ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/orchestration/install_generator.rb', line 37 def dockerfile docker_dir = Rails.root.join('docker') path = docker_dir.join('Dockerfile') content = template('Dockerfile', ruby_version: RUBY_VERSION) FileUtils.mkdir(docker_dir) unless Dir.exist?(docker_dir) write_file(path, content, overwrite: false) end |
#gitignore ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/orchestration/install_generator.rb', line 45 def gitignore path = Rails.root.join('.gitignore') entries = [ 'docker/.build', 'docker/Gemfile', 'docker/Gemfile.lock', 'docker/*.gemspec' ].map { |entry| "#{entry} # Orchestration" } ensure_lines_in_file(path, entries) end |
#makefile ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/orchestration/install_generator.rb', line 27 def makefile environment = { app_id: @env.application_name, wait_commands: wait_commands } content = template('Makefile', environment) path = @env.root.join('Makefile') delete_and_inject_after(path, "\n#!!orchestration\n", content) end |
#orchestration_configuration ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/orchestration/install_generator.rb', line 16 def orchestration_configuration path = @env.orchestration_configuration_path settings = Settings.new(path) docker_username(settings) relpath = relative_path(path) return @terminal.write(:create, relpath) unless settings.exist? return @terminal.write(:update, relpath) if settings.dirty? @terminal.write(:skip, relpath) end |