Class: Fastlane::Actions::AddItemToKeychainAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



29
30
31
# File 'lib/fastlane/plugin/secret_keeper/actions/add_item_to_keychain_action.rb', line 29

def self.authors
  ["Daniel Jankowski"]
end

.available_optionsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/secret_keeper/actions/add_item_to_keychain_action.rb', line 33

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :item_name,
                            env_name: "SECRET_KEEPER_ITEM_NAME",
                         description: "Item name to be stored in the keychain",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :account_name,
                              env_name: "SECRET_KEEPER_ACCOUNT_NAME",
                          description: "An account name associated with the keychain item",
                              optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :password,
                              env_name: "SECRET_KEEPER_PASSWORD",
                          description: "Password to be stored in the keychain",
                              optional: false,
                              sensitive: true,
                                type: String)
  ]
end

.descriptionObject



21
22
23
# File 'lib/fastlane/plugin/secret_keeper/actions/add_item_to_keychain_action.rb', line 21

def self.description
  "Adds the credentials to the keychain on behalf of the user"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/fastlane/plugin/secret_keeper/actions/add_item_to_keychain_action.rb', line 54

def self.is_supported?(platform)
  true
end

.return_valueObject



25
26
27
# File 'lib/fastlane/plugin/secret_keeper/actions/add_item_to_keychain_action.rb', line 25

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
18
19
# File 'lib/fastlane/plugin/secret_keeper/actions/add_item_to_keychain_action.rb', line 6

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

  success = Security::InternetPassword.add(item_name, , password)
  if success 
    UI.success("Sucessfully added new item to the keychain 🎉")
    return password
  else
    UI.error("Could not store password in keychain ❌")
    UI.user_error!("Could not store password in the keychain. This can happen if the item you are trying to store already exists in the keychain.")
  end
end