chatopsify 0.0.5 → 0.0.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/.github/workflows/run_rubocop.yml +8 -11
- data/.github/workflows/run_tests.yml +5 -11
- data/.rubocop.yml +6 -0
- data/Gemfile +2 -3
- data/README.md +5 -4
- data/chatopsify.gemspec +3 -5
- data/lib/capistrano/tasks/chatopsify.cap +16 -3
- data/lib/chatopsify/co.rb +37 -38
- data/lib/chatopsify/version.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +3 -33
- /data/test/{chatworkify_test.rb → chatopsify_test.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14141a20c1a8a4cfda8993608f336919ef400ad96644ca994658fd215b494a8b
|
4
|
+
data.tar.gz: dbf4b8583120ec65a00d0e47fa82e469ed4fd80e27644d1d9def262c9e8849fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 690503d6828f98cd64ce2e90540c6adcdcaccfcc59093ad195f887ee5893c549b8ffd87f6a94e9f2985826cbd12bb8bc63ab6da54b52fdba8137c88ed49465c9
|
7
|
+
data.tar.gz: 29c67e0bed4b61b825c49a4e903fc1643516a9d14279bf12b0547e04a3a802b0de0fb80fccc2dce17af082fa0bb4e3675ec185aed0796761aee8f604c82065cb
|
@@ -8,20 +8,17 @@ jobs:
|
|
8
8
|
runs-on: ubuntu-latest
|
9
9
|
|
10
10
|
steps:
|
11
|
-
- uses: actions/checkout@
|
12
|
-
- name: Set up Ruby 2.6
|
13
|
-
uses:
|
11
|
+
- uses: actions/checkout@v4
|
12
|
+
- name: Set up Ruby 2.6.4
|
13
|
+
uses: ruby/setup-ruby@v1
|
14
14
|
with:
|
15
|
-
ruby-version: 2.6.
|
16
|
-
- uses:
|
17
|
-
|
18
|
-
|
19
|
-
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
20
|
-
restore-keys: |
|
21
|
-
${{ runner.os }}-gems-
|
15
|
+
ruby-version: 2.6.4
|
16
|
+
# - uses: ruby/setup-ruby@v1
|
17
|
+
# with:
|
18
|
+
# bundler-cache: true
|
22
19
|
- name: Run Rubocop linter
|
23
20
|
run: |
|
24
|
-
gem install bundler
|
21
|
+
gem install bundler -v 2.4.22
|
25
22
|
bundle config path vendor/bundle
|
26
23
|
bundle install --jobs 4 --retry 3
|
27
24
|
bundle exec rubocop
|
@@ -8,20 +8,14 @@ jobs:
|
|
8
8
|
runs-on: ubuntu-latest
|
9
9
|
|
10
10
|
steps:
|
11
|
-
- uses: actions/checkout@
|
12
|
-
- name: Set up Ruby 2.6
|
13
|
-
uses:
|
11
|
+
- uses: actions/checkout@v4
|
12
|
+
- name: Set up Ruby 2.6.4
|
13
|
+
uses: ruby/setup-ruby@v1
|
14
14
|
with:
|
15
|
-
ruby-version: 2.6.
|
16
|
-
- uses: actions/cache@v1
|
17
|
-
with:
|
18
|
-
path: vendor/bundle
|
19
|
-
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
20
|
-
restore-keys: |
|
21
|
-
${{ runner.os }}-gems-
|
15
|
+
ruby-version: 2.6.4
|
22
16
|
- name: Run test suite
|
23
17
|
run: |
|
24
|
-
gem install bundler
|
18
|
+
gem install bundler -v 2.4.22
|
25
19
|
bundle config path vendor/bundle
|
26
20
|
bundle install --jobs 4 --retry 3
|
27
21
|
bundle exec rake test
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Chatopsify
|
2
2
|
|
3
|
-

|
4
|
-

|
5
|
-
|
6
|
-

|
4
|
+

|
5
|
+

|
6
|
+

|
7
|
+
<!--  -->
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
data/chatopsify.gemspec
CHANGED
@@ -12,15 +12,15 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.email = ['phunt@runsystem.net']
|
13
13
|
|
14
14
|
spec.summary = 'Publish deployment notifications to ChatOps via the API'
|
15
|
-
spec.description = '
|
15
|
+
spec.description = 'chatopsify = ChatOps + Capistrano notifications via API'
|
16
16
|
spec.homepage = 'https://github.com/papakvy/chatopsify'
|
17
17
|
spec.license = 'MIT'
|
18
18
|
spec.required_ruby_version = '>= 2.6'
|
19
19
|
|
20
20
|
# spec.metadata['allowed_push_host'] = 'TODO: Set to your gem server 'https://example.com''
|
21
21
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
22
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
23
|
-
spec.metadata['source_code_uri'] = 'https://github.com/papakvy/chatopsify'
|
22
|
+
# spec.metadata['homepage_uri'] = spec.homepage
|
23
|
+
# spec.metadata['source_code_uri'] = 'https://github.com/papakvy/chatopsify'
|
24
24
|
spec.metadata['changelog_uri'] = 'https://github.com/papakvy/chatopsify/blob/master/CHANGELOG.md'
|
25
25
|
|
26
26
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -31,8 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
# Uncomment to register a new dependency of your gem
|
32
32
|
|
33
33
|
spec.add_dependency 'capistrano', '~> 3.2', '>= 3.2.0'
|
34
|
-
spec.add_development_dependency 'bundler', '~> 2'
|
35
|
-
spec.add_development_dependency 'rake', '~> 1'
|
36
34
|
|
37
35
|
# For more information and examples about making a new gem, checkout our
|
38
36
|
# guide at: https://bundler.io/guides/creating_gem.html
|
@@ -4,7 +4,12 @@ namespace :chatops do
|
|
4
4
|
set :chatops_time_started, Time.now
|
5
5
|
run_locally do
|
6
6
|
if fetch(:chatops_notify_events).include? :started
|
7
|
-
|
7
|
+
info 'Notifying ChatOps of deploy started'
|
8
|
+
begin
|
9
|
+
Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:starting))
|
10
|
+
rescue StandardError => e
|
11
|
+
info "ERROR notify_started: #{e}"
|
12
|
+
end
|
8
13
|
end
|
9
14
|
end
|
10
15
|
end
|
@@ -17,7 +22,11 @@ namespace :chatops do
|
|
17
22
|
run_locally do
|
18
23
|
if fetch(:chatops_notify_events).include? :finished
|
19
24
|
info 'Notifying ChatOps of deploy finished'
|
20
|
-
|
25
|
+
begin
|
26
|
+
Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:success))
|
27
|
+
rescue StandardError => e
|
28
|
+
info "ERROR notify_finished: #{e}"
|
29
|
+
end
|
21
30
|
end
|
22
31
|
end
|
23
32
|
end
|
@@ -30,7 +39,11 @@ namespace :chatops do
|
|
30
39
|
run_locally do
|
31
40
|
if fetch(:chatops_notify_events).include? :failed
|
32
41
|
info 'Notifying ChatOps of deploy failed'
|
33
|
-
|
42
|
+
begin
|
43
|
+
Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:failed))
|
44
|
+
rescue StandardError => e
|
45
|
+
info "ERROR notify_failed: #{e}"
|
46
|
+
end
|
34
47
|
end
|
35
48
|
end
|
36
49
|
end
|
data/lib/chatopsify/co.rb
CHANGED
@@ -4,6 +4,7 @@ require 'json'
|
|
4
4
|
require 'net/http'
|
5
5
|
|
6
6
|
module Chatopsify
|
7
|
+
# ChatOps services
|
7
8
|
class Co
|
8
9
|
def initialize(api_key = nil)
|
9
10
|
@api_key = api_key || load_api_key
|
@@ -23,8 +24,8 @@ module Chatopsify
|
|
23
24
|
puts e.message
|
24
25
|
end
|
25
26
|
|
26
|
-
def
|
27
|
-
|
27
|
+
def call_delete(id = nil)
|
28
|
+
send_delete_request(id)
|
28
29
|
rescue StandardError => e
|
29
30
|
puts e.message
|
30
31
|
end
|
@@ -65,11 +66,10 @@ module Chatopsify
|
|
65
66
|
puts "Response: #{res.code} #{res.body}"
|
66
67
|
end
|
67
68
|
|
68
|
-
def
|
69
|
+
def send_delete_request(id = nil)
|
69
70
|
uri = URI(@uri)
|
70
71
|
uri.path += "/#{id}" if id
|
71
72
|
|
72
|
-
# req = Net::HTTP::Get.new(co_uri)
|
73
73
|
req = Net::HTTP::Delete.new(uri)
|
74
74
|
req['authorization'] = "Bearer #{o_api_key}"
|
75
75
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
@@ -95,20 +95,23 @@ module Chatopsify
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
# rubocop:disable Lint/TripleQuotes, Style/StringLiterals, Layout/IndentationWidth
|
98
99
|
def msg_fmt(status = nil)
|
99
100
|
"""#{text(status)}
|
100
101
|
| TITLE | CONTENTS |
|
101
102
|
|----------:|:-------------|
|
102
|
-
| Stage | #{fetch(:stage)
|
103
|
-
| Server | #{fetch(:ip_address)
|
103
|
+
| Stage | #{fetch(:stage)&.upcase!} |
|
104
|
+
| Server | #{fetch(:ip_address)}|
|
104
105
|
| Branch | #{fetch(:branch)} |
|
105
106
|
| Revision | #{fetch(:current_revision) || '<empty>'} |
|
106
|
-
| Timestamp | #{Time.now.getlocal(
|
107
|
+
| Timestamp | #{Time.now.getlocal('+07:00') || Time.now} |
|
107
108
|
"""
|
108
109
|
end
|
110
|
+
# rubocop:enable Lint/TripleQuotes, Style/StringLiterals, Layout/IndentationWidth
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
114
|
+
# CoSecurity service
|
112
115
|
class CoSecurity
|
113
116
|
require 'openssl'
|
114
117
|
require 'securerandom'
|
@@ -122,44 +125,40 @@ module Chatopsify
|
|
122
125
|
end
|
123
126
|
|
124
127
|
def encrypt_string
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
false
|
140
|
-
end
|
128
|
+
cipher = OpenSSL::Cipher.new('aes-256-cbc')
|
129
|
+
cipher.encrypt
|
130
|
+
salt = SecureRandom.random_bytes(16)
|
131
|
+
key_iv = OpenSSL::PKCS5.pbkdf2_hmac_sha1(generate_pwd, salt, 2000, cipher.key_len + cipher.iv_len)
|
132
|
+
key = key_iv[0, cipher.key_len]
|
133
|
+
iv = key_iv[cipher.key_len, cipher.iv_len]
|
134
|
+
|
135
|
+
cipher.key = key
|
136
|
+
cipher.iv = iv
|
137
|
+
|
138
|
+
encrypted = cipher.update(@str) + cipher.final
|
139
|
+
(salt + encrypted).unpack1('H*')
|
140
|
+
rescue StandardError => e
|
141
|
+
puts e.message
|
141
142
|
end
|
142
143
|
|
143
144
|
def decrypt_string
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
cipher.decrypt
|
145
|
+
encrypted = [@str].pack('H*')
|
146
|
+
cipher = OpenSSL::Cipher.new('aes-256-cbc')
|
147
|
+
cipher.decrypt
|
148
148
|
|
149
|
-
|
150
|
-
|
149
|
+
salt = encrypted[0, 16]
|
150
|
+
encrypted_data = encrypted[16..]
|
151
151
|
|
152
|
-
|
153
|
-
|
154
|
-
|
152
|
+
key_iv = OpenSSL::PKCS5.pbkdf2_hmac_sha1(generate_pwd, salt, 2000, cipher.key_len + cipher.iv_len)
|
153
|
+
key = key_iv[0, cipher.key_len]
|
154
|
+
iv = key_iv[cipher.key_len, cipher.iv_len]
|
155
155
|
|
156
|
-
|
157
|
-
|
156
|
+
cipher.key = key
|
157
|
+
cipher.iv = iv
|
158
158
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
end
|
159
|
+
cipher.update(encrypted_data) + cipher.final
|
160
|
+
rescue StandardError => e
|
161
|
+
puts e.message
|
163
162
|
end
|
164
163
|
|
165
164
|
private
|
data/lib/chatopsify/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chatopsify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- phunt
|
@@ -30,35 +30,7 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.2.0
|
33
|
-
|
34
|
-
name: bundler
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '2'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '2'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rake
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '1'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '1'
|
61
|
-
description: Publish deployment notifications to ChatOps via the API
|
33
|
+
description: chatopsify = ChatOps + Capistrano notifications via API
|
62
34
|
email:
|
63
35
|
- phunt@runsystem.net
|
64
36
|
executables: []
|
@@ -84,15 +56,13 @@ files:
|
|
84
56
|
- lib/chatopsify/co.rb
|
85
57
|
- lib/chatopsify/version.rb
|
86
58
|
- lib/core_ext/custom_lib.rb
|
87
|
-
- test/
|
59
|
+
- test/chatopsify_test.rb
|
88
60
|
- test/test_helper.rb
|
89
61
|
homepage: https://github.com/papakvy/chatopsify
|
90
62
|
licenses:
|
91
63
|
- MIT
|
92
64
|
metadata:
|
93
65
|
rubygems_mfa_required: 'true'
|
94
|
-
homepage_uri: https://github.com/papakvy/chatopsify
|
95
|
-
source_code_uri: https://github.com/papakvy/chatopsify
|
96
66
|
changelog_uri: https://github.com/papakvy/chatopsify/blob/master/CHANGELOG.md
|
97
67
|
post_install_message:
|
98
68
|
rdoc_options: []
|
File without changes
|