swarm_cluster_cli_ope 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec7a0b3dd9f3253a1e18bcb091b4e31a5de19b6304a91fe77ed4d704c9a9f109
4
- data.tar.gz: b552969314967d155c2ddba35de7f4f809b5905830c1fb2edc20a0542879005f
3
+ metadata.gz: 3f13501680246e78bd7c7d3e6694a7ec96a46ea817f58b0a0ab98cecc394002e
4
+ data.tar.gz: d17bcf2b19090a6156e39da8171ae821b27822c308806b55daad73193ab68726
5
5
  SHA512:
6
- metadata.gz: 64f80000c7b36cd5ef521f41939fb93060b3e94520081b33522d44ecf52cba7754022881089a981a206b230287289e19735efd9b6fdcb1acdb60e26563c2f14a
7
- data.tar.gz: e7943eaad259b10bc0e3c6879aca2910d6a864e843d0235844eca2ef90c10c8ba7fa671b1fa2bbcbdec5041a0946abae4d96b6a49d311636f8a52dd5717a7a7a
6
+ metadata.gz: 16e6068c30b780460fdd6c6b12580d5397f8162f5c9c38b1f1e74dffbe3373028b9bd5428cdcaa15386e55e5d6354d35787bf7026c965f55c028ab81cde6bb26
7
+ data.tar.gz: db7aedd27c45e08c9c9b636da84d0916d0a7ed8c2d0b27ed07f3b4bc6d77811d0a36dee141c879d76c7ac70f34cd47520309df0235e6a141214d851d43884721
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## Changelog
2
2
 
3
+ # 0.5.5
4
+ - correzione utilizzo e configurazione variabili ambiente nelle configurazioni.
5
+ - controllo di non installare rsync e killall nel caso siano già presenti.
6
+
3
7
  # 0.5.4
4
8
  - bug permessi sul file password dell'rsync
5
9
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swarm_cluster_cli_ope (0.5.4)
4
+ swarm_cluster_cli_ope (0.5.5)
5
5
  activesupport
6
6
  open4
7
7
  thor (~> 1.0)
@@ -15,7 +15,6 @@ module SwarmClusterCliOpe
15
15
  @configs[:configs][:remote]
16
16
  end
17
17
 
18
-
19
18
  # @return [SwarmClusterCliOpe::ShellCommandResponse]
20
19
  def push
21
20
  execute(direction: :up)
@@ -26,7 +25,6 @@ module SwarmClusterCliOpe
26
25
  execute(direction: :down)
27
26
  end
28
27
 
29
-
30
28
  private
31
29
 
32
30
  def execute(direction: :down)
@@ -36,7 +34,6 @@ module SwarmClusterCliOpe
36
34
  exit
37
35
  end
38
36
 
39
-
40
37
  if yes? "Attenzione, i dati locali o remoti verranno sovrascritti/cancellati?[y,yes]"
41
38
 
42
39
  podname = container.name
@@ -46,10 +43,27 @@ module SwarmClusterCliOpe
46
43
  exit
47
44
  end
48
45
 
49
- cmd = container.exec(['bash -c "apt update && apt install -yq rsync psmisc"'])
50
- if cmd.failed?
51
- puts "Problemi nell'installazione di rsync nel pod"
52
- else
46
+ # controllo presenza comandi necessari
47
+ command_installed = false
48
+ cmd_ricerca = container.exec(['bash -c "command -v rsync && command -v killall"'])
49
+ unless cmd_ricerca.failed?
50
+ num_commands = cmd_ricerca.raw_result[:stdout].split("\n").count rescue 0
51
+ if num_commands == 2
52
+ command_installed = true
53
+ end
54
+ end
55
+
56
+ unless command_installed
57
+ # tentiamo di installarlo
58
+ cmd = container.exec(['bash -c "apt update && apt install -yq rsync psmisc"'])
59
+ if cmd.failed?
60
+ puts "Problemi nell'installazione di rsync nel pod"
61
+ else
62
+ command_installed = true
63
+ end
64
+ end
65
+
66
+ if command_installed
53
67
  cmd = container.cp_in(configs_path("rsyncd.conf"), "/tmp/.")
54
68
  copy_1 = cmd.execute.failed?
55
69
  cmd = container.cp_in(configs_path("rsyncd.secrets"), "/tmp/.")
@@ -17,6 +17,7 @@ module SwarmClusterCliOpe
17
17
  ##
18
18
  # Metodo che richiama la lambda della generazione del container al momento che ne
19
19
  # è proprio necessario
20
+ # @return [SwarmClusterCliOpe::Commands::Container,SwarmClusterCliOpe::Kubernetes::Pod]
20
21
  def container
21
22
  @container ||= @lambda_container.call
22
23
  end
@@ -26,17 +27,17 @@ module SwarmClusterCliOpe
26
27
  @configs[:service] || @sync_configs.service
27
28
  end
28
29
 
29
-
30
30
  ##
31
31
  # Costruisce i metodi che restituiscono i valori delle configurazioni
32
32
  #
33
33
  # @param [String,Symbol] name -> nome della stringa con cui viene generato il metodo
34
- # @param [String,Symbol] default_env -> nome env default nel caso non sia passato
34
+ # @param [String,Symbol,Array<String,Symbol>] default_env -> nome env default nel caso non sia passato
35
35
  # @param [String,Symbol] configuration_name -> nome della configurazione da utilizzare per estrapolare la configurazione
36
36
  # in automatico viene tenuto conto se cercare per la versione
37
37
  # con _env o senza....precedenza SENZA
38
+ # @param [Block] from_proc -> proc da utilizzare per ricavare il valore
38
39
  # @param [nil,String] default_value se non è estrapolato nessun valore, viene utilizzato il valore di default
39
- def self.define_cfgs(name, default_env:, configuration_name:,default_value:nil)
40
+ def self.define_cfgs(name, default_env:, configuration_name:, default_value: nil, from_proc: nil)
40
41
  configuration_name ||= name
41
42
 
42
43
  define_method(name) do
@@ -44,17 +45,36 @@ module SwarmClusterCliOpe
44
45
 
45
46
  #valore restituito direttamente dalla configurazione
46
47
  if @configs.key?(configuration_name)
47
- value = @configs["#{configuration_name}".to_sym] || default_value
48
- else
49
- env_var = @configs["#{configuration_name}_env".to_sym] || default_env
50
- value = find_env_file_variable(env_var) || default_value
48
+ value = @configs["#{configuration_name}".to_sym]
49
+ end
50
+ # se non abbiamo nulla dalle configurazioni utilizziamo le variabili d'ambiente
51
+ if value.nil?
52
+
53
+ #cerchiamo nella lista delle variabili ambiente possibili, la prima che ha un valore la tengo per buona
54
+ env_vars = []
55
+ env_vars << @configs["#{configuration_name}_env".to_sym]
56
+ env_vars << default_env
57
+ env_vars.flatten!
58
+ env_vars.compact!
59
+
60
+ env_vars.each do |env_var|
61
+ value = find_env_file_variable(env_var)
62
+ break unless value.nil?
63
+ end
64
+
51
65
  end
66
+ # se non abbiamo ancora nulla e abbiamo una proc proseguiamo
67
+ if value.nil? and from_proc
68
+ value = from_proc.call(container)
69
+ end
70
+
71
+ value = value || default_value
72
+
52
73
  self.instance_variable_set("@#{name}", value)
53
74
  end
54
75
 
55
76
  end
56
77
 
57
-
58
78
  private
59
79
 
60
80
  ##
@@ -50,11 +50,14 @@ module SwarmClusterCliOpe
50
50
  # Classe interna che rappresenta le configurazioni del DB
51
51
  class EnvConfigs < BaseDatabase::EnvConfigs
52
52
 
53
- define_cfgs :database_name, default_env: "POSTGRES_DB", configuration_name: :database_name
54
- define_cfgs :username, default_env: "POSTGRES_USER", configuration_name: :pg_user, default_value: 'postgres'
55
- define_cfgs :password, default_env: "POSTGRES_PASSWORD", configuration_name: :pg_password
56
-
57
- define_cfgs :database_version, default_env: "PG_MAJOR", configuration_name: :pg_version
53
+ define_cfgs :database_name, default_env: ["POSTGRES_DB", "POSTGRESQL_DATABASE"], configuration_name: :database_name
54
+ define_cfgs :username, default_env: ["POSTGRES_USER", "POSTGRESQL_USERNAME"], configuration_name: :pg_user, default_value: 'postgres'
55
+ define_cfgs :password, default_env: ["POSTGRES_PASSWORD", "POSTGRESQL_PASSWORD"], configuration_name: :pg_password
56
+
57
+ define_cfgs :database_version, default_env: "PG_MAJOR", configuration_name: :pg_version,
58
+ from_proc: ->(container) {
59
+ container.exec("postgres -V").raw_result[:stdout].strip.match(/((\d+\.)?(\d+\.)?(\*|\d+))$/)[1] rescue nil
60
+ }
58
61
 
59
62
  end
60
63
 
@@ -1,3 +1,3 @@
1
1
  module SwarmClusterCliOpe
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swarm_cluster_cli_ope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marino Bonetti
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-29 00:00:00.000000000 Z
11
+ date: 2021-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor