chagall 0.0.1.beta6 → 0.0.1.beta8
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.
- checksums.yaml +4 -4
- data/lib/chagall/base.rb +4 -4
- data/lib/chagall/cli.rb +1 -2
- data/lib/chagall/deploy.rb +16 -14
- data/lib/chagall/settings.rb +6 -23
- data/lib/chagall/setup.rb +5 -3
- data/lib/chagall/ssh.rb +2 -2
- data/lib/chagall/version.rb +1 -1
- metadata +2 -3
- data/lib/chagall/compose/main.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a3ec571dfa82c816310a2001d8272f3287651defad0695b9d3141392a73182
|
4
|
+
data.tar.gz: 2bc8ea9a4a7cfbc95abf74a3b0fa6f11dde77c73cd8531f8030589e2b089a342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d17e12ed9746b9cc15614aed4fb666c47779565a279a46cba8589af6ee5e1ca48f66c564838f04b5d49826e13388dc4949449c193fd2582c7ae0e01c40d0ad8
|
7
|
+
data.tar.gz: 828c9ca246db41df0bfc8a8cc9d3c76fb2e8e18d98483bde7d7410a5aaeda1ffdb246e56afe333316e78fdf8d442a96850b2ec843042c52da5005a687e3abd71
|
data/lib/chagall/base.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "logger"
|
2
2
|
require_relative "ssh"
|
3
|
+
require_relative "settings"
|
3
4
|
|
4
5
|
module Chagall
|
5
6
|
class Base < Clamp::Command
|
@@ -9,11 +10,12 @@ module Chagall
|
|
9
10
|
"info" => Logger::INFO,
|
10
11
|
"debug" => Logger::DEBUG,
|
11
12
|
"warn" => Logger::WARN,
|
12
|
-
"error" => Logger::ERROR
|
13
|
+
"error" => Logger::ERROR
|
13
14
|
}
|
14
|
-
|
15
|
+
|
15
16
|
def logger
|
16
17
|
@logger ||= Logger.new($stdout).tap do |l|
|
18
|
+
l.level = LOG_LEVELS[Chagall::Settings[:log_level]]
|
17
19
|
l.formatter = proc do |severity, _, _, msg|
|
18
20
|
if severity == "DEBUG"
|
19
21
|
"[#{severity}] #{msg}\n"
|
@@ -21,8 +23,6 @@ module Chagall
|
|
21
23
|
"#{msg}\n"
|
22
24
|
end
|
23
25
|
end
|
24
|
-
|
25
|
-
l.level = LOG_LEVELS[ENV.fetch("LOG_LEVEL", "info")]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
data/lib/chagall/cli.rb
CHANGED
@@ -10,13 +10,12 @@ Clamp.allow_options_after_parameters = true
|
|
10
10
|
|
11
11
|
module Chagall
|
12
12
|
class Cli < Clamp::Command
|
13
|
-
|
14
13
|
def run(arguments)
|
15
14
|
parse(arguments)
|
16
15
|
Chagall::Settings.configure(collect_options_hash)
|
17
16
|
execute
|
18
17
|
end
|
19
|
-
|
18
|
+
|
20
19
|
def self.options_from_config_file
|
21
20
|
@options_from_config_file ||= begin
|
22
21
|
config_path = File.join(Dir.pwd, "chagall.yml") || File.join(Dir.pwd, "chagall.yaml")
|
data/lib/chagall/deploy.rb
CHANGED
@@ -7,21 +7,21 @@ require "yaml"
|
|
7
7
|
|
8
8
|
module Chagall
|
9
9
|
class Deploy < Base
|
10
|
-
|
11
10
|
attr_reader :total_time
|
12
11
|
|
13
12
|
def execute
|
14
13
|
@interrupted = false
|
15
14
|
@total_time = 0.0
|
16
15
|
setup_signal_handlers
|
17
|
-
|
16
|
+
|
17
|
+
# binding.irb
|
18
18
|
|
19
19
|
t("Checking uncommitted changes") { check_uncommit_changes } unless Settings[:skip_uncommit]
|
20
20
|
t("Check image or build") { check_image_or_build }
|
21
|
-
t("
|
22
|
-
t("
|
23
|
-
t("
|
24
|
-
t("
|
21
|
+
t("Tag as production") { tag_as_production }
|
22
|
+
t("Update compose files") { update_compose_files }
|
23
|
+
t("Deploy compose files") { deploy_compose_files }
|
24
|
+
t("Rotate release") { rotate_releases }
|
25
25
|
|
26
26
|
print_total_time
|
27
27
|
rescue Interrupt
|
@@ -79,8 +79,17 @@ module Chagall
|
|
79
79
|
|
80
80
|
private
|
81
81
|
|
82
|
+
def format_time(seconds)
|
83
|
+
minutes, secs = seconds.abs.divmod(60)
|
84
|
+
hours, mins = minutes.divmod(60)
|
85
|
+
[[hours, 'h'], [mins, 'm'], [secs.round(2), 's']]
|
86
|
+
.reject { |n, _| n.zero? && !(_=='s') }
|
87
|
+
.map { |n, u| "#{n}#{u}" }
|
88
|
+
.join(' ')
|
89
|
+
end
|
90
|
+
|
82
91
|
def print_total_time
|
83
|
-
logger.info "Total execution time: #{
|
92
|
+
logger.info "Total execution time: #{format_time(@total_time)}"
|
84
93
|
end
|
85
94
|
|
86
95
|
def t(title)
|
@@ -195,7 +204,6 @@ module Chagall
|
|
195
204
|
logger.debug "Updating compose services..."
|
196
205
|
deploy_command = [ "docker compose" ]
|
197
206
|
|
198
|
-
# Use the remote file paths for docker compose command
|
199
207
|
Settings[:compose_files].each do |file|
|
200
208
|
deploy_command << "-f #{File.basename(file)}"
|
201
209
|
end
|
@@ -217,10 +225,8 @@ module Chagall
|
|
217
225
|
release_folder = "#{Settings.instance.project_folder_path}/releases"
|
218
226
|
release_file = "#{release_folder}/#{Settings[:release]}"
|
219
227
|
|
220
|
-
# Create releases directory if it doesn't exist
|
221
228
|
ssh.execute("mkdir -p #{release_folder}")
|
222
229
|
|
223
|
-
# Save current release
|
224
230
|
ssh.execute("touch #{release_file}")
|
225
231
|
|
226
232
|
# Get list of releases sorted by modification time (newest first)
|
@@ -250,9 +256,5 @@ module Chagall
|
|
250
256
|
|
251
257
|
result
|
252
258
|
end
|
253
|
-
|
254
|
-
def ssh
|
255
|
-
@ssh ||= SSH.new
|
256
|
-
end
|
257
259
|
end
|
258
260
|
end
|
data/lib/chagall/settings.rb
CHANGED
@@ -13,12 +13,12 @@ module Chagall
|
|
13
13
|
|
14
14
|
OPTIONS = [
|
15
15
|
{
|
16
|
-
key: :
|
17
|
-
flags: [ "--
|
18
|
-
description: "
|
19
|
-
type: :
|
20
|
-
default:
|
21
|
-
environment_variable: "
|
16
|
+
key: :log_level,
|
17
|
+
flags: [ "--log-level" ],
|
18
|
+
description: "Log level",
|
19
|
+
type: :string,
|
20
|
+
default: "info",
|
21
|
+
environment_variable: "CHAGALL_LOG_LEVEL"
|
22
22
|
},
|
23
23
|
{
|
24
24
|
key: :skip_uncommit,
|
@@ -201,23 +201,6 @@ module Chagall
|
|
201
201
|
raise Chagall::SettingsError, error_message_string unless @options[:dry_run]
|
202
202
|
end
|
203
203
|
|
204
|
-
def options_from_config_file
|
205
|
-
@options_from_config_file ||= begin
|
206
|
-
config_path = File.join(Dir.pwd, "chagall.yml") || File.join(Dir.pwd, "chagall.yaml")
|
207
|
-
return {} unless File.exist?(config_path)
|
208
|
-
|
209
|
-
config = YAML.load_file(config_path)
|
210
|
-
config.transform_keys(&:to_sym)
|
211
|
-
rescue StandardError => e
|
212
|
-
puts "Warning: Error loading chagall.yml: #{e.message}"
|
213
|
-
{}
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def true?(value)
|
218
|
-
value.to_s.strip.downcase == "true"
|
219
|
-
end
|
220
|
-
|
221
204
|
def image_tag
|
222
205
|
@image_tag ||= "#{options[:name]}:#{options[:release]}"
|
223
206
|
end
|
data/lib/chagall/setup.rb
CHANGED
@@ -34,7 +34,6 @@ module Chagall
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def unable_to_access_docker_deamon?
|
37
|
-
return true
|
38
37
|
docker_result = ssh.command("docker ps")
|
39
38
|
docker_output = `#{docker_result} 2>&1`.strip
|
40
39
|
logger.debug "Docker output: #{docker_output}"
|
@@ -72,8 +71,11 @@ module Chagall
|
|
72
71
|
compose_output = `#{ssh.command("docker compose version")} 2>&1`.strip
|
73
72
|
logger.debug "Docker Compose output: '#{compose_output}'"
|
74
73
|
|
75
|
-
|
76
|
-
compose_output.include?("
|
74
|
+
if docker_output.downcase.include?("docker version") &&
|
75
|
+
compose_output.downcase.include?("docker compose version")
|
76
|
+
logger.info "Docker and Docker Compose installed"
|
77
|
+
return true
|
78
|
+
end
|
77
79
|
|
78
80
|
logger.warn "Docker check failed:"
|
79
81
|
logger.warn "Docker output: #{docker_output}"
|
data/lib/chagall/ssh.rb
CHANGED
@@ -6,7 +6,7 @@ module Chagall
|
|
6
6
|
|
7
7
|
DEFAULT_SSH_ARGS = "-o StrictHostKeyChecking=no -o ServerAliveInterval=60".freeze
|
8
8
|
|
9
|
-
def initialize(server: Settings.instance.options[:server], ssh_args: DEFAULT_SSH_ARGS, logger:
|
9
|
+
def initialize(server: Settings.instance.options[:server], ssh_args: DEFAULT_SSH_ARGS, logger:)
|
10
10
|
@server = server
|
11
11
|
@ssh_args = ssh_args
|
12
12
|
@logger = logger
|
@@ -14,7 +14,7 @@ module Chagall
|
|
14
14
|
|
15
15
|
def execute(command, directory: nil, tty: false)
|
16
16
|
cmd = build_command(command, directory, tty)
|
17
|
-
logger.debug "SSH: #{cmd}"
|
17
|
+
logger.debug "SSH: #{cmd}" if logger.debug?
|
18
18
|
system(cmd)
|
19
19
|
$CHILD_STATUS.success?
|
20
20
|
end
|
data/lib/chagall/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chagall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Klevtsov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -94,7 +94,6 @@ files:
|
|
94
94
|
- lib/chagall/base.rb
|
95
95
|
- lib/chagall/cli.rb
|
96
96
|
- lib/chagall/compose.rb
|
97
|
-
- lib/chagall/compose/main.rb
|
98
97
|
- lib/chagall/deploy.rb
|
99
98
|
- lib/chagall/install/main.rb
|
100
99
|
- lib/chagall/install/templates/template.Dockerfile
|
data/lib/chagall/compose/main.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require_relative "../base"
|
2
|
-
|
3
|
-
module Chagall
|
4
|
-
module Compose
|
5
|
-
class Main < Base
|
6
|
-
attr_reader :command, :service, :args
|
7
|
-
|
8
|
-
def initialize(command, *args)
|
9
|
-
@command = command
|
10
|
-
@service = args.first if args.first && !args.first.start_with?('-')
|
11
|
-
@args = @service ? args[1..-1] : args
|
12
|
-
|
13
|
-
raise Chagall::Error, "Command is required" if @command.nil? || @command.empty?
|
14
|
-
|
15
|
-
run_command
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def run_command
|
21
|
-
cmd = build_command
|
22
|
-
logger.debug "Executing: #{cmd}"
|
23
|
-
|
24
|
-
result = ssh.execute(cmd, tty: true)
|
25
|
-
raise Chagall::Error, "Command failed: #{cmd}" unless result
|
26
|
-
end
|
27
|
-
|
28
|
-
def build_command
|
29
|
-
cmd = [ "cd #{Settings.instance.project_folder_path}" ]
|
30
|
-
cmd << build_docker_compose_command
|
31
|
-
cmd << @command
|
32
|
-
cmd << @service if @service
|
33
|
-
cmd << @args.join(" ") if @args && @args.any?
|
34
|
-
|
35
|
-
cmd.join(" && ")
|
36
|
-
end
|
37
|
-
|
38
|
-
def build_docker_compose_command
|
39
|
-
compose_files = Settings[:compose_files]
|
40
|
-
compose_cmd = [ "docker compose" ]
|
41
|
-
|
42
|
-
if compose_files && !compose_files.empty?
|
43
|
-
compose_files.each do |file|
|
44
|
-
compose_cmd << "-f #{File.basename(file)}"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
compose_cmd.join(" ")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|