kdeploy 1.2.5 → 1.2.6
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/kdeploy/cli.rb +7 -1
- data/lib/kdeploy/configuration.rb +53 -0
- data/lib/kdeploy/executor.rb +2 -2
- data/lib/kdeploy/version.rb +2 -1
- metadata +1 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a3af51405ecedeb02c10520a2ddba0cf5f76ee0a25e2a2d311db9319ebe76bb
|
|
4
|
+
data.tar.gz: b8e216dadef9d55f0c1845c9bc9d849c94f72f90d08667620696fc99d57672d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b050e973842c87b45ba2e670e5963ec55f6d82fd077f2d4cc0b6557a9461810470bcb78bf2424368708855dacbaf16a7ac993a70cdf1fd588977d4b77ff077b
|
|
7
|
+
data.tar.gz: ecd13cc283ae9e1440f1566b135f85334c9df35218a654eefe8f8d445d1bb01f62431dc4b35ff51403906116c9bccc819ba879916e61c3fce1ec6582bcf10bd2
|
data/lib/kdeploy/cli.rb
CHANGED
|
@@ -46,6 +46,7 @@ module Kdeploy
|
|
|
46
46
|
method_option :parallel, type: :numeric, default: 10, desc: 'Number of parallel executions'
|
|
47
47
|
method_option :dry_run, type: :boolean, desc: 'Show what would be done'
|
|
48
48
|
def execute(task_file, task_name = nil)
|
|
49
|
+
load_config_file
|
|
49
50
|
show_banner_once
|
|
50
51
|
load_task_file(task_file)
|
|
51
52
|
|
|
@@ -58,6 +59,10 @@ module Kdeploy
|
|
|
58
59
|
|
|
59
60
|
private
|
|
60
61
|
|
|
62
|
+
def load_config_file
|
|
63
|
+
Configuration.load_from_file
|
|
64
|
+
end
|
|
65
|
+
|
|
61
66
|
def load_task_file(file)
|
|
62
67
|
validate_task_file(file)
|
|
63
68
|
# 用 instance_eval 并传递顶层 binding,兼容 heredoc
|
|
@@ -207,7 +212,8 @@ module Kdeploy
|
|
|
207
212
|
|
|
208
213
|
def run_task(hosts, task)
|
|
209
214
|
output = ConsoleOutput.new
|
|
210
|
-
|
|
215
|
+
parallel_count = options[:parallel] || Configuration.default_parallel
|
|
216
|
+
runner = Runner.new(hosts, self.class.kdeploy_tasks, parallel: parallel_count, output: output)
|
|
211
217
|
results = runner.run(task)
|
|
212
218
|
print_results(results, task)
|
|
213
219
|
end
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
3
5
|
module Kdeploy
|
|
4
6
|
# Configuration management for Kdeploy
|
|
5
7
|
class Configuration
|
|
6
8
|
DEFAULT_PARALLEL = 10
|
|
7
9
|
DEFAULT_SSH_TIMEOUT = 30
|
|
8
10
|
DEFAULT_VERIFY_HOST_KEY = :never
|
|
11
|
+
CONFIG_FILE_NAME = '.kdeploy.yml'
|
|
9
12
|
|
|
10
13
|
class << self
|
|
11
14
|
attr_accessor :default_parallel,
|
|
@@ -17,6 +20,56 @@ module Kdeploy
|
|
|
17
20
|
@default_ssh_timeout = DEFAULT_SSH_TIMEOUT
|
|
18
21
|
@default_verify_host_key = DEFAULT_VERIFY_HOST_KEY
|
|
19
22
|
end
|
|
23
|
+
|
|
24
|
+
def load_from_file(config_path = nil)
|
|
25
|
+
config_path ||= find_config_file
|
|
26
|
+
return unless config_path && File.exist?(config_path)
|
|
27
|
+
|
|
28
|
+
config = YAML.safe_load(File.read(config_path), permitted_classes: [Symbol])
|
|
29
|
+
apply_config(config)
|
|
30
|
+
rescue StandardError => e
|
|
31
|
+
warn "Warning: Failed to load config from #{config_path}: #{e.message}"
|
|
32
|
+
nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def find_config_file(start_dir = Dir.pwd)
|
|
36
|
+
current_dir = File.expand_path(start_dir)
|
|
37
|
+
|
|
38
|
+
loop do
|
|
39
|
+
config_file = File.join(current_dir, CONFIG_FILE_NAME)
|
|
40
|
+
return config_file if File.exist?(config_file)
|
|
41
|
+
|
|
42
|
+
parent_dir = File.dirname(current_dir)
|
|
43
|
+
break if parent_dir == current_dir
|
|
44
|
+
|
|
45
|
+
current_dir = parent_dir
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
nil
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def apply_config(config)
|
|
54
|
+
return unless config.is_a?(Hash)
|
|
55
|
+
|
|
56
|
+
@default_parallel = config['parallel'] if config.key?('parallel')
|
|
57
|
+
@default_ssh_timeout = config['ssh_timeout'] if config.key?('ssh_timeout')
|
|
58
|
+
@default_verify_host_key = parse_verify_host_key(config['verify_host_key']) if config.key?('verify_host_key')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def parse_verify_host_key(value)
|
|
62
|
+
case value
|
|
63
|
+
when true, 'true', 'yes', 'always'
|
|
64
|
+
:always
|
|
65
|
+
when false, 'false', 'no', 'never'
|
|
66
|
+
:never
|
|
67
|
+
when 'accept_new', 'accept-new'
|
|
68
|
+
:accept_new
|
|
69
|
+
else
|
|
70
|
+
value.to_sym if value.respond_to?(:to_sym)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
20
73
|
end
|
|
21
74
|
|
|
22
75
|
# Initialize with defaults
|
data/lib/kdeploy/executor.rb
CHANGED
data/lib/kdeploy/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kdeploy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kk
|
|
@@ -122,48 +122,6 @@ dependencies:
|
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: '0.12'
|
|
125
|
-
- !ruby/object:Gem::Dependency
|
|
126
|
-
name: irb
|
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
|
128
|
-
requirements:
|
|
129
|
-
- - ">="
|
|
130
|
-
- !ruby/object:Gem::Version
|
|
131
|
-
version: '0'
|
|
132
|
-
type: :development
|
|
133
|
-
prerelease: false
|
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
-
requirements:
|
|
136
|
-
- - ">="
|
|
137
|
-
- !ruby/object:Gem::Version
|
|
138
|
-
version: '0'
|
|
139
|
-
- !ruby/object:Gem::Dependency
|
|
140
|
-
name: logger
|
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
|
142
|
-
requirements:
|
|
143
|
-
- - "~>"
|
|
144
|
-
- !ruby/object:Gem::Version
|
|
145
|
-
version: '1.6'
|
|
146
|
-
type: :development
|
|
147
|
-
prerelease: false
|
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
-
requirements:
|
|
150
|
-
- - "~>"
|
|
151
|
-
- !ruby/object:Gem::Version
|
|
152
|
-
version: '1.6'
|
|
153
|
-
- !ruby/object:Gem::Dependency
|
|
154
|
-
name: rspec
|
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
|
156
|
-
requirements:
|
|
157
|
-
- - "~>"
|
|
158
|
-
- !ruby/object:Gem::Version
|
|
159
|
-
version: '3.0'
|
|
160
|
-
type: :development
|
|
161
|
-
prerelease: false
|
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
-
requirements:
|
|
164
|
-
- - "~>"
|
|
165
|
-
- !ruby/object:Gem::Version
|
|
166
|
-
version: '3.0'
|
|
167
125
|
description: Kdeploy is a Ruby-based deployment automation tool that provides agentless
|
|
168
126
|
remote deployment solutions with an elegant DSL
|
|
169
127
|
email:
|