fastlane 2.108.0 → 2.109.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +76 -76
- data/deliver/lib/deliver/app_screenshot.rb +22 -1
- data/fastlane/lib/fastlane/action_collector.rb +1 -22
- data/fastlane/lib/fastlane/actions/appetize.rb +20 -3
- data/fastlane/lib/fastlane/actions/docs/build_ios_app.md +12 -9
- data/fastlane/lib/fastlane/actions/pod_lib_lint.rb +25 -16
- data/fastlane/lib/fastlane/actions/pod_push.rb +1 -1
- data/fastlane/lib/fastlane/actions/puts.rb +1 -1
- data/fastlane/lib/fastlane/actions/set_github_release.rb +1 -0
- data/fastlane/lib/fastlane/actions/testfairy.rb +11 -5
- data/fastlane/lib/fastlane/fast_file.rb +9 -6
- data/fastlane/lib/fastlane/helper/adb_helper.rb +3 -3
- data/fastlane/lib/fastlane/helper/crashlytics_helper.rb +5 -5
- data/fastlane/lib/fastlane/version.rb +1 -1
- data/fastlane/swift/Deliverfile.swift +1 -1
- data/fastlane/swift/Fastlane.swift +16 -6
- data/fastlane/swift/Gymfile.swift +1 -1
- data/fastlane/swift/Matchfile.swift +1 -1
- data/fastlane/swift/Precheckfile.swift +1 -1
- data/fastlane/swift/Scanfile.swift +1 -1
- data/fastlane/swift/Screengrabfile.swift +1 -1
- data/fastlane/swift/Snapshotfile.swift +1 -1
- data/fastlane_core/lib/fastlane_core.rb +0 -1
- data/fastlane_core/lib/fastlane_core/configuration/configuration.rb +2 -2
- data/fastlane_core/lib/fastlane_core/project.rb +9 -11
- data/match/lib/match/encryption.rb +33 -9
- data/match/lib/match/runner.rb +15 -3
- data/match/lib/match/spaceship_ensure.rb +2 -5
- data/match/lib/match/storage.rb +29 -7
- data/match/lib/match/storage/git_storage.rb +30 -48
- data/match/lib/match/storage/interface.rb +39 -1
- data/precheck/lib/precheck/rules/other_platforms_rule.rb +4 -1
- data/scan/lib/scan/error_handler.rb +8 -1
- data/sigh/lib/assets/resign.sh +39 -63
- data/snapshot/lib/snapshot/reports_generator.rb +1 -0
- data/spaceship/lib/spaceship/client.rb +174 -58
- data/spaceship/lib/spaceship/commands_generator.rb +1 -0
- data/spaceship/lib/spaceship/du/du_client.rb +18 -12
- data/spaceship/lib/spaceship/spaceauth_runner.rb +1 -1
- data/spaceship/lib/spaceship/tunes/app_submission.rb +2 -1
- data/spaceship/lib/spaceship/tunes/device_type.rb +1 -1
- data/spaceship/lib/spaceship/tunes/tunes_client.rb +5 -2
- data/spaceship/lib/spaceship/{two_step_client.rb → two_step_or_factor_client.rb} +65 -96
- data/supply/lib/supply/options.rb +17 -3
- data/supply/lib/supply/uploader.rb +12 -5
- metadata +17 -19
- data/deliver/lib/deliver/.app_screenshot.rb.swp +0 -0
- data/fastlane_core/lib/fastlane_core/tool_collector.rb +0 -304
@@ -17,6 +17,11 @@ module Fastlane
|
|
17
17
|
command << "--sources='#{sources}'"
|
18
18
|
end
|
19
19
|
|
20
|
+
if params[:swift_version]
|
21
|
+
swift_version = params[:swift_version]
|
22
|
+
command << "--swift-version=#{swift_version}"
|
23
|
+
end
|
24
|
+
|
20
25
|
if params[:allow_warnings]
|
21
26
|
command << "--allow-warnings"
|
22
27
|
end
|
@@ -46,25 +51,29 @@ module Fastlane
|
|
46
51
|
def self.available_options
|
47
52
|
[
|
48
53
|
FastlaneCore::ConfigItem.new(key: :use_bundle_exec,
|
49
|
-
|
50
|
-
|
51
|
-
|
54
|
+
description: "Use bundle exec when there is a Gemfile presented",
|
55
|
+
is_string: false,
|
56
|
+
default_value: true),
|
52
57
|
FastlaneCore::ConfigItem.new(key: :verbose,
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
description: "Allow output detail in console",
|
59
|
+
optional: true,
|
60
|
+
is_string: false),
|
56
61
|
FastlaneCore::ConfigItem.new(key: :allow_warnings,
|
57
|
-
|
58
|
-
|
59
|
-
|
62
|
+
description: "Allow warnings during pod lint",
|
63
|
+
optional: true,
|
64
|
+
is_string: false),
|
60
65
|
FastlaneCore::ConfigItem.new(key: :sources,
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
description: "The sources of repos you want the pod spec to lint with, separated by commas",
|
67
|
+
optional: true,
|
68
|
+
is_string: false,
|
69
|
+
type: Array,
|
70
|
+
verify_block: proc do |value|
|
71
|
+
UI.user_error!("Sources must be an array.") unless value.kind_of?(Array)
|
72
|
+
end),
|
73
|
+
FastlaneCore::ConfigItem.new(key: :swift_version,
|
74
|
+
description: "The SWIFT_VERSION that should be used to lint the spec. This takes precedence over a .swift-version file",
|
75
|
+
optional: true,
|
76
|
+
is_string: true),
|
68
77
|
FastlaneCore::ConfigItem.new(key: :use_libraries,
|
69
78
|
description: "Lint uses static libraries to install the spec",
|
70
79
|
is_string: false,
|
@@ -87,7 +87,7 @@ module Fastlane
|
|
87
87
|
FastlaneCore::ConfigItem.new(key: :swift_version,
|
88
88
|
description: "The SWIFT_VERSION that should be used to lint the spec. This takes precedence over a .swift-version file",
|
89
89
|
optional: true,
|
90
|
-
is_string:
|
90
|
+
is_string: true),
|
91
91
|
FastlaneCore::ConfigItem.new(key: :verbose,
|
92
92
|
description: "Show more debugging information",
|
93
93
|
optional: true,
|
@@ -218,6 +218,7 @@ module Fastlane
|
|
218
218
|
description: "Path to assets to be uploaded with the release",
|
219
219
|
optional: true,
|
220
220
|
is_string: false,
|
221
|
+
type: Array,
|
221
222
|
verify_block: proc do |value|
|
222
223
|
UI.user_error!("upload_assets must be an Array of paths to assets") unless value.kind_of?(Array)
|
223
224
|
end)
|
@@ -5,7 +5,7 @@ module Fastlane
|
|
5
5
|
end
|
6
6
|
|
7
7
|
class TestfairyAction < Action
|
8
|
-
def self.upload_build(upload_url, ipa, options)
|
8
|
+
def self.upload_build(upload_url, ipa, options, timeout)
|
9
9
|
require 'faraday'
|
10
10
|
require 'faraday_middleware'
|
11
11
|
|
@@ -29,6 +29,7 @@ module Fastlane
|
|
29
29
|
|
30
30
|
begin
|
31
31
|
connection.post do |req|
|
32
|
+
req.options.timeout = timeout
|
32
33
|
req.url("/api/upload/")
|
33
34
|
req.body = options
|
34
35
|
end
|
@@ -66,9 +67,9 @@ module Fastlane
|
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
69
|
-
# Rejecting key `upload_url` as we don't need it in options
|
70
|
+
# Rejecting key `upload_url` and `timeout` as we don't need it in options
|
70
71
|
client_options = Hash[params.values.reject do |key, value|
|
71
|
-
|
72
|
+
[:upload_url, :timeout].include?(key)
|
72
73
|
end.map do |key, value|
|
73
74
|
case key
|
74
75
|
when :api_key
|
@@ -101,7 +102,7 @@ module Fastlane
|
|
101
102
|
|
102
103
|
return path if Helper.test?
|
103
104
|
|
104
|
-
response = self.upload_build(params[:upload_url], path, client_options)
|
105
|
+
response = self.upload_build(params[:upload_url], path, client_options, params[:timeout])
|
105
106
|
if parse_response(response)
|
106
107
|
UI.success("Build URL: #{Actions.lane_context[SharedValues::TESTFAIRY_BUILD_URL]}")
|
107
108
|
UI.success("Build successfully uploaded to TestFairy.")
|
@@ -221,7 +222,12 @@ module Fastlane
|
|
221
222
|
type: Array,
|
222
223
|
env_name: "FL_TESTFAIRY_OPTIONS",
|
223
224
|
description: "Array of options (shake,video_only_wifi,anonymous)",
|
224
|
-
default_value: [])
|
225
|
+
default_value: []),
|
226
|
+
FastlaneCore::ConfigItem.new(key: :timeout,
|
227
|
+
env_name: "FL_TESTFAIRY_TIMEOUT",
|
228
|
+
description: "Request timeout in seconds",
|
229
|
+
type: Integer,
|
230
|
+
optional: true)
|
225
231
|
]
|
226
232
|
end
|
227
233
|
|
@@ -56,9 +56,14 @@ module Fastlane
|
|
56
56
|
eval(data, parsing_binding, relative_path) # using eval is ok for this case
|
57
57
|
# rubocop:enable Security/Eval
|
58
58
|
rescue SyntaxError => ex
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
match = ex.to_s.match(/#{Regexp.escape(relative_path)}:(\d+)/)
|
60
|
+
if match
|
61
|
+
line = match[1]
|
62
|
+
UI.content_error(data, line)
|
63
|
+
UI.user_error!("Syntax error in your Fastfile on line #{line}: #{ex}")
|
64
|
+
else
|
65
|
+
UI.user_error!("Syntax error in your Fastfile: #{ex}")
|
66
|
+
end
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
@@ -201,9 +206,7 @@ module Fastlane
|
|
201
206
|
end
|
202
207
|
|
203
208
|
def generated_fastfile_id(id)
|
204
|
-
|
205
|
-
# generate as part of an automated process.
|
206
|
-
ENV['GENERATED_FASTFILE_ID'] = id
|
209
|
+
UI.important("The `generated_fastfile_id` action was deprecated, you can remove the line from your `Fastfile`")
|
207
210
|
end
|
208
211
|
|
209
212
|
def import(path = nil)
|
@@ -18,7 +18,7 @@ module Fastlane
|
|
18
18
|
def initialize(adb_path: nil)
|
19
19
|
android_home = ENV['ANDROID_HOME'] || ENV['ANDROID_SDK_ROOT'] || ENV['ANDROID_SDK']
|
20
20
|
if (adb_path.nil? || adb_path == "adb") && android_home
|
21
|
-
adb_path =
|
21
|
+
adb_path = File.join(android_home, "platform-tools", "adb")
|
22
22
|
end
|
23
23
|
self.adb_path = adb_path
|
24
24
|
end
|
@@ -26,7 +26,7 @@ module Fastlane
|
|
26
26
|
# Run a certain action
|
27
27
|
def trigger(command: nil, serial: nil)
|
28
28
|
android_serial = serial != "" ? "ANDROID_SERIAL=#{serial}" : nil
|
29
|
-
command = [android_serial, adb_path, command].join(" ")
|
29
|
+
command = [android_serial, adb_path.shellescape, command.shellescape].join(" ")
|
30
30
|
Action.sh(command)
|
31
31
|
end
|
32
32
|
|
@@ -38,7 +38,7 @@ module Fastlane
|
|
38
38
|
def load_all_devices
|
39
39
|
self.devices = []
|
40
40
|
|
41
|
-
command = [adb_path, "devices"].join(" ")
|
41
|
+
command = [adb_path.shellescape, "devices"].join(" ")
|
42
42
|
output = Actions.sh(command, log: false)
|
43
43
|
output.split("\n").each do |line|
|
44
44
|
if (result = line.match(/(.*)\tdevice$/))
|
@@ -75,13 +75,13 @@ module Fastlane
|
|
75
75
|
command << "-androidRes ."
|
76
76
|
command << "-apiKey #{params[:api_token]}"
|
77
77
|
command << "-apiSecret #{params[:build_secret]}"
|
78
|
-
command << "-uploadDist
|
79
|
-
command << "-androidManifest
|
78
|
+
command << "-uploadDist #{File.expand_path(params[:apk_path]).shellescape}"
|
79
|
+
command << "-androidManifest #{xml.path.shellescape}"
|
80
80
|
|
81
81
|
# Optional
|
82
|
-
command << "-betaDistributionEmails
|
83
|
-
command << "-betaDistributionReleaseNotesFilePath
|
84
|
-
command << "-betaDistributionGroupAliases
|
82
|
+
command << "-betaDistributionEmails #{params[:emails].shellescape}" if params[:emails]
|
83
|
+
command << "-betaDistributionReleaseNotesFilePath #{File.expand_path(params[:notes_path]).shellescape}" if params[:notes_path]
|
84
|
+
command << "-betaDistributionGroupAliases #{params[:groups].shellescape}" if params[:groups]
|
85
85
|
command << "-betaDistributionNotifications #{(params[:notifications] ? 'true' : 'false')}"
|
86
86
|
|
87
87
|
return command
|
@@ -71,13 +71,15 @@ func appaloosa(binary: String,
|
|
71
71
|
RubyCommand.Argument(name: "description", value: description)])
|
72
72
|
_ = runner.executeCommand(command)
|
73
73
|
}
|
74
|
-
func appetize(
|
74
|
+
func appetize(apiHost: String = "api.appetize.io",
|
75
|
+
apiToken: String,
|
75
76
|
url: String? = nil,
|
76
77
|
platform: String = "ios",
|
77
78
|
path: String? = nil,
|
78
79
|
publicKey: String? = nil,
|
79
80
|
note: String? = nil) {
|
80
|
-
let command = RubyCommand(commandID: "", methodName: "appetize", className: nil, args: [RubyCommand.Argument(name: "
|
81
|
+
let command = RubyCommand(commandID: "", methodName: "appetize", className: nil, args: [RubyCommand.Argument(name: "api_host", value: apiHost),
|
82
|
+
RubyCommand.Argument(name: "api_token", value: apiToken),
|
81
83
|
RubyCommand.Argument(name: "url", value: url),
|
82
84
|
RubyCommand.Argument(name: "platform", value: platform),
|
83
85
|
RubyCommand.Argument(name: "path", value: path),
|
@@ -2399,6 +2401,7 @@ func podLibLint(useBundleExec: Bool = true,
|
|
2399
2401
|
verbose: String? = nil,
|
2400
2402
|
allowWarnings: String? = nil,
|
2401
2403
|
sources: [String]? = nil,
|
2404
|
+
swiftVersion: String? = nil,
|
2402
2405
|
useLibraries: Bool = false,
|
2403
2406
|
failFast: Bool = false,
|
2404
2407
|
`private`: Bool = false,
|
@@ -2407,6 +2410,7 @@ func podLibLint(useBundleExec: Bool = true,
|
|
2407
2410
|
RubyCommand.Argument(name: "verbose", value: verbose),
|
2408
2411
|
RubyCommand.Argument(name: "allow_warnings", value: allowWarnings),
|
2409
2412
|
RubyCommand.Argument(name: "sources", value: sources),
|
2413
|
+
RubyCommand.Argument(name: "swift_version", value: swiftVersion),
|
2410
2414
|
RubyCommand.Argument(name: "use_libraries", value: useLibraries),
|
2411
2415
|
RubyCommand.Argument(name: "fail_fast", value: failFast),
|
2412
2416
|
RubyCommand.Argument(name: "private", value: `private`),
|
@@ -2962,7 +2966,7 @@ func setChangelog(appIdentifier: String,
|
|
2962
2966
|
description: String? = nil,
|
2963
2967
|
isDraft: Bool = false,
|
2964
2968
|
isPrerelease: Bool = false,
|
2965
|
-
uploadAssets: String? = nil) -> [String : String] {
|
2969
|
+
uploadAssets: [String]? = nil) -> [String : String] {
|
2966
2970
|
let command = RubyCommand(commandID: "", methodName: "set_github_release", className: nil, args: [RubyCommand.Argument(name: "repository_name", value: repositoryName),
|
2967
2971
|
RubyCommand.Argument(name: "server_url", value: serverUrl),
|
2968
2972
|
RubyCommand.Argument(name: "api_token", value: apiToken),
|
@@ -3338,6 +3342,7 @@ func supply(packageName: String,
|
|
3338
3342
|
apk: String? = nil,
|
3339
3343
|
apkPaths: [String]? = nil,
|
3340
3344
|
aab: String? = nil,
|
3345
|
+
aabPaths: [String]? = nil,
|
3341
3346
|
skipUploadApk: Bool = false,
|
3342
3347
|
skipUploadAab: Bool = false,
|
3343
3348
|
skipUploadMetadata: Bool = false,
|
@@ -3362,6 +3367,7 @@ func supply(packageName: String,
|
|
3362
3367
|
RubyCommand.Argument(name: "apk", value: apk),
|
3363
3368
|
RubyCommand.Argument(name: "apk_paths", value: apkPaths),
|
3364
3369
|
RubyCommand.Argument(name: "aab", value: aab),
|
3370
|
+
RubyCommand.Argument(name: "aab_paths", value: aabPaths),
|
3365
3371
|
RubyCommand.Argument(name: "skip_upload_apk", value: skipUploadApk),
|
3366
3372
|
RubyCommand.Argument(name: "skip_upload_aab", value: skipUploadAab),
|
3367
3373
|
RubyCommand.Argument(name: "skip_upload_metadata", value: skipUploadMetadata),
|
@@ -3463,7 +3469,8 @@ func testfairy(apiKey: String,
|
|
3463
3469
|
comment: String = "No comment provided",
|
3464
3470
|
autoUpdate: String = "off",
|
3465
3471
|
notify: String = "off",
|
3466
|
-
options: [String] = []
|
3472
|
+
options: [String] = [],
|
3473
|
+
timeout: Int? = nil) {
|
3467
3474
|
let command = RubyCommand(commandID: "", methodName: "testfairy", className: nil, args: [RubyCommand.Argument(name: "api_key", value: apiKey),
|
3468
3475
|
RubyCommand.Argument(name: "ipa", value: ipa),
|
3469
3476
|
RubyCommand.Argument(name: "apk", value: apk),
|
@@ -3474,7 +3481,8 @@ func testfairy(apiKey: String,
|
|
3474
3481
|
RubyCommand.Argument(name: "comment", value: comment),
|
3475
3482
|
RubyCommand.Argument(name: "auto_update", value: autoUpdate),
|
3476
3483
|
RubyCommand.Argument(name: "notify", value: notify),
|
3477
|
-
RubyCommand.Argument(name: "options", value: options)
|
3484
|
+
RubyCommand.Argument(name: "options", value: options),
|
3485
|
+
RubyCommand.Argument(name: "timeout", value: timeout)])
|
3478
3486
|
_ = runner.executeCommand(command)
|
3479
3487
|
}
|
3480
3488
|
func testflight(username: String,
|
@@ -3830,6 +3838,7 @@ func uploadToPlayStore(packageName: String,
|
|
3830
3838
|
apk: String? = nil,
|
3831
3839
|
apkPaths: [String]? = nil,
|
3832
3840
|
aab: String? = nil,
|
3841
|
+
aabPaths: [String]? = nil,
|
3833
3842
|
skipUploadApk: Bool = false,
|
3834
3843
|
skipUploadAab: Bool = false,
|
3835
3844
|
skipUploadMetadata: Bool = false,
|
@@ -3854,6 +3863,7 @@ func uploadToPlayStore(packageName: String,
|
|
3854
3863
|
RubyCommand.Argument(name: "apk", value: apk),
|
3855
3864
|
RubyCommand.Argument(name: "apk_paths", value: apkPaths),
|
3856
3865
|
RubyCommand.Argument(name: "aab", value: aab),
|
3866
|
+
RubyCommand.Argument(name: "aab_paths", value: aabPaths),
|
3857
3867
|
RubyCommand.Argument(name: "skip_upload_apk", value: skipUploadApk),
|
3858
3868
|
RubyCommand.Argument(name: "skip_upload_aab", value: skipUploadAab),
|
3859
3869
|
RubyCommand.Argument(name: "skip_upload_metadata", value: skipUploadMetadata),
|
@@ -4151,4 +4161,4 @@ let screengrabfile: Screengrabfile = Screengrabfile()
|
|
4151
4161
|
let snapshotfile: Snapshotfile = Snapshotfile()
|
4152
4162
|
// Please don't remove the lines below
|
4153
4163
|
// They are used to detect outdated files
|
4154
|
-
// FastlaneRunnerAPIVersion [0.9.
|
4164
|
+
// FastlaneRunnerAPIVersion [0.9.34]
|
@@ -22,7 +22,6 @@ require_relative 'fastlane_core/print_table'
|
|
22
22
|
require_relative 'fastlane_core/project'
|
23
23
|
require_relative 'fastlane_core/device_manager'
|
24
24
|
require_relative 'fastlane_core/ui/ui'
|
25
|
-
require_relative 'fastlane_core/tool_collector'
|
26
25
|
require_relative 'fastlane_core/fastlane_folder'
|
27
26
|
require_relative 'fastlane_core/keychain_importer'
|
28
27
|
require_relative 'fastlane_core/swag'
|
@@ -211,7 +211,7 @@ module FastlaneCore
|
|
211
211
|
# if 'ask' is true and the value is not present, the user will be prompted to provide a value
|
212
212
|
# rubocop:disable Metrics/PerceivedComplexity
|
213
213
|
def fetch(key, ask: true)
|
214
|
-
UI.
|
214
|
+
UI.crash!("Key '#{key}' must be a symbol. Example :app_id.") unless key.kind_of?(Symbol)
|
215
215
|
|
216
216
|
option = verify_options_key!(key)
|
217
217
|
|
@@ -263,7 +263,7 @@ module FastlaneCore
|
|
263
263
|
# Overwrites or sets a new value for a given key
|
264
264
|
# @param key [Symbol] Must be a symbol
|
265
265
|
def set(key, value)
|
266
|
-
UI.
|
266
|
+
UI.crash!("Key '#{key}' must be a symbol. Example :#{key}.") unless key.kind_of?(Symbol)
|
267
267
|
option = option_for_key(key)
|
268
268
|
|
269
269
|
unless option
|
@@ -448,20 +448,18 @@ module FastlaneCore
|
|
448
448
|
if self.workspace?
|
449
449
|
# Find the xcodeproj file, as the information isn't included in the workspace file
|
450
450
|
# We have a reference to the workspace, let's find the xcodeproj file
|
451
|
-
#
|
452
|
-
#
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
end.select do |current_match|
|
451
|
+
# Use Xcodeproj gem here to
|
452
|
+
# * parse the contents.xcworkspacedata XML file
|
453
|
+
# * handle different types (group:, container: etc.) of file references and their paths
|
454
|
+
# for details see https://github.com/CocoaPods/Xcodeproj/blob/e0287156d426ba588c9234bb2a4c824149889860/lib/xcodeproj/workspace/file_reference.rb```
|
455
|
+
|
456
|
+
workspace_dir_path = File.expand_path("..", self.path)
|
457
|
+
file_references_paths = workspace.file_references.map { |fr| fr.absolute_path(workspace_dir_path) }
|
458
|
+
@_project_paths = file_references_paths.select do |current_match|
|
460
459
|
# Xcode workspaces can contain loose files now, so let's filter non-xcodeproj files.
|
461
460
|
current_match.end_with?(".xcodeproj")
|
462
461
|
end.reject do |current_match|
|
463
|
-
# We're not interested in a `Pods` project, as it doesn't contain any relevant
|
464
|
-
# information about code signing
|
462
|
+
# We're not interested in a `Pods` project, as it doesn't contain any relevant information about code signing
|
465
463
|
current_match.end_with?("Pods/Pods.xcodeproj")
|
466
464
|
end
|
467
465
|
|
@@ -3,15 +3,39 @@ require_relative 'encryption/openssl'
|
|
3
3
|
|
4
4
|
module Match
|
5
5
|
module Encryption
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
class << self
|
7
|
+
def backends
|
8
|
+
@backends ||= {
|
9
|
+
"git" => lambda { |params|
|
10
|
+
# OpenSSL is storage agnostic so this maps git_url
|
11
|
+
# to keychain_name for the name of the keychain entry
|
12
|
+
params[:keychain_name] = params[:git_url]
|
13
|
+
return Encryption::OpenSSL.configure(params)
|
14
|
+
}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def register_backend(type: nil, encryption_class: nil, &configurator)
|
19
|
+
UI.user_error!("No type specified for encryption backend") if type.nil?
|
20
|
+
|
21
|
+
normalized_name = type.to_s
|
22
|
+
UI.message("Replacing Match::Encryption backend for type '#{normalized_name}'") if backends.include?(normalized_name)
|
23
|
+
|
24
|
+
if configurator
|
25
|
+
@backends[normalized_name] = configurator
|
26
|
+
elsif encryption_class
|
27
|
+
@backends[normalized_name] = ->(params) { return encryption_class.configure(params) }
|
28
|
+
else
|
29
|
+
UI.user_error!("Specify either a `encryption_class` or a configuration block when registering a encryption backend")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the class to be used for a given `storage_mode`
|
34
|
+
def for_storage_mode(storage_mode, params)
|
35
|
+
configurator = backends[storage_mode.to_s]
|
36
|
+
return configurator.call(params) if configurator
|
37
|
+
|
38
|
+
UI.user_error!("No encryption backend for storage mode '#{storage_mode}'")
|
15
39
|
end
|
16
40
|
end
|
17
41
|
end
|