Class: SwarmClusterCliOpe::Commands::Base
- Inherits:
-
Object
- Object
- SwarmClusterCliOpe::Commands::Base
- Defined in:
- lib/swarm_cluster_cli_ope/commands/base.rb
Instance Attribute Summary collapse
-
#base_suffix_command ⇒ Array<String>
Elenco di comandi da aggiungere in coda al comando lanciato.
-
#docker_host ⇒ String
Identifivo per potersi collegare.
Class Method Summary collapse
-
.object_identifier ⇒ String
Ritorna il nome identificativo dell’elemento all’interno di docker: container,service,stack ecc..
Instance Method Summary collapse
-
#command {|cmd| ... } ⇒ SwarmClusterCliOpe::ShellCommandExecution
Aggiunge al blocco passato di comandi, i comandi standard iniziali.
-
#docker_inspect(id) ⇒ SwarmClusterCliOpe::ShellCommandResponse
Esegue l’inspect sul componente.
-
#initialize(connection_uri: nil, base_suffix_command: ["--format=\"{{json .}}\""]) ⇒ Base
constructor
A new instance of Base.
Methods included from LoggerConcern
Constructor Details
#initialize(connection_uri: nil, base_suffix_command: ["--format=\"{{json .}}\""]) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/swarm_cluster_cli_ope/commands/base.rb', line 13 def initialize(connection_uri: nil, base_suffix_command: ["--format=\"{{json .}}\""]) if connection_uri if connection_uri.blank? @docker_host = "DOCKER_HOST=" # casistica di sviluppo, in cui l'host viene mappato localmente else @docker_host = "DOCKER_HOST=#{connection_uri}" end end @base_suffix_command = base_suffix_command end |
Instance Attribute Details
#base_suffix_command ⇒ Array<String>
Returns elenco di comandi da aggiungere in coda al comando lanciato.
11 12 13 |
# File 'lib/swarm_cluster_cli_ope/commands/base.rb', line 11 def base_suffix_command @base_suffix_command end |
#docker_host ⇒ String
Returns Identifivo per potersi collegare.
8 9 10 |
# File 'lib/swarm_cluster_cli_ope/commands/base.rb', line 8 def docker_host @docker_host end |
Class Method Details
.object_identifier ⇒ String
Ritorna il nome identificativo dell’elemento all’interno di docker: container,service,stack ecc..
53 54 55 |
# File 'lib/swarm_cluster_cli_ope/commands/base.rb', line 53 def self.object_identifier self.name.demodulize.downcase end |
Instance Method Details
#command {|cmd| ... } ⇒ SwarmClusterCliOpe::ShellCommandExecution
Aggiunge al blocco passato di comandi, i comandi standard iniziali
35 36 37 38 39 |
# File 'lib/swarm_cluster_cli_ope/commands/base.rb', line 35 def command cmd = ShellCommandExecution.new(base_prefix_command) yield cmd if block_given? cmd.add(*base_suffix_command) end |
#docker_inspect(id) ⇒ SwarmClusterCliOpe::ShellCommandResponse
Esegue l’inspect sul componente
44 45 46 47 48 |
# File 'lib/swarm_cluster_cli_ope/commands/base.rb', line 44 def docker_inspect(id) command do |cmd| cmd.add(" #{self.class.object_identifier} inspect #{id}") end.execute end |