kdeploy 1.2.5 → 1.2.7

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.
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
- runner = Runner.new(hosts, self.class.kdeploy_tasks, parallel: options[:parallel], output: output)
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
@@ -83,8 +83,8 @@ module Kdeploy
83
83
 
84
84
  def base_ssh_options
85
85
  {
86
- verify_host_key: :never,
87
- timeout: 30
86
+ verify_host_key: Configuration.default_verify_host_key,
87
+ timeout: Configuration.default_ssh_timeout
88
88
  }
89
89
  end
90
90
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Kdeploy module for version management
3
4
  module Kdeploy
4
- VERSION = '1.2.5' unless const_defined?(:VERSION)
5
+ VERSION = '1.2.7' unless const_defined?(:VERSION)
5
6
  end
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.5
4
+ version: 1.2.7
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:
@@ -175,6 +133,7 @@ extensions:
175
133
  extra_rdoc_files: []
176
134
  files:
177
135
  - README.md
136
+ - README_EN.md
178
137
  - exe/kdeploy
179
138
  - ext/mkrf_conf.rb
180
139
  - lib/kdeploy.rb