Class: Nvoi::Configuration::Service
- Inherits:
-
Object
- Object
- Nvoi::Configuration::Service
- Defined in:
- lib/nvoi/configuration/service.rb
Overview
Service defines a generic service
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#env ⇒ Object
Returns the value of attribute env.
-
#image ⇒ Object
Returns the value of attribute image.
-
#mount ⇒ Object
Returns the value of attribute mount.
-
#port ⇒ Object
Returns the value of attribute port.
-
#servers ⇒ Object
Returns the value of attribute servers.
Instance Method Summary collapse
-
#initialize(data = nil) ⇒ Service
constructor
A new instance of Service.
- #to_service_spec(app_name, service_name) ⇒ Object
Constructor Details
#initialize(data = nil) ⇒ Service
Returns a new instance of Service.
9 10 11 12 13 14 15 16 17 |
# File 'lib/nvoi/configuration/service.rb', line 9 def initialize(data = nil) data ||= {} @servers = data["servers"] || [] @image = data["image"] @port = data["port"]&.to_i @command = data["command"] @env = data["env"] || {} @mount = data["mount"] || {} end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
7 8 9 |
# File 'lib/nvoi/configuration/service.rb', line 7 def command @command end |
#env ⇒ Object
Returns the value of attribute env.
7 8 9 |
# File 'lib/nvoi/configuration/service.rb', line 7 def env @env end |
#image ⇒ Object
Returns the value of attribute image.
7 8 9 |
# File 'lib/nvoi/configuration/service.rb', line 7 def image @image end |
#mount ⇒ Object
Returns the value of attribute mount.
7 8 9 |
# File 'lib/nvoi/configuration/service.rb', line 7 def mount @mount end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/nvoi/configuration/service.rb', line 7 def port @port end |
#servers ⇒ Object
Returns the value of attribute servers.
7 8 9 |
# File 'lib/nvoi/configuration/service.rb', line 7 def servers @servers end |
Instance Method Details
#to_service_spec(app_name, service_name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nvoi/configuration/service.rb', line 19 def to_service_spec(app_name, service_name) cmd = @command ? @command.split : [] port = @port && @port.positive? ? @port : infer_port_from_image Configuration::Deployment.new( name: "#{app_name}-#{service_name}", image: @image, port:, command: cmd, env: @env, mounts: @mount, replicas: 1, stateful_set: false, servers: @servers ) end |