class SwarmClusterCliOpe::Commands::Base
Attributes
base_suffix_command[RW]
@return [Array<String>] elenco di comandi da aggiungere in coda al comando lanciato
docker_host[RW]
@return [String] Identifivo per potersi collegare
Public Class Methods
new(connection_uri: nil, base_suffix_command: ["--format=\"{{json .}}\""])
click to toggle source
# 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
object_identifier()
click to toggle source
Ritorna il nome identificativo dell'elemento all'interno di docker: container,service,stack ecc.. @return [String]
# File lib/swarm_cluster_cli_ope/commands/base.rb, line 53 def self.object_identifier self.name.demodulize.downcase end
Public Instance Methods
command() { |cmd| ... }
click to toggle source
Aggiunge al blocco passato di comandi, i comandi standard iniziali @return [SwarmClusterCliOpe::ShellCommandExecution]
# 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)
click to toggle source
Esegue l'inspect sul componente @param [String] id @return [SwarmClusterCliOpe::ShellCommandResponse]
# 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
Private Instance Methods
base_prefix_command()
click to toggle source
# File lib/swarm_cluster_cli_ope/commands/base.rb, line 59 def base_prefix_command if cfgs.development_mode? ["docker"] else [docker_host, "docker"] end end