class Fastlane::Actions::AddItemToKeychainAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/secret_keeper/actions/add_item_to_keychain_action.rb, line 29
def self.authors
  ["Daniel Jankowski"]
end
available_options() click to toggle source
# 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
description() click to toggle source
# 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) click to toggle source
# File lib/fastlane/plugin/secret_keeper/actions/add_item_to_keychain_action.rb, line 54
def self.is_supported?(platform)
  true
end
return_value() click to toggle source
# 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) click to toggle source
# File lib/fastlane/plugin/secret_keeper/actions/add_item_to_keychain_action.rb, line 6
def self.run(params)
  item_name = params[:item_name]
  account_name = params[:account_name]
  password = params[:password]

  success = Security::InternetPassword.add(item_name, account_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