Class: Fastlane::Actions::UnlockKeychainAction
Constant Summary
Fastlane::Action::AVAILABLE_CATEGORIES
Class Method Summary
collapse
action_name, author, lane_context, method_missing, other_action, output, return_value, sample_return_value, sh, step_text
Class Method Details
.add_keychain_to_search_list(keychain_path) ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 31
def self.add_keychain_to_search_list(keychain_path)
keychains = Fastlane::Actions.sh("security list-keychains -d user", log: false).shellsplit
unless keychains.include?(keychain_path)
keychains << keychain_path
Fastlane::Actions.sh("security list-keychains -s #{keychains.shelljoin}", log: false)
end
end
|
.authors ⇒ Object
106
107
108
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 106
def self.authors
["xfreebird"]
end
|
.available_options ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 82
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_UNLOCK_KEYCHAIN_PATH",
description: "Path to the Keychain file",
optional: false),
FastlaneCore::ConfigItem.new(key: :password,
env_name: "FL_UNLOCK_KEYCHAIN_PASSWORD",
description: "Keychain password",
optional: false),
FastlaneCore::ConfigItem.new(key: :add_to_search_list,
env_name: "FL_UNLOCK_KEYCHAIN_ADD_TO_SEARCH_LIST",
description: "Add to keychain search list",
is_string: false,
default_value: true),
FastlaneCore::ConfigItem.new(key: :set_default,
env_name: "FL_UNLOCK_KEYCHAIN_SET_DEFAULT",
description: "Set as default keychain",
is_string: false,
default_value: false)
]
end
|
.category ⇒ Object
137
138
139
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 137
def self.category
:misc
end
|
.default_keychain(keychain_path) ⇒ Object
48
49
50
51
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 48
def self.default_keychain(keychain_path)
escaped_path = keychain_path.shellescape
Fastlane::Actions.sh("security default-keychain -s #{escaped_path}", log: false)
end
|
.description ⇒ Object
73
74
75
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 73
def self.description
"Unlock a keychain"
end
|
.details ⇒ Object
77
78
79
80
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 77
def self.details
"Unlocks the give keychain file and adds it to the keychain search list\n" \
"Keychains can be replaced with `add_to_search_list: :replace`"
end
|
.example_code ⇒ Object
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 114
def self.example_code
[
'unlock_keychain( # Unlock an existing keychain and add it to the keychain search list
path: "/path/to/KeychainName.keychain",
password: "mysecret"
)',
'unlock_keychain( # By default the keychain is added to the existing. To replace them with the selected keychain you may use `:replace`
path: "/path/to/KeychainName.keychain",
password: "mysecret",
add_to_search_list: :replace # To only add a keychain use `true` or `:add`.
)',
'unlock_keychain( # In addition, the keychain can be selected as a default keychain
path: "/path/to/KeychainName.keychain",
password: "mysecret",
set_default: true
)',
'unlock_keychain( # If the keychain file is located in the standard location `~/Library/Keychains`, then it is sufficient to provide the keychain file name, or file name with its suffix.
path: "KeychainName",
password: "mysecret"
)'
]
end
|
.expand_keychain_path(keychain_path) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 53
def self.expand_keychain_path(keychain_path)
possible_locations = []
possible_locations << keychain_path
possible_locations << "~/Library/Keychains/#{keychain_path}"
possible_locations << "~/Library/Keychains/#{keychain_path}.keychain"
possible_locations.each do |location|
expanded_location = File.expand_path(location)
if File.exist?(expanded_location)
return expanded_location
end
end
UI.user_error!("Could not find the keychain file in: #{possible_locations}")
end
|
.is_supported?(platform) ⇒ Boolean
110
111
112
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 110
def self.is_supported?(platform)
true
end
|
.replace_keychain_in_search_list(keychain_path) ⇒ Object
.run(params) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/fastlane/actions/unlock_keychain.rb', line 4
def self.run(params)
keychain_path = self.expand_keychain_path(params[:path])
add_to_search_list = params[:add_to_search_list]
set_default = params[:set_default]
commands = []
if add_to_search_list == true || add_to_search_list == :add
commands << add_keychain_to_search_list(keychain_path)
elsif add_to_search_list == :replace
commands << replace_keychain_in_search_list(keychain_path)
end
if set_default
commands << default_keychain(keychain_path)
end
escaped_path = keychain_path.shellescape
escaped_password = params[:password].shellescape
commands << Fastlane::Actions.sh("security unlock-keychain -p #{escaped_password} #{escaped_path}", log: false)
commands << Fastlane::Actions.sh("security set-keychain-settings #{escaped_path}", log: false)
commands
end
|