Class: Dip::Commands::Infra::Service
- Inherits:
-
Object
- Object
- Dip::Commands::Infra::Service
- Defined in:
- lib/dip/commands/infra/service.rb
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#network_env_var ⇒ Object
readonly
Returns the value of attribute network_env_var.
-
#network_name ⇒ Object
readonly
Returns the value of attribute network_name.
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
- #env ⇒ Object
-
#initialize(name, git: nil, ref: nil, path: nil) ⇒ Service
constructor
A new instance of Service.
Constructor Details
#initialize(name, git: nil, ref: nil, path: nil) ⇒ Service
Returns a new instance of Service.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dip/commands/infra/service.rb', line 11 def initialize(name, git: nil, ref: nil, path: nil) if git.nil? && path.nil? raise ArgumentError, "Infra service `#{name}` configuration error: git or path must be defined" end @name = name @git = git @ref = ref || "latest" @location = if git "#{Dip.home_path}/infra/#{@name}/#{@ref}" else File.(path) end @project_name = "dip-infra-#{name}-#{@ref}" @network_name = "dip-net-#{name}-#{@ref}" @network_env_var = "DIP_INFRA_NETWORK_#{@name.to_s.upcase.tr("-", "_")}" end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
9 10 11 |
# File 'lib/dip/commands/infra/service.rb', line 9 def git @git end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
9 10 11 |
# File 'lib/dip/commands/infra/service.rb', line 9 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/dip/commands/infra/service.rb', line 9 def name @name end |
#network_env_var ⇒ Object (readonly)
Returns the value of attribute network_env_var.
9 10 11 |
# File 'lib/dip/commands/infra/service.rb', line 9 def network_env_var @network_env_var end |
#network_name ⇒ Object (readonly)
Returns the value of attribute network_name.
9 10 11 |
# File 'lib/dip/commands/infra/service.rb', line 9 def network_name @network_name end |
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
9 10 11 |
# File 'lib/dip/commands/infra/service.rb', line 9 def project_name @project_name end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
9 10 11 |
# File 'lib/dip/commands/infra/service.rb', line 9 def ref @ref end |
Instance Method Details
#env ⇒ Object
29 30 31 32 33 34 |
# File 'lib/dip/commands/infra/service.rb', line 29 def env { "COMPOSE_PROJECT_NAME" => project_name, "DIP_INFRA_NETWORK_NAME" => network_name } end |