swarm_cluster_cli_ope 0.5.0.pre.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -45
  3. data/README.md +11 -2
  4. data/lib/swarm_cluster_cli_ope.rb +9 -1
  5. data/lib/swarm_cluster_cli_ope/base_configuration.rb +226 -0
  6. data/lib/swarm_cluster_cli_ope/cli.rb +2 -129
  7. data/lib/swarm_cluster_cli_ope/configuration.rb +10 -186
  8. data/lib/swarm_cluster_cli_ope/configuration_concern.rb +10 -9
  9. data/lib/swarm_cluster_cli_ope/k8s.rb +59 -83
  10. data/lib/swarm_cluster_cli_ope/kubernetes/configuration.rb +75 -0
  11. data/lib/swarm_cluster_cli_ope/kubernetes/pod.rb +144 -0
  12. data/lib/swarm_cluster_cli_ope/{k8s_rsync → kubernetes/rsync_cfgs}/password +0 -0
  13. data/lib/swarm_cluster_cli_ope/{k8s_rsync → kubernetes/rsync_cfgs}/rsyncd.conf +0 -0
  14. data/lib/swarm_cluster_cli_ope/{k8s_rsync → kubernetes/rsync_cfgs}/rsyncd.secrets +0 -0
  15. data/lib/swarm_cluster_cli_ope/kubernetes/sync_configs/base_decorator.rb +28 -0
  16. data/lib/swarm_cluster_cli_ope/kubernetes/sync_configs/mysql.rb +10 -0
  17. data/lib/swarm_cluster_cli_ope/kubernetes/sync_configs/post_gres.rb +11 -0
  18. data/lib/swarm_cluster_cli_ope/kubernetes/sync_configs/rsync.rb +125 -0
  19. data/lib/swarm_cluster_cli_ope/kubernetes/sync_configs/sqlite3.rb +9 -0
  20. data/lib/swarm_cluster_cli_ope/logger_concern.rb +1 -1
  21. data/lib/swarm_cluster_cli_ope/shell_command_response.rb +18 -5
  22. data/lib/swarm_cluster_cli_ope/stack_sync_concern.rb +135 -0
  23. data/lib/swarm_cluster_cli_ope/sync_configs/base.rb +1 -1
  24. data/lib/swarm_cluster_cli_ope/sync_configs/mysql.rb +17 -2
  25. data/lib/swarm_cluster_cli_ope/sync_configs/post_gres.rb +1 -1
  26. data/lib/swarm_cluster_cli_ope/thor_configuration_concern.rb +29 -0
  27. data/lib/swarm_cluster_cli_ope/version.rb +1 -1
  28. data/swarm_cluster_cli_ope.gemspec +0 -1
  29. metadata +17 -21
@@ -9,7 +9,7 @@ module SwarmClusterCliOpe
9
9
  attr_accessor :configs
10
10
 
11
11
  # @param [Hash] configs
12
- # @param [Continuation] stack_cfgs
12
+ # @param [Configuration] stack_cfgs
13
13
  def initialize(stack_cfgs, configs)
14
14
  super()
15
15
  @configs = configs
@@ -7,9 +7,24 @@ module SwarmClusterCliOpe
7
7
  resume('pull')
8
8
  if yes?("Confermare il comando?[y,yes]")
9
9
  tmp_file = "/tmp/#{Time.now.to_i}.sql.gz"
10
- container.exec("bash -c 'mysqldump -u #{remote.username} --password=#{remote.password} #{remote.database_name} | gzip -c -f' > #{tmp_file}")
10
+ container.exec("bash -c 'mysqldump -u #{remote.username} --password=#{remote.password} #{remote.database_name} | gzip -c -f' > #{tmp_file}")
11
11
  local_container.copy_in(tmp_file, tmp_file)
12
- local_container.exec("bash -c 'zcat #{tmp_file} | mysql -u #{local.username} --password=#{local.password} #{local.database_name}'")
12
+ local_authentication = "-u #{local.username} --password=#{local.password}"
13
+
14
+ command = []
15
+ command << "bash -c '"
16
+
17
+ command << "mysql #{local_authentication} -e \"DROP DATABASE IF EXISTS #{local.database_name};CREATE DATABASE #{local.database_name}\""
18
+
19
+ command << "&&"
20
+
21
+ command << "zcat #{tmp_file}"
22
+ command << "|"
23
+ command << "mysql #{local_authentication} #{local.database_name}"
24
+
25
+ command << "'"
26
+
27
+ local_container.exec(command.join" ")
13
28
  end
14
29
  true
15
30
  end
@@ -129,7 +129,7 @@ module SwarmClusterCliOpe
129
129
  # @param [EnvConfigs] config
130
130
  def close_connections_and_drop_cmd(config)
131
131
  cmd = []
132
- cmd << "PGPASSWORD=\"#{config.password}\""
132
+ cmd << "export PGPASSWORD=\"#{config.password}\" &&"
133
133
 
134
134
  sql = []
135
135
  sql << "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '\"'\"'#{config.database_name}'\"'\"' AND pid <> pg_backend_pid();;"
@@ -0,0 +1,29 @@
1
+ require 'active_support/concern'
2
+
3
+ module SwarmClusterCliOpe
4
+ module ThorConfigurationConcern
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+
9
+ desc "config", "Visualizza le configurazioni mergiate (HOME + Project configuration[#{Configuration.cfgs_project_file_name}])"
10
+
11
+ def config
12
+ cfgs.env(options[:environment]) do
13
+ puts JSON.pretty_generate(cfgs.merged_configurations)
14
+ end
15
+ end
16
+
17
+ desc "configure_project STACK_NAME", "Genera il file di configurazione del progetto contenente il nome dello stack"
18
+
19
+ def configure_project(stack_name)
20
+ cfgs.env(options[:environment]) do |c|
21
+ c.stack_name = stack_name
22
+ c.save_project_cfgs
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module SwarmClusterCliOpe
2
- VERSION = "0.5.0.pre.2"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -33,5 +33,4 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency "zeitwerk", '~>2.3'
34
34
  spec.add_dependency "open4"
35
35
  spec.add_dependency "activesupport"
36
- spec.add_dependency "kubeclient", '~>4.9'
37
36
  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.0.pre.2
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marino Bonetti
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: kubeclient
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '4.9'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '4.9'
83
69
  description: |-
84
70
  Gestione di varie operazioni come sincronia con le cartelle bindate dei container (rsync) up o
85
71
  down e possibilità di scaricare/caricare i file direttamente all'interno del cluster, in
@@ -102,6 +88,7 @@ files:
102
88
  - Rakefile
103
89
  - exe/swarm_cli_ope
104
90
  - lib/swarm_cluster_cli_ope.rb
91
+ - lib/swarm_cluster_cli_ope/base_configuration.rb
105
92
  - lib/swarm_cluster_cli_ope/cli.rb
106
93
  - lib/swarm_cluster_cli_ope/commands/base.rb
107
94
  - lib/swarm_cluster_cli_ope/commands/compose_container.rb
@@ -112,9 +99,16 @@ files:
112
99
  - lib/swarm_cluster_cli_ope/configuration.rb
113
100
  - lib/swarm_cluster_cli_ope/configuration_concern.rb
114
101
  - lib/swarm_cluster_cli_ope/k8s.rb
115
- - lib/swarm_cluster_cli_ope/k8s_rsync/password
116
- - lib/swarm_cluster_cli_ope/k8s_rsync/rsyncd.conf
117
- - lib/swarm_cluster_cli_ope/k8s_rsync/rsyncd.secrets
102
+ - lib/swarm_cluster_cli_ope/kubernetes/configuration.rb
103
+ - lib/swarm_cluster_cli_ope/kubernetes/pod.rb
104
+ - lib/swarm_cluster_cli_ope/kubernetes/rsync_cfgs/password
105
+ - lib/swarm_cluster_cli_ope/kubernetes/rsync_cfgs/rsyncd.conf
106
+ - lib/swarm_cluster_cli_ope/kubernetes/rsync_cfgs/rsyncd.secrets
107
+ - lib/swarm_cluster_cli_ope/kubernetes/sync_configs/base_decorator.rb
108
+ - lib/swarm_cluster_cli_ope/kubernetes/sync_configs/mysql.rb
109
+ - lib/swarm_cluster_cli_ope/kubernetes/sync_configs/post_gres.rb
110
+ - lib/swarm_cluster_cli_ope/kubernetes/sync_configs/rsync.rb
111
+ - lib/swarm_cluster_cli_ope/kubernetes/sync_configs/sqlite3.rb
118
112
  - lib/swarm_cluster_cli_ope/logger_concern.rb
119
113
  - lib/swarm_cluster_cli_ope/manager.rb
120
114
  - lib/swarm_cluster_cli_ope/models/base.rb
@@ -127,6 +121,7 @@ files:
127
121
  - lib/swarm_cluster_cli_ope/node.rb
128
122
  - lib/swarm_cluster_cli_ope/shell_command_execution.rb
129
123
  - lib/swarm_cluster_cli_ope/shell_command_response.rb
124
+ - lib/swarm_cluster_cli_ope/stack_sync_concern.rb
130
125
  - lib/swarm_cluster_cli_ope/sync_configs/base.rb
131
126
  - lib/swarm_cluster_cli_ope/sync_configs/base_database.rb
132
127
  - lib/swarm_cluster_cli_ope/sync_configs/copy.rb
@@ -135,6 +130,7 @@ files:
135
130
  - lib/swarm_cluster_cli_ope/sync_configs/post_gres.rb
136
131
  - lib/swarm_cluster_cli_ope/sync_configs/rsync.rb
137
132
  - lib/swarm_cluster_cli_ope/sync_configs/sqlite3.rb
133
+ - lib/swarm_cluster_cli_ope/thor_configuration_concern.rb
138
134
  - lib/swarm_cluster_cli_ope/version.rb
139
135
  - lib/swarm_cluster_cli_ope/worker.rb
140
136
  - swarm_cluster_cli_ope.gemspec
@@ -157,9 +153,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
153
  version: 2.3.0
158
154
  required_rubygems_version: !ruby/object:Gem::Requirement
159
155
  requirements:
160
- - - ">"
156
+ - - ">="
161
157
  - !ruby/object:Gem::Version
162
- version: 1.3.1
158
+ version: '0'
163
159
  requirements: []
164
160
  rubygems_version: 3.0.8
165
161
  signing_key: