capistrano-ops 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -10
- data/capistrano-ops.gemspec +1 -1
- data/lib/capistrano/ops/notification/api.rb +5 -4
- data/lib/capistrano/ops/notification/slack.rb +2 -1
- data/lib/capistrano/ops/notification/webhook.rb +2 -2
- data/lib/capistrano/ops/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cb665418708dfee77665fa627d54d391f3a7017f71406039f89f590eb6ac3e3
|
4
|
+
data.tar.gz: 1e7fa4c8f246d88b0b31db32e3034e2ff97c56a1c17942364214e8ff88a30fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35abe9b947d8d8518ab000520f10854a2e2d7e87eaaaf26e7e3a6de6bca28ffe40c5e4071e1706d9195612fc14d026e2cd0a65b95fc8c5ae61962c575150e5ec
|
7
|
+
data.tar.gz: 22389fec5aacdd0bb10a0dc6806513ecfa290f540a5aeb541cc2092adcdedc2c370f4299753cbd76276c5405b05b6324686dfa3fb5950e0e7958e6d972689ceb
|
data/README.md
CHANGED
@@ -69,16 +69,17 @@ production:
|
|
69
69
|
|
70
70
|
### Optional Settings for backup task
|
71
71
|
|
72
|
-
| env
|
73
|
-
|
|
74
|
-
| NUMBER_OF_BACKUPS
|
75
|
-
| BACKUPS_ENABLED
|
76
|
-
| DEFAULT_URL
|
77
|
-
| NOTIFICATION_TYPE
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
| env | description | type/options |
|
73
|
+
| ------------------ | ---------------------------------------------------------------------- | :----------------------------------------------------------------: |
|
74
|
+
| NUMBER_OF_BACKUPS | number of backups to keep (default: 1) | `number` |
|
75
|
+
| BACKUPS_ENABLED | enable/disable backup task (default: Rails.env == 'production') | `boolean` |
|
76
|
+
| DEFAULT_URL | notification message title (default: "#{database} Backup") | `string` |
|
77
|
+
| NOTIFICATION_TYPE | for notification (default: nil) | `string` (`webhook`/`slack`) |
|
78
|
+
| NOTIFICATION_LEVEL | for notification (default: nil) | `string` (`info`/`error`) |
|
79
|
+
| SLACK_SECRET | for slack integration | `string` (e.g. `xoxb-1234567890-1234567890-1234567890-1234567890`) |
|
80
|
+
| SLACK_CHANNEL | for slack integration | `string` (e.g. `C234567890`) |
|
81
|
+
| WEBHOOK_URL | Webhook server to send message | e.g `http://example.com` |
|
82
|
+
| WEBHOOK_SECRET | Secret to send with uses md5-hmac hexdigest in header`x-hub-signature` | --- |
|
82
83
|
|
83
84
|
### use with whenever/capistrano
|
84
85
|
|
@@ -135,6 +136,14 @@ WEBHOOK_URL: '<your-webhook-url>'
|
|
135
136
|
WEBHOOK_SECRET: '<your-webhook-secret>'
|
136
137
|
```
|
137
138
|
|
139
|
+
## Notification level
|
140
|
+
|
141
|
+
if you want to use notification level you have to add this to your `application.yml`
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
NOTIFICATION_LEVEL: 'info' # default is 'error'
|
145
|
+
```
|
146
|
+
|
138
147
|
## Contributing
|
139
148
|
|
140
149
|
1. Fork it ( https://github.com/zauberware/capistrano-ops/fork )
|
data/capistrano-ops.gemspec
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
module Notification
|
2
2
|
class Api
|
3
|
-
attr_accessor :notification_type
|
3
|
+
attr_accessor :notification_type, :notification_level
|
4
4
|
|
5
|
-
def initialize(notification_type: ENV['NOTIFICATION_TYPE'])
|
5
|
+
def initialize(notification_type: ENV['NOTIFICATION_TYPE'], notification_level: ENV['NOTIFICATION_LEVEL'])
|
6
6
|
self.notification_type = notification_type
|
7
|
+
self.notification_level = notification_level || 'error'
|
7
8
|
end
|
8
9
|
|
9
10
|
def send_backup_notification(result, date, database, backup_path)
|
10
11
|
return if notification_type.nil?
|
11
12
|
case notification_type
|
12
13
|
when 'slack'
|
13
|
-
Slack.new.backup_notification(result, date, database, backup_path)
|
14
|
+
Slack.new.backup_notification(result, date, database, backup_path, notification_level)
|
14
15
|
when 'webhook'
|
15
|
-
Webhook.new.backup_notification(result, date, database, backup_path)
|
16
|
+
Webhook.new.backup_notification(result, date, database, backup_path, notification_level)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -23,8 +23,9 @@ module Notification
|
|
23
23
|
puts response.body
|
24
24
|
end
|
25
25
|
|
26
|
-
def backup_notification(result, date, database, backup_path)
|
26
|
+
def backup_notification(result, date, database, backup_path, notification_level)
|
27
27
|
return if @slack_secret.nil? || @slack_channel.nil?
|
28
|
+
return if notification_level == 'error' && result
|
28
29
|
uri = URI.parse("#{@slack_base_url}chat.postMessage")
|
29
30
|
http = Net::HTTP.new(uri.host, uri.port)
|
30
31
|
http.use_ssl = true
|
@@ -15,9 +15,9 @@ module Notification
|
|
15
15
|
"md5=#{OpenSSL::HMAC.hexdigest('md5', ENV['WEBHOOK_SECRET'], payload_body)}"
|
16
16
|
end
|
17
17
|
|
18
|
-
def backup_notification(result, date, database, backup_path)
|
18
|
+
def backup_notification(result, date, database, backup_path, notification_level)
|
19
19
|
return if @webhook_url.nil? || @secret.nil?
|
20
|
-
|
20
|
+
return if result && ENV['NOTIFICATION_LEVEL'] == 'error'
|
21
21
|
data = {
|
22
22
|
domain: ENV['DEFAULT_URL'] || "#{database} Backup",
|
23
23
|
backupPath: result ? backup_path : nil,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-ops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Crusius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 4.2.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 7.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 4.2.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 7.0.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: nokogiri
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +50,14 @@ dependencies:
|
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
53
|
+
version: 2.4.15
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
60
|
+
version: 2.4.15
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rake
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
125
|
- !ruby/object:Gem::Version
|
120
126
|
version: '0'
|
121
127
|
requirements: []
|
122
|
-
rubygems_version: 3.1.
|
128
|
+
rubygems_version: 3.1.2
|
123
129
|
signing_key:
|
124
130
|
specification_version: 4
|
125
131
|
summary: devops tasks for rails applications
|