capistrano-ops 0.1.9 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb8e87887f388f4832ffa3fcbebfd19b89ec534eb9ab728bdf584eaa85ec5be0
4
- data.tar.gz: de83378b9b7bef0f0f32b11b6ee496b083460653793ede1ebe3951ea89e00e7c
3
+ metadata.gz: 9cb665418708dfee77665fa627d54d391f3a7017f71406039f89f590eb6ac3e3
4
+ data.tar.gz: 1e7fa4c8f246d88b0b31db32e3034e2ff97c56a1c17942364214e8ff88a30fdf
5
5
  SHA512:
6
- metadata.gz: 810d7204931e4db0d8db9fb588812c3f36c3b609a11b1a952708de0eb0aba74244830b481e0a93e57496bd10d49105230b5772eb85eea6a3bdf096b3600a9e4f
7
- data.tar.gz: 5faaa7920c135508dabc373ee792b5e8486984e92c735a1f5a4101a4f7376c81826b34fb36cff026d540bcf09504e4bd37fc55bc18489a0861252fd2b4d7672b
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 | 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
- | SLACK_SECRET | for slack integration | `string` (e.g. `xoxb-1234567890-1234567890-1234567890-1234567890`) |
79
- | SLACK_CHANNEL | for slack integration | `string` (e.g. `C234567890`) |
80
- | WEBHOOK_URL | Webhook server to send message | e.g `http://example.com` |
81
- | WEBHOOK_SECRET | Secret to send with uses md5-hmac hexdigest in header`x-hub-signature` | --- |
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 )
@@ -37,6 +37,6 @@ Gem::Specification.new do |s|
37
37
  s.add_dependency 'nokogiri', '>= 1.11.0'
38
38
  end
39
39
 
40
- s.add_development_dependency 'bundler', '~> 2.3.9'
40
+ s.add_development_dependency 'bundler', '~> 2.4.15'
41
41
  s.add_development_dependency 'rake', '~> 10.0'
42
42
  end
@@ -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,
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Capistrano
3
3
  module Ops
4
- VERSION = '0.1.9'
4
+ VERSION = '0.2.1'
5
5
  end
6
6
  end
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.1.9
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-04-13 00:00:00.000000000 Z
11
+ date: 2023-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 2.3.9
53
+ version: 2.4.15
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 2.3.9
60
+ version: 2.4.15
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.3.26
128
+ rubygems_version: 3.1.2
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: devops tasks for rails applications