eco-rake 0.2.16 → 0.2.18
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/.gitignore +1 -0
- data/CHANGELOG.md +16 -1
- data/lib/eco-rake/lib/export/payload.rb +70 -18
- data/lib/eco-rake/lib/files/decrypt.rb +1 -1
- data/lib/eco-rake/lib/people/sync_launch.rb +9 -2
- data/lib/eco-rake/lib/people/sync_process.rb +9 -1
- data/lib/eco-rake/shell/files.rb +2 -2
- data/lib/eco-rake/shell/gpg.rb +10 -6
- data/lib/eco-rake/utils/mailing.rb +13 -5
- data/lib/eco-rake/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7876dd36735ea99fcb006628a2f8fe2c49c05115befe40f64ac82337a9851b29
|
4
|
+
data.tar.gz: 17042f197a6535f2f33f2ebc0ff3de57d0628c4eef561340e443c1a43f7d5c3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3932c8e52dc30e19b2f12292fe6349974a33136622a6ba4165e2e8c2096b9bffbabca76f8c50fa1373101a9180c179e58d8866cc82559b2340a373620c66251
|
7
|
+
data.tar.gz: 1afc961abec0938ea8d4007cb644d7adb8ec21b01f166769e75ed7458f50441777763cb49f1c299ab31a23673770aedb814120d8564adcc3af98570aca5e4ffe
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [0.2.
|
5
|
+
## [0.2.18] - 2025-03-xx
|
6
6
|
|
7
7
|
### Added
|
8
8
|
|
@@ -10,6 +10,21 @@ All notable changes to this project will be documented in this file.
|
|
10
10
|
|
11
11
|
### Fixed
|
12
12
|
|
13
|
+
## [0.2.18] - 2025-03-22
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- Command invocation cases on `Export::Payload` related tasks.
|
18
|
+
|
19
|
+
## [0.2.17] - 2025-03-22
|
20
|
+
|
21
|
+
### Added
|
22
|
+
|
23
|
+
- `space` to mailing.
|
24
|
+
- Export `payload` notify
|
25
|
+
- On error
|
26
|
+
- On success
|
27
|
+
|
13
28
|
## [0.2.16] - 2025-03-11
|
14
29
|
|
15
30
|
### Fixed
|
@@ -1,39 +1,58 @@
|
|
1
1
|
# Use case for special integrations. It requires some use cases to be present
|
2
|
-
# 1. `-
|
3
|
-
# 2. `-
|
4
|
-
# 3. `-
|
5
|
-
# 4. `-
|
2
|
+
# 1. `-extract-select-options`
|
3
|
+
# 2. `-extract-registers`
|
4
|
+
# 3. `-extract-pack`
|
5
|
+
# 4. `-extract-sftp-push`
|
6
6
|
require 'optparse/time'
|
7
7
|
class EcoRake
|
8
8
|
module Lib
|
9
9
|
module Export
|
10
10
|
class Payload < EcoRake::Lib::BaseTask
|
11
|
-
INCLUDED_OPTIONS = %i[csv simulate].freeze
|
11
|
+
INCLUDED_OPTIONS = %i[csv simulate no_email].freeze
|
12
12
|
FORWARD_RULES = {
|
13
|
-
enviro: ->(enviro) { "-#{enviro}"
|
14
|
-
space: ->(space)
|
13
|
+
enviro: ->(enviro) { "-#{enviro}" },
|
14
|
+
space: ->(space) { "-space #{space}" },
|
15
15
|
simulate: '-simulate',
|
16
|
+
no_email: '-no-email',
|
16
17
|
csv: '-csv',
|
17
18
|
full: ->(full) { full ? nil : '-delta' },
|
18
19
|
asat: ->(asat) { "-asatdate #{asat}" }
|
19
20
|
}.freeze
|
20
21
|
|
22
|
+
attr_const :mail_to
|
23
|
+
|
21
24
|
options_with_defaults true
|
22
25
|
option '-s', '--simulate', TrueClass, 'Do a dry-run (with no changes)'
|
23
|
-
|
24
|
-
|
25
|
-
option '-
|
26
|
-
|
27
|
-
|
26
|
+
|
27
|
+
str_desc = 'Target environment to run against (i.e. org, live)'
|
28
|
+
option '-e', '--enviro ENVIRO', String, desc: str_desc, required: true # , default_lookup: :default_enviro
|
29
|
+
|
30
|
+
str_desc = 'Target space of the envionment (i.e. uat)'
|
31
|
+
option '-w', '--space SPACE', String, desc: str_desc
|
32
|
+
|
33
|
+
str_desc = 'If the PAYLOAD file is a full file (false: means delta)'
|
34
|
+
option '-f', '--[no-]full', TrueClass, default: false, desc: str_desc
|
35
|
+
|
36
|
+
str_desc = 'Generate files in csv format?'
|
37
|
+
option '-c', '--csv', TrueClass, default: true, desc: str_desc
|
38
|
+
|
39
|
+
str_desc = 'Specifies the date when the export was done (default: now).'
|
40
|
+
option '-a', '--asat [DATE]', Time, default: Time.now.iso8601, desc: str_desc do |value|
|
28
41
|
value&.iso8601
|
29
42
|
end
|
30
43
|
|
44
|
+
option '-m', '--no-email', FalseClass, desc: 'Do not notify'
|
45
|
+
|
31
46
|
option_forwarding(**FORWARD_RULES)
|
32
47
|
|
33
48
|
def task(*_args)
|
34
|
-
sh_chain(commands) do |ok,
|
35
|
-
|
49
|
+
sh_chain(commands) do |ok, res|
|
50
|
+
next if ok
|
51
|
+
|
52
|
+
error_notify!(res)
|
36
53
|
end
|
54
|
+
|
55
|
+
success_notify
|
37
56
|
end
|
38
57
|
|
39
58
|
private
|
@@ -48,19 +67,19 @@ class EcoRake
|
|
48
67
|
end
|
49
68
|
|
50
69
|
def export_select_options
|
51
|
-
forward_command('-
|
70
|
+
forward_command('-extract-select-options')
|
52
71
|
end
|
53
72
|
|
54
73
|
def export_registers
|
55
|
-
forward_command('-
|
74
|
+
forward_command('-extract-registers')
|
56
75
|
end
|
57
76
|
|
58
77
|
def export_pack
|
59
|
-
forward_command('-
|
78
|
+
forward_command('-extract-pack', :full, :asat)
|
60
79
|
end
|
61
80
|
|
62
81
|
def export_sftp_push
|
63
|
-
|
82
|
+
forward_command('-extract-sftp-push')
|
64
83
|
end
|
65
84
|
|
66
85
|
def forward_command(use, *opts)
|
@@ -81,6 +100,39 @@ class EcoRake
|
|
81
100
|
use
|
82
101
|
)
|
83
102
|
end
|
103
|
+
|
104
|
+
def success_notify
|
105
|
+
return if options[:simulate]
|
106
|
+
return if options[:no_email]
|
107
|
+
return unless (inbox = mail_to)
|
108
|
+
|
109
|
+
email(
|
110
|
+
subject: "Payload pushed",
|
111
|
+
to: inbox,
|
112
|
+
body: 'The data extract has been correctly pushed.',
|
113
|
+
enviro: options[:enviro],
|
114
|
+
space: options[:space]
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
118
|
+
def error_notify!(res)
|
119
|
+
msg = res.to_s
|
120
|
+
puts msg
|
121
|
+
|
122
|
+
exit 1 if options[:simulate]
|
123
|
+
exit 1 if options[:no_email]
|
124
|
+
exit 1 unless (inbox = mail_to)
|
125
|
+
|
126
|
+
email(
|
127
|
+
subject: "Error exporting payload",
|
128
|
+
to: inbox,
|
129
|
+
body: 'Could not push latest extract.',
|
130
|
+
enviro: options[:enviro],
|
131
|
+
space: options[:space]
|
132
|
+
)
|
133
|
+
|
134
|
+
exit 1
|
135
|
+
end
|
84
136
|
end
|
85
137
|
end
|
86
138
|
end
|
@@ -63,7 +63,12 @@ class EcoRake
|
|
63
63
|
exit 1 if options[:no_email]
|
64
64
|
exit 1 unless (inbox = mail_to)
|
65
65
|
|
66
|
-
email_missing_files(
|
66
|
+
email_missing_files(
|
67
|
+
to: inbox,
|
68
|
+
enviro: target_enviro,
|
69
|
+
space: options[:space]
|
70
|
+
)
|
71
|
+
|
67
72
|
exit 1
|
68
73
|
end
|
69
74
|
|
@@ -156,7 +161,9 @@ class EcoRake
|
|
156
161
|
deleted << file
|
157
162
|
end
|
158
163
|
|
159
|
-
|
164
|
+
return if deleted_files.empty?
|
165
|
+
|
166
|
+
puts "Deleted these files:\n • #{deleted_files.join("\n • ")}"
|
160
167
|
end
|
161
168
|
end
|
162
169
|
end
|
@@ -66,11 +66,19 @@ class EcoRake
|
|
66
66
|
def failed_decryption_notify
|
67
67
|
msg = 'File decryption failed'
|
68
68
|
puts msg
|
69
|
+
|
69
70
|
exit 1 if options[:simulate]
|
70
71
|
exit 1 if options[:no_email]
|
71
72
|
exit 1 unless (inbox = mail_to)
|
72
73
|
|
73
|
-
email(
|
74
|
+
email(
|
75
|
+
to: inbox,
|
76
|
+
subject: msg,
|
77
|
+
body: msg,
|
78
|
+
enviro: target_enviro,
|
79
|
+
space: options[:space]
|
80
|
+
)
|
81
|
+
|
74
82
|
exit 1
|
75
83
|
end
|
76
84
|
end
|
data/lib/eco-rake/shell/files.rb
CHANGED
@@ -65,9 +65,9 @@ class EcoRake
|
|
65
65
|
# and changes its extension to `csv`.
|
66
66
|
# @return [String]
|
67
67
|
def gpg_to_csv_filename(gpg_file)
|
68
|
-
return
|
68
|
+
return unless gpg_file
|
69
69
|
|
70
|
-
ext = gpg_file.split('.')[1
|
70
|
+
ext = gpg_file.split('.')[1..].join('.')
|
71
71
|
base = File.basename(gpg_file, ".#{ext}")
|
72
72
|
folder = File.dirname(gpg_file)
|
73
73
|
File.join(folder, "#{base}.csv")
|
data/lib/eco-rake/shell/gpg.rb
CHANGED
@@ -13,16 +13,20 @@ class EcoRake
|
|
13
13
|
# is different. This is the reason why we check what is the option for a `loopback`
|
14
14
|
# @param gpg_file [String] the file meant to be decrypted.
|
15
15
|
# @return [String] the command to decrypt `gpg_file`
|
16
|
-
def decrypt_command(gpg_file, gpg_key: ENV[
|
16
|
+
def decrypt_command(gpg_file, gpg_key: ENV['GPG_KEY'], ignore_mdc_error: false)
|
17
17
|
csv_file = gpg_to_csv_filename(gpg_file)
|
18
18
|
no_error = ignore_mdc_error ? '--ignore-mdc-error' : nil
|
19
|
-
|
19
|
+
|
20
|
+
loopback = '--batch --yes'
|
21
|
+
loopback = '--pinentry-mode=loopback' if gpg_version_gte?(major: 2, minor: 1)
|
22
|
+
|
20
23
|
args = [
|
21
24
|
no_error, loopback,
|
22
25
|
'--passphrase', double_quote(gpg_key),
|
23
26
|
'-o', double_quote(csv_file),
|
24
27
|
'-d', double_quote(gpg_file)
|
25
28
|
]
|
29
|
+
|
26
30
|
string_cmd('gpg', *args)
|
27
31
|
end
|
28
32
|
|
@@ -37,10 +41,10 @@ class EcoRake
|
|
37
41
|
# @note the versioning format is `MAJOR.MINOR.PATCH`
|
38
42
|
# @example if the host has this gpg version: `gpg (GnuPG) 2.1.10`. The following is to be expected:
|
39
43
|
# 1. `gpg_version_gte?(major: 1, minor: 10)` return `true`
|
40
|
-
# 2. `gpg_version_gte?(major: 3, minor: 0)`
|
41
|
-
# 3. `gpg_version_gte?(major: 2, minor: 0)`
|
42
|
-
# 4. `gpg_version_gte?(major: 2, minor: 1)`
|
43
|
-
# 5. `gpg_version_gte?(major: 2, minor: 3)`
|
44
|
+
# 2. `gpg_version_gte?(major: 3, minor: 0)` return `false`
|
45
|
+
# 3. `gpg_version_gte?(major: 2, minor: 0)` return `true`
|
46
|
+
# 4. `gpg_version_gte?(major: 2, minor: 1)` return `true`
|
47
|
+
# 5. `gpg_version_gte?(major: 2, minor: 3)` return `false`
|
44
48
|
# @return [Boolean]
|
45
49
|
def gpg_version_gte?(major:, minor:)
|
46
50
|
result = shell_gpg_version
|
@@ -6,9 +6,15 @@ class EcoRake
|
|
6
6
|
@mailer ||= EcoRake::Utils::Mailer.new
|
7
7
|
end
|
8
8
|
|
9
|
-
def email(subject:, body:, to:, enviro: nil)
|
9
|
+
def email(subject:, body:, to:, enviro: nil, space: nil)
|
10
10
|
has_enviro = enviro && subject&.downcase&.include?(enviro.downcase)
|
11
|
-
|
11
|
+
|
12
|
+
if enviro && !has_enviro
|
13
|
+
env_str = enviro.upcase
|
14
|
+
env_str << " (space: #{space})" if space
|
15
|
+
subject = "#{env_str} - #{subject}"
|
16
|
+
end
|
17
|
+
|
12
18
|
mailer.mail(
|
13
19
|
to: to,
|
14
20
|
subject: subject,
|
@@ -17,11 +23,13 @@ class EcoRake
|
|
17
23
|
end
|
18
24
|
|
19
25
|
# Helper to notify that there are no files to be processed
|
20
|
-
def email_missing_files(enviro:, to:)
|
26
|
+
def email_missing_files(enviro:, to:, space: nil)
|
21
27
|
email(
|
22
28
|
to: to,
|
23
|
-
subject: "
|
24
|
-
body: 'No files found to be processed. Aborting...'
|
29
|
+
subject: "No files to be processed",
|
30
|
+
body: 'No files found to be processed. Aborting...',
|
31
|
+
enviro: enviro,
|
32
|
+
space: space
|
25
33
|
)
|
26
34
|
end
|
27
35
|
end
|
data/lib/eco-rake/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura Samper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|