Sha256: b1fed69157beb10a3d00a84e4e67c4d2800d0feda74500e62080673d76d34864

Contents?: true

Size: 1.37 KB

Versions: 31

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Orchestration
  module DockerCompose
    class Configuration
      def initialize(env, environment, selected_services)
        @env = env # Global environment
        @environment = environment # Current build environment
        @selected_services = selected_services
      end

      def version
        @env.docker_api_version
      end

      def services
        Hash[services_enabled]
      end

      def volumes
        {}.merge(database_volume).merge(mongo_volume)
      end

      private

      def services_available
        {
          app: AppService,
          database: DatabaseService,
          mongo: MongoService,
          rabbitmq: RabbitMQService
        }
      end

      def services_enabled
        @selected_services.map do |service, config|
          definition = service_definition(service, config)
          next if definition.nil?

          [service.to_s, definition]
        end.compact
      end

      def database_volume
        return {} unless services.key?('database')

        { @env.database_volume => {} }
      end

      def mongo_volume
        return {} unless services.key?('mongo')

        { @env.mongo_volume => {} }
      end

      def service_definition(service, config)
        services_available
          .fetch(service)
          .new(config, @environment)
          .definition
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
orchestration-0.5.6 lib/orchestration/docker_compose/configuration.rb
orchestration-0.5.5 lib/orchestration/docker_compose/configuration.rb
orchestration-0.5.4 lib/orchestration/docker_compose/configuration.rb
orchestration-0.5.3 lib/orchestration/docker_compose/configuration.rb
orchestration-0.5.2 lib/orchestration/docker_compose/configuration.rb
orchestration-0.5.1 lib/orchestration/docker_compose/configuration.rb
orchestration-0.5.0 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.21 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.20 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.19 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.18 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.17 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.16 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.15 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.14 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.13 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.12 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.10 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.9 lib/orchestration/docker_compose/configuration.rb
orchestration-0.4.8 lib/orchestration/docker_compose/configuration.rb