Sha256: 1ad5dfc27ba5f81ae3412ca26d02200b308abba48c43d3a808a0f58eb75f4206

Contents?: true

Size: 1.05 KB

Versions: 30

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Orchestration
  module DockerCompose
    class MongoService
      include ComposeHelpers

      PORT = 27_020

      def initialize(config, environment)
        @config = config
        @environment = environment
      end

      def definition
        return nil unless @config.enabled?

        { 'image' => 'library/mongo' }.merge(ports).merge(volumes)
      end

      private

      def ports
        return {} unless %i[development test].include?(@environment)

        { 'ports' => ["#{sidecar_port(@environment)}#{remote_port}"] }
      end

      def volumes
        return {} if @environment == :test

        { 'volumes' => ["#{@config.env.mongo_volume}:/data/db"] }
      end

      def client
        Services::Mong::Configuration::CONFIG_KEYS.each do |key|
          return @config.settings.fetch(key) if @config.settings.key?(key)
        end
      end

      def local_port
        Orchestration.random_local_port
      end

      def remote_port
        Orchestration::Services::Mongo::PORT
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
orchestration-0.6.4 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.6.3 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.6.2 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.6.1 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.6.0 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.14 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.13 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.12 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.11 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.10 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.9 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.8 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.7 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.6 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.5 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.4 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.3 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.2 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.1 lib/orchestration/docker_compose/mongo_service.rb
orchestration-0.5.0 lib/orchestration/docker_compose/mongo_service.rb