eventhub-command 0.7.3 → 0.10.0

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
- SHA1:
3
- metadata.gz: 9be1880d0572ecd48c1cc0262c99fedcea248fac
4
- data.tar.gz: 0c4fbb822a5fdeae89aebfc0f2dc2b4a8361a83a
2
+ SHA256:
3
+ metadata.gz: a3b9ef32ec489113cd533f9603db9c1ae542bf32aabf82c3ae7ae4d5000919bd
4
+ data.tar.gz: a6ada20b684ac2a911ae411ab738a2d904fc151206d8f42e529967feb2bc5d08
5
5
  SHA512:
6
- metadata.gz: 5799b0d04a410f54afde4a8d0836917811381c0fdb55ccbcd39684ce045cf202eb6676543c59a08ba6ca5efcd2b3830137a417f55d5b57b13f5f697836fafcd2
7
- data.tar.gz: e62608b51f6eeb9e75be55a14283e180126f6988413d659c0416cc7702ff28b38c322bd62800ea39022597f1a6e105492a737c533d91877190336ce0f077661e
6
+ metadata.gz: 93bbf8d4c58fc240bdf0f15531f99992f927024e280e5258147373e2d867667ae52b09eb6db542d6ff10f400ed687eca39a2d113ccbd7762166d50772b77ab55
7
+ data.tar.gz: 5afc8e32a44692f25c6977db3641f3ef1bf1e7663b24c14d5126a6f2b3dec49bb033419659f8aeedcafb6e33f0c02880363ccc26002376fb7d77b5c55a94d830
data/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## 0.10.0 (2021-08-03)
2
+
3
+ * Change: Bump version
4
+
5
+ ## 0.9.0 (2021-08-02)
6
+
7
+ * Add: Apply ruby styles (standard gem)
8
+ * Add: Simple test coverage (simplecov gem)
9
+ * Add: ci with github actions
10
+ * Change: Update ruby to 2.6.6
11
+ * Change: Update rake to 13.0
12
+ * Change: Update rspec to 3.10
13
+ * Change: Update highline to 2.0
14
+ * Change: Update rubyzip to 2.3
15
+ * Change: Update net-ssh to 6.1
16
+ * Change: Hide scm password for log output
17
+ * Change: Remove redundant rails_src_dir method
18
+ * Change: rspec - improve test performance
19
+ * Change: rspec - order is randomized
20
+ * Delete: travis ci dependency
21
+
22
+ ## 0.8.0 (2018-02-21)
23
+
24
+ * Change: Update gem dependencies (rake, rspec, bundler, GLI)
25
+
26
+ ## 0.7.5 (2018-02-13)
27
+
28
+ * Re-release
29
+
30
+ ## 0.7.4 (2018-02-12)
31
+
32
+ * Includes .ruby-version in ruby packages
33
+
1
34
  ## 0.7.2 (2017-11-7)
2
35
 
3
36
  * Edit: bundler dependency
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/eventhub-command.svg)](https://badge.fury.io/rb/eventhub-command)
2
- [![Dependency Status](https://gemnasium.com/badges/github.com/thomis/eventhub-command.svg)](https://gemnasium.com/github.com/thomis/eventhub-command)
3
- [![Build Status](https://travis-ci.org/thomis/eventhub-command.svg?branch=master)](https://travis-ci.org/thomis/eventhub-command)
2
+ ![](https://github.com/thomis/eventhub-command/workflows/ci/badge.svg)
4
3
 
5
4
  eventhub-command
6
5
  ================
data/lib/deployer.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  module Deployer
2
2
  end
3
3
 
4
- require_relative 'deployer/executor'
5
- require_relative 'deployer/net_ssh_extension'
6
- require_relative 'deployer/stage'
4
+ require_relative "deployer/executor"
5
+ require_relative "deployer/net_ssh_extension"
6
+ require_relative "deployer/stage"
7
7
 
8
- require_relative 'deployer/base_deployer'
9
- require_relative 'deployer/mule_deployer'
10
- require_relative 'deployer/ruby_deployer'
11
- require_relative 'deployer/go_deployer'
12
- require_relative 'deployer/config_deployer'
13
- require_relative 'deployer/console_deployer'
8
+ require_relative "deployer/base_deployer"
9
+ require_relative "deployer/mule_deployer"
10
+ require_relative "deployer/ruby_deployer"
11
+ require_relative "deployer/go_deployer"
12
+ require_relative "deployer/config_deployer"
13
+ require_relative "deployer/console_deployer"
@@ -11,11 +11,11 @@ class Deployer::BaseDeployer
11
11
  private
12
12
 
13
13
  def config_source_dir(*extra_paths)
14
- File.join(base_dir, 'config', *extra_paths)
14
+ File.join(base_dir, "config", *extra_paths)
15
15
  end
16
16
 
17
17
  def log_deployment(executor, message)
18
- executor.execute("echo $(date): #{message} - #{ENV['USER']} >> #{deploy_log_file}")
18
+ executor.execute("echo $(date): #{message} - #{ENV["USER"]} >> #{deploy_log_file}")
19
19
  end
20
20
 
21
21
  def base_dir
@@ -23,7 +23,7 @@ class Deployer::BaseDeployer
23
23
  end
24
24
 
25
25
  def deploy_log_file
26
- File.join(shared_dir, 'logs', 'deploy.log')
26
+ File.join(shared_dir, "logs", "deploy.log")
27
27
  end
28
28
 
29
29
  def deploy_via
@@ -35,32 +35,30 @@ class Deployer::BaseDeployer
35
35
  end
36
36
 
37
37
  def via_scp?
38
- deploy_via == 'scp'
38
+ deploy_via == "scp"
39
39
  end
40
40
 
41
41
  def shared_dir
42
- File.join(base_dir, 'shared')
42
+ File.join(base_dir, "shared")
43
43
  end
44
44
 
45
45
  def cached_copy_scp_dir
46
- File.join(shared_dir, 'cached_copy_scp')
46
+ File.join(shared_dir, "cached_copy_scp")
47
47
  end
48
48
 
49
49
  def cached_copy_svn_dir
50
- File.join(shared_dir, 'cached_copy_svn')
50
+ File.join(shared_dir, "cached_copy_svn")
51
51
  end
52
52
 
53
53
  def cached_copy_dir(*extra_paths)
54
54
  dir = if via_scp?
55
55
  cached_copy_scp_dir
56
+ elsif options[:tag]
57
+ File.join(cached_copy_svn_dir, "tags", options[:tag], "releases")
58
+ elsif options[:branch]
59
+ File.join(cached_copy_svn_dir, "branches", options[:branch], "releases")
56
60
  else
57
- if options[:tag]
58
- File.join(cached_copy_svn_dir, 'tags', options[:tag], 'releases')
59
- elsif options[:branch]
60
- File.join(cached_copy_svn_dir, 'branches', options[:branch], 'releases')
61
- else
62
- File.join(cached_copy_svn_dir, 'branches', 'master', 'releases')
63
- end
61
+ File.join(cached_copy_svn_dir, "branches", "master", "releases")
64
62
  end
65
63
  File.join(dir, *extra_paths)
66
64
  end
@@ -81,16 +79,15 @@ class Deployer::BaseDeployer
81
79
  "#{scm_base_url}/branches/master/releases"
82
80
  end
83
81
 
84
-
85
82
  def create_base_dirs(executor)
86
83
  dirs = [
87
- File.join(base_dir, 'config'),
88
- File.join(base_dir, 'ruby'),
89
- File.join(base_dir, 'mule'),
90
- File.join(base_dir, 'rails'),
84
+ File.join(base_dir, "config"),
85
+ File.join(base_dir, "ruby"),
86
+ File.join(base_dir, "mule"),
87
+ File.join(base_dir, "rails"),
91
88
  shared_dir,
92
- File.join(shared_dir, 'pids'),
93
- File.join(shared_dir, 'logs'),
89
+ File.join(shared_dir, "pids"),
90
+ File.join(shared_dir, "logs"),
94
91
  cached_copy_scp_dir
95
92
  ]
96
93
  cmds = dirs.map do |dir|
@@ -115,7 +112,6 @@ class Deployer::BaseDeployer
115
112
 
116
113
  private
117
114
 
118
-
119
115
  # Executes an ls on all hosts and returns the combined
120
116
  # list of files or dirs.
121
117
  def remote_ls(executor, options, pattern)
@@ -129,7 +125,7 @@ class Deployer::BaseDeployer
129
125
 
130
126
  def verify_deployment_list!(requested, available)
131
127
  # remove requested that are not available
132
- puts 'Deployment List'.light_blue.on_blue
128
+ puts "Deployment List".light_blue.on_blue
133
129
  abort = false
134
130
  requested.each do |name|
135
131
  if available.include?(name)
@@ -143,11 +139,9 @@ class Deployer::BaseDeployer
143
139
  puts "Not all requested components are available in #{cached_copy_dir}. Will abort.".red
144
140
  raise
145
141
  end
146
-
147
142
  end
148
143
 
149
144
  def inspector_command(action, name)
150
145
  "curl -X POST --data '[{\"name\": \"#{name}\",\"action\": \"#{action}\"}]' --header \"Content-Type:application/json\" http://localhost:5500/applications"
151
146
  end
152
-
153
147
  end
@@ -1,6 +1,6 @@
1
1
  class Deployer::ConfigDeployer < Deployer::BaseDeployer
2
2
  def initialize(options = {})
3
- options[:deploy_via] = 'svn'
3
+ options[:deploy_via] = "svn"
4
4
  super(options)
5
5
  end
6
6
 
@@ -10,7 +10,7 @@ class Deployer::ConfigDeployer < Deployer::BaseDeployer
10
10
  create_base_dirs(executor)
11
11
  update_scm(executor)
12
12
 
13
- source = cached_copy_dir('..', 'config', "%{stagename}", "%{hostname}", '')
13
+ source = cached_copy_dir("..", "config", "%{stagename}", "%{hostname}", "")
14
14
  target = config_source_dir
15
15
 
16
16
  cmd = "rsync -r --exclude=.svn #{source} #{target}"
@@ -1,5 +1,4 @@
1
1
  class Deployer::ConsoleDeployer < Deployer::BaseDeployer
2
-
3
2
  def initialize(options)
4
3
  @options = options
5
4
  end
@@ -19,6 +18,6 @@ class Deployer::ConsoleDeployer < Deployer::BaseDeployer
19
18
  end
20
19
 
21
20
  def stage
22
- @options.fetch(:stage, 'development')
21
+ @options.fetch(:stage, "development")
23
22
  end
24
23
  end
@@ -1,5 +1,5 @@
1
- require 'net/ssh'
2
- require 'colorize'
1
+ require "net/ssh"
2
+ require "colorize"
3
3
 
4
4
  class Deployer::Executor
5
5
  attr_reader :stage
@@ -26,7 +26,6 @@ class Deployer::Executor
26
26
  log_result(result)
27
27
  result
28
28
  end
29
-
30
29
  rescue => e
31
30
  handle_exception(e, options)
32
31
  end
@@ -45,7 +44,6 @@ class Deployer::Executor
45
44
  log_result(result)
46
45
  result
47
46
  end
48
-
49
47
  rescue => e
50
48
  handle_exception(e, options)
51
49
  end
@@ -58,12 +56,12 @@ class Deployer::Executor
58
56
  log_result(result)
59
57
  result
60
58
  end
61
-
62
59
  rescue => e
63
60
  handle_exception(e, options)
64
61
  end
65
62
 
66
63
  private
64
+
67
65
  def handle_exception(e, options)
68
66
  if options[:abort_on_error] == false
69
67
  puts "warning".black.on_yellow
@@ -73,7 +71,6 @@ class Deployer::Executor
73
71
  puts " #{e.message}".red
74
72
  end
75
73
  raise unless options[:abort_on_error] == false
76
-
77
74
  end
78
75
 
79
76
  def verbose?
@@ -92,7 +89,7 @@ class Deployer::Executor
92
89
  end
93
90
 
94
91
  def log_command(cmd, comment = nil)
95
- puts cmd.blue
92
+ puts filter(cmd).blue
96
93
  puts " (#{comment})" if verbose? && comment
97
94
  end
98
95
 
@@ -104,8 +101,9 @@ class Deployer::Executor
104
101
  execute_local "scp -P #{host[:port]} #{host[:user]}@#{host[:host]}:#{source} #{target}"
105
102
  end
106
103
 
107
-
108
-
104
+ def filter(text)
105
+ text.gsub(/--password (\S)+/, "--password [FILTERED]")
106
+ end
109
107
 
110
108
  def execute_local(command)
111
109
  output = nil
@@ -118,12 +116,10 @@ class Deployer::Executor
118
116
 
119
117
  raise "Command \"#{command}\" returned exit code #{exit_code}" unless exit_code.success?
120
118
 
121
- result = {
119
+ {
122
120
  stdout: output,
123
- stderr: '',
124
- exit_code: 0,
121
+ stderr: "",
122
+ exit_code: 0
125
123
  }
126
-
127
- result
128
124
  end
129
125
  end
@@ -12,7 +12,6 @@ class Deployer::GoDeployer < Deployer::BaseDeployer
12
12
  Deployer::Executor.new(stage, verbose: verbose?) do |executor|
13
13
  create_base_dirs(executor)
14
14
 
15
-
16
15
  update_cached_copy(executor)
17
16
 
18
17
  # fetch processor_names unless they have been passed as an argument to the initializer
@@ -23,37 +22,37 @@ class Deployer::GoDeployer < Deployer::BaseDeployer
23
22
  log_deployment(executor, "Deploying #{processor_name} via #{deploy_via} from #{cached_copy_dir}")
24
23
 
25
24
  # stop old one
26
- if processor_name != 'inspector'
27
- cmd = inspector_command('stop', processor_name)
25
+ if processor_name != "inspector"
26
+ cmd = inspector_command("stop", processor_name)
28
27
  executor.execute(cmd, abort_on_error: false, comment: "Request to stop component")
29
28
  else
30
29
  executor.execute("kill -s TERM $(cat #{File.join(pids_dir, processor_name)}.pid)", abort_on_error: false, comment: "This is not sooo important")
31
30
  end
32
31
 
33
32
  # unzip package
34
- target = deploy_dir('go')
35
- source = cached_copy_dir('go',"#{processor_name}.zip")
33
+ target = deploy_dir("go")
34
+ source = cached_copy_dir("go", "#{processor_name}.zip")
36
35
  executor.execute("rm -rf #{processor_dir(processor_name)} && unzip -o -d #{target} #{source}")
37
36
 
38
37
  # copy config
39
38
  executor.execute("if [[ -d #{config_source_dir(processor_name)} ]] ; then cp -r #{config_source_dir(processor_name)}/* #{processor_dir(processor_name)}; fi")
40
39
 
41
40
  # remove log dir if it exists
42
- executor.execute("if [[ -d #{processor_dir(processor_name, 'logs')} ]] ; then rm -rf #{processor_dir(processor_name, 'logs')}; fi")
41
+ executor.execute("if [[ -d #{processor_dir(processor_name, "logs")} ]] ; then rm -rf #{processor_dir(processor_name, "logs")}; fi")
43
42
 
44
43
  # symlink log dir
45
- executor.execute("ln -s #{logs_dir} #{processor_dir(processor_name, 'logs')}")
44
+ executor.execute("ln -s #{logs_dir} #{processor_dir(processor_name, "logs")}")
46
45
 
47
46
  # symlink pids dir
48
- executor.execute("ln -s #{pids_dir} #{processor_dir(processor_name, 'pids')}")
47
+ executor.execute("ln -s #{pids_dir} #{processor_dir(processor_name, "pids")}")
49
48
 
50
49
  # start new one
51
- if processor_name == 'inspector'
50
+ if processor_name == "inspector"
52
51
  # default start
53
52
  executor.execute("cd #{processor_dir(processor_name)} && ./#{processor_name} -d -e $EH_ENV")
54
53
  else
55
54
  # startig go via inspector
56
- cmd = inspector_command('start', processor_name)
55
+ cmd = inspector_command("start", processor_name)
57
56
  executor.execute(cmd, abort_on_error: false, comment: "Request to start component")
58
57
  end
59
58
  end
@@ -64,8 +63,8 @@ class Deployer::GoDeployer < Deployer::BaseDeployer
64
63
 
65
64
  def update_cached_copy(executor)
66
65
  if via_scp?
67
- source = Eh::Settings.current.releases_dir('go', '*.zip')
68
- target_dir = File.join(cached_copy_dir, 'go')
66
+ source = Eh::Settings.current.releases_dir("go", "*.zip")
67
+ target_dir = File.join(cached_copy_dir, "go")
69
68
  executor.execute("rm -rf #{target_dir}/*.zip && mkdir -p #{target_dir}")
70
69
  executor.upload(source, target_dir)
71
70
  else
@@ -74,11 +73,11 @@ class Deployer::GoDeployer < Deployer::BaseDeployer
74
73
  end
75
74
 
76
75
  def logs_dir
77
- File.join(shared_dir, 'logs')
76
+ File.join(shared_dir, "logs")
78
77
  end
79
78
 
80
79
  def pids_dir
81
- File.join(shared_dir, 'pids')
80
+ File.join(shared_dir, "pids")
82
81
  end
83
82
 
84
83
  def deploy_dir(*extra_paths)
@@ -86,23 +85,23 @@ class Deployer::GoDeployer < Deployer::BaseDeployer
86
85
  end
87
86
 
88
87
  def processor_dir(*extra_paths)
89
- File.join(deploy_dir, 'go', *extra_paths)
88
+ File.join(deploy_dir, "go", *extra_paths)
90
89
  end
91
90
 
92
91
  def config_source_dir(processor_name)
93
- super('go', processor_name)
92
+ super("go", processor_name)
94
93
  end
95
94
 
96
95
  # Detect what processors to deploy
97
96
  #
98
97
  def resolve_processor_names(executor, options)
99
- available = remote_ls(executor, options, File.join(cached_copy_dir, 'go', '*.zip')).map do |name|
100
- File.basename(name, '.zip')
98
+ available = remote_ls(executor, options, File.join(cached_copy_dir, "go", "*.zip")).map do |name|
99
+ File.basename(name, ".zip")
101
100
  end
102
101
 
103
102
  fetched = Array(processor_names).map do |name|
104
- if name.include?('*') # resolve pattern on remote machine
105
- remote_ls(executor, options, File.join(cached_copy_dir, 'go', "#{name}.zip"))
103
+ if name.include?("*") # resolve pattern on remote machine
104
+ remote_ls(executor, options, File.join(cached_copy_dir, "go", "#{name}.zip"))
106
105
  else
107
106
  name
108
107
  end
@@ -112,7 +111,7 @@ class Deployer::GoDeployer < Deployer::BaseDeployer
112
111
  end
113
112
 
114
113
  fetched = fetched.flatten.map do |name|
115
- File.basename(name, '.zip')
114
+ File.basename(name, ".zip")
116
115
  end
117
116
 
118
117
  verify_deployment_list!(fetched, available)
@@ -124,10 +123,9 @@ class Deployer::GoDeployer < Deployer::BaseDeployer
124
123
  #
125
124
  def go_sorter
126
125
  ->(a, b) do
127
- return -1 if a =~ /inspector/i
128
- return 1 if b =~ /inspector/i
126
+ return -1 if /inspector/i.match?(a)
127
+ return 1 if /inspector/i.match?(b)
129
128
  a <=> b
130
129
  end
131
130
  end
132
-
133
131
  end
@@ -7,11 +7,11 @@ class Deployer::MuleDeployer < Deployer::BaseDeployer
7
7
  end
8
8
 
9
9
  def adapter_cached_copy(adapter_name)
10
- cached_copy_dir('mule', "#{adapter_name}.zip")
10
+ cached_copy_dir("mule", "#{adapter_name}.zip")
11
11
  end
12
12
 
13
13
  def config_source_dir(adapter_name)
14
- super('mule', adapter_name)
14
+ super("mule", adapter_name)
15
15
  end
16
16
 
17
17
  def deploy!
@@ -31,7 +31,7 @@ class Deployer::MuleDeployer < Deployer::BaseDeployer
31
31
  log_deployment(executor, "Deploying #{adapter_name} via #{deploy_via} from #{cached_copy_dir}")
32
32
  # make a copy of the zip files to merge them with config
33
33
  cached_copy_source = adapter_cached_copy(adapter_name)
34
- configuration_target = File.join(base_dir, 'mule', "#{adapter_name}.zip")
34
+ configuration_target = File.join(base_dir, "mule", "#{adapter_name}.zip")
35
35
  executor.execute("cp #{cached_copy_source} #{configuration_target}")
36
36
 
37
37
  # copy config
@@ -44,17 +44,16 @@ class Deployer::MuleDeployer < Deployer::BaseDeployer
44
44
  end
45
45
  end
46
46
 
47
-
48
47
  private
49
48
 
50
49
  def resolve_adapter_names(executor, options)
51
- available = remote_ls(executor, options, cached_copy_dir('mule', '*.zip')).map do |name|
52
- File.basename(name, '.zip')
50
+ available = remote_ls(executor, options, cached_copy_dir("mule", "*.zip")).map do |name|
51
+ File.basename(name, ".zip")
53
52
  end
54
53
 
55
54
  fetched = Array(adapter_names).map do |name|
56
- if name.include?('*') # resolve pattern on remote machine
57
- remote_ls(executor, options, cached_copy_dir('mule', "#{name}.zip"))
55
+ if name.include?("*") # resolve pattern on remote machine
56
+ remote_ls(executor, options, cached_copy_dir("mule", "#{name}.zip"))
58
57
  else
59
58
  name
60
59
  end
@@ -64,7 +63,7 @@ class Deployer::MuleDeployer < Deployer::BaseDeployer
64
63
  end
65
64
 
66
65
  fetched = fetched.flatten.map do |name|
67
- File.basename(name, '.zip')
66
+ File.basename(name, ".zip")
68
67
  end
69
68
 
70
69
  verify_deployment_list!(fetched, available)
@@ -74,8 +73,8 @@ class Deployer::MuleDeployer < Deployer::BaseDeployer
74
73
 
75
74
  def update_cached_copy(executor)
76
75
  if via_scp?
77
- source = Eh::Settings.current.releases_dir('mule', '*.zip')
78
- target_dir = cached_copy_dir('mule')
76
+ source = Eh::Settings.current.releases_dir("mule", "*.zip")
77
+ target_dir = cached_copy_dir("mule")
79
78
  executor.execute("rm -rf #{target_dir}/*.zip && mkdir -p #{target_dir}")
80
79
  executor.upload(source, target_dir)
81
80
  else