Class: Fastlane::Actions::ReadItemFromKeychainAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/secret_keeper/actions/read_item_from_keychain_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



23
24
25
# File 'lib/fastlane/plugin/secret_keeper/actions/read_item_from_keychain_action.rb', line 23

def self.authors
  ["Daniel Jankowski"]
end

.available_optionsObject



31
32
33
34
35
36
37
38
39
# File 'lib/fastlane/plugin/secret_keeper/actions/read_item_from_keychain_action.rb', line 31

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :item_name,
                            env_name: "SECRET_KEEPER_ITEM_NAME",
                         description: "Item name for a given password stored in the keychain",
                            optional: false,
                                type: String)
  ]
end

.descriptionObject



19
20
21
# File 'lib/fastlane/plugin/secret_keeper/actions/read_item_from_keychain_action.rb', line 19

def self.description
  "Reads the password from the keychain for a given item"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/fastlane/plugin/secret_keeper/actions/read_item_from_keychain_action.rb', line 41

def self.is_supported?(platform)
  true
end

.return_valueObject



27
28
29
# File 'lib/fastlane/plugin/secret_keeper/actions/read_item_from_keychain_action.rb', line 27

def self.return_value
  "Returns password as a plain text"
end

.run(params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fastlane/plugin/secret_keeper/actions/read_item_from_keychain_action.rb', line 6

def self.run(params)
  item_name = params[:item_name]

  item = Security::InternetPassword.find(server: item_name)
  if item 
    UI.success("Sucessfully read an item from the keychain 🎉")
    return item.password 
  else
    UI.error("Could not read an item from the keychain. Please make sure '#{item_name}' item exists in the keychain ❌")
    return nil
  end
end