chatopsify 0.0.4 → 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 +15 -11
- data/chatopsify.gemspec +3 -6
- data/lib/capistrano/tasks/chatopsify.cap +18 -6
- data/lib/chatopsify/co.rb +37 -40
- data/lib/chatopsify/version.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +4 -49
- data/lib/chatopsify/co_service.rb +0 -10
- /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
|
+

|
7
|
+
<!--  -->
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -29,19 +30,22 @@ Require the gem in your `Capfile`:
|
|
29
30
|
|
30
31
|
## Configuration
|
31
32
|
|
32
|
-
###
|
33
|
-
|
34
|
-
- Export to your `bash`: `export CHATOPS_API_KEY=xxx`
|
35
|
-
|
36
|
-
- Add to `.env` if you're using `dotenv` gem
|
33
|
+
### Using ENV (or `.env`)
|
37
34
|
|
35
|
+
```bash
|
36
|
+
export CHATOPS_URI='your_chatops_uri'
|
37
|
+
export CHATOPS_API_KEY='your_chatops_api_key'
|
38
|
+
export CHATOPS_CHANNEL_ID='your_channel_id'
|
39
|
+
```
|
38
40
|
|
39
|
-
###
|
41
|
+
### Using `config/deploy`
|
40
42
|
|
41
43
|
```ruby
|
42
44
|
# config/deploy.rb
|
43
45
|
...
|
44
|
-
set :
|
46
|
+
set :chatops_uri, 'your_chatops_uri'
|
47
|
+
set :chatops_api_key, 'your_chatops_api_key'
|
48
|
+
set :chatops_channel_id, 'your_channel_id'
|
45
49
|
...
|
46
50
|
```
|
47
51
|
|
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,9 +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_dependency 'tzinfo', '~> 1.1'
|
35
|
-
spec.add_development_dependency 'bundler', '~> 2'
|
36
|
-
spec.add_development_dependency 'rake', '~> 1'
|
37
34
|
|
38
35
|
# For more information and examples about making a new gem, checkout our
|
39
36
|
# guide at: https://bundler.io/guides/creating_gem.html
|
@@ -1,11 +1,15 @@
|
|
1
1
|
namespace :chatops do
|
2
2
|
desc "Notify ChatOps Started"
|
3
3
|
task :notify_started do
|
4
|
-
# return
|
5
4
|
set :chatops_time_started, Time.now
|
6
5
|
run_locally do
|
7
6
|
if fetch(:chatops_notify_events).include? :started
|
8
|
-
|
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
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -18,7 +22,11 @@ namespace :chatops do
|
|
18
22
|
run_locally do
|
19
23
|
if fetch(:chatops_notify_events).include? :finished
|
20
24
|
info 'Notifying ChatOps of deploy finished'
|
21
|
-
|
25
|
+
begin
|
26
|
+
Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:success))
|
27
|
+
rescue StandardError => e
|
28
|
+
info "ERROR notify_finished: #{e}"
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
@@ -31,7 +39,11 @@ namespace :chatops do
|
|
31
39
|
run_locally do
|
32
40
|
if fetch(:chatops_notify_events).include? :failed
|
33
41
|
info 'Notifying ChatOps of deploy failed'
|
34
|
-
|
42
|
+
begin
|
43
|
+
Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:failed))
|
44
|
+
rescue StandardError => e
|
45
|
+
info "ERROR notify_failed: #{e}"
|
46
|
+
end
|
35
47
|
end
|
36
48
|
end
|
37
49
|
end
|
@@ -51,7 +63,7 @@ namespace :load do
|
|
51
63
|
servers.map{ |e| ["#{e.hostname} (#{e.properties.fetch(:my_property)&.upcase!})"]}.join(', ')
|
52
64
|
}
|
53
65
|
set :chatops_deploy_starting_text, ->{
|
54
|
-
"### :zap: ⎡#{fetch(:application)}⎦ is
|
66
|
+
"### :zap: ⎡#{fetch(:application)}⎦ is being deployed by ⎡*#{fetch(:local_user)}*⎦: Starting •••"
|
55
67
|
}
|
56
68
|
set :chatops_deploy_succeed_text, ->{
|
57
69
|
time_elapsed = Integer(fetch(:chatops_time_finished, 0).to_i - fetch(:chatops_time_started, 0).to_i)
|
@@ -61,7 +73,7 @@ namespace :load do
|
|
61
73
|
set :chatops_deploy_failed_text, ->{
|
62
74
|
time_elapsed = Integer(fetch(:chatops_time_finished, 0).to_i - fetch(:chatops_time_started, 0).to_i)
|
63
75
|
"### :sos: ⎡#{fetch(:application)}⎦ was deployed by ⎡#{fetch(:local_user)}⎦: " \
|
64
|
-
"*failed*
|
76
|
+
"*failed* within **#{time_elapsed}** seconds."
|
65
77
|
}
|
66
78
|
set :chatops_notify_events, [:started, :finished, :failed]
|
67
79
|
end
|
data/lib/chatopsify/co.rb
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
require 'net/http'
|
5
|
-
require 'tzinfo'
|
6
5
|
|
7
6
|
module Chatopsify
|
8
|
-
# ChatOps
|
7
|
+
# ChatOps services
|
9
8
|
class Co
|
10
9
|
def initialize(api_key = nil)
|
11
10
|
@api_key = api_key || load_api_key
|
@@ -25,8 +24,8 @@ module Chatopsify
|
|
25
24
|
puts e.message
|
26
25
|
end
|
27
26
|
|
28
|
-
def
|
29
|
-
|
27
|
+
def call_delete(id = nil)
|
28
|
+
send_delete_request(id)
|
30
29
|
rescue StandardError => e
|
31
30
|
puts e.message
|
32
31
|
end
|
@@ -67,11 +66,10 @@ module Chatopsify
|
|
67
66
|
puts "Response: #{res.code} #{res.body}"
|
68
67
|
end
|
69
68
|
|
70
|
-
def
|
69
|
+
def send_delete_request(id = nil)
|
71
70
|
uri = URI(@uri)
|
72
71
|
uri.path += "/#{id}" if id
|
73
72
|
|
74
|
-
# req = Net::HTTP::Get.new(co_uri)
|
75
73
|
req = Net::HTTP::Delete.new(uri)
|
76
74
|
req['authorization'] = "Bearer #{o_api_key}"
|
77
75
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
@@ -97,20 +95,23 @@ module Chatopsify
|
|
97
95
|
end
|
98
96
|
end
|
99
97
|
|
98
|
+
# rubocop:disable Lint/TripleQuotes, Style/StringLiterals, Layout/IndentationWidth
|
100
99
|
def msg_fmt(status = nil)
|
101
100
|
"""#{text(status)}
|
102
101
|
| TITLE | CONTENTS |
|
103
102
|
|----------:|:-------------|
|
104
|
-
| Stage | #{fetch(:stage)
|
105
|
-
| Server | #{fetch(:ip_address)
|
103
|
+
| Stage | #{fetch(:stage)&.upcase!} |
|
104
|
+
| Server | #{fetch(:ip_address)}|
|
106
105
|
| Branch | #{fetch(:branch)} |
|
107
106
|
| Revision | #{fetch(:current_revision) || '<empty>'} |
|
108
|
-
| Timestamp | #{
|
107
|
+
| Timestamp | #{Time.now.getlocal('+07:00') || Time.now} |
|
109
108
|
"""
|
110
109
|
end
|
110
|
+
# rubocop:enable Lint/TripleQuotes, Style/StringLiterals, Layout/IndentationWidth
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
# CoSecurity service
|
114
115
|
class CoSecurity
|
115
116
|
require 'openssl'
|
116
117
|
require 'securerandom'
|
@@ -124,44 +125,40 @@ module Chatopsify
|
|
124
125
|
end
|
125
126
|
|
126
127
|
def encrypt_string
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
false
|
142
|
-
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
|
143
142
|
end
|
144
143
|
|
145
144
|
def decrypt_string
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
cipher.decrypt
|
145
|
+
encrypted = [@str].pack('H*')
|
146
|
+
cipher = OpenSSL::Cipher.new('aes-256-cbc')
|
147
|
+
cipher.decrypt
|
150
148
|
|
151
|
-
|
152
|
-
|
149
|
+
salt = encrypted[0, 16]
|
150
|
+
encrypted_data = encrypted[16..]
|
153
151
|
|
154
|
-
|
155
|
-
|
156
|
-
|
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]
|
157
155
|
|
158
|
-
|
159
|
-
|
156
|
+
cipher.key = key
|
157
|
+
cipher.iv = iv
|
160
158
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
159
|
+
cipher.update(encrypted_data) + cipher.final
|
160
|
+
rescue StandardError => e
|
161
|
+
puts e.message
|
165
162
|
end
|
166
163
|
|
167
164
|
private
|
data/lib/chatopsify/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -30,49 +30,7 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.2.0
|
33
|
-
|
34
|
-
name: tzinfo
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.1'
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '1.1'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: bundler
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '2'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '2'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: rake
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1'
|
75
|
-
description: Publish deployment notifications to ChatOps via the API
|
33
|
+
description: chatopsify = ChatOps + Capistrano notifications via API
|
76
34
|
email:
|
77
35
|
- phunt@runsystem.net
|
78
36
|
executables: []
|
@@ -96,18 +54,15 @@ files:
|
|
96
54
|
- lib/capistrano/tasks/chatopsify.cap
|
97
55
|
- lib/chatopsify.rb
|
98
56
|
- lib/chatopsify/co.rb
|
99
|
-
- lib/chatopsify/co_service.rb
|
100
57
|
- lib/chatopsify/version.rb
|
101
58
|
- lib/core_ext/custom_lib.rb
|
102
|
-
- test/
|
59
|
+
- test/chatopsify_test.rb
|
103
60
|
- test/test_helper.rb
|
104
61
|
homepage: https://github.com/papakvy/chatopsify
|
105
62
|
licenses:
|
106
63
|
- MIT
|
107
64
|
metadata:
|
108
65
|
rubygems_mfa_required: 'true'
|
109
|
-
homepage_uri: https://github.com/papakvy/chatopsify
|
110
|
-
source_code_uri: https://github.com/papakvy/chatopsify
|
111
66
|
changelog_uri: https://github.com/papakvy/chatopsify/blob/master/CHANGELOG.md
|
112
67
|
post_install_message:
|
113
68
|
rdoc_options: []
|
File without changes
|