Class: Fastlane::Actions::DeleteKeychainAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/delete_keychain.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject


59
60
61
# File 'fastlane/lib/fastlane/actions/delete_keychain.rb', line 59

def self.authors
  ["gin0606", "koenpunt"]
end

.available_optionsObject


33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'fastlane/lib/fastlane/actions/delete_keychain.rb', line 33

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :name,
                                 env_name: "KEYCHAIN_NAME",
                                 description: "Keychain name",
                                 conflicting_options: [:keychain_path],
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :keychain_path,
                                 env_name: "KEYCHAIN_PATH",
                                 description: "Keychain path",
                                 conflicting_options: [:name],
                                 optional: true)
  ]
end

.categoryObject


55
56
57
# File 'fastlane/lib/fastlane/actions/delete_keychain.rb', line 55

def self.category
  :misc
end

.descriptionObject


29
30
31
# File 'fastlane/lib/fastlane/actions/delete_keychain.rb', line 29

def self.description
  "Delete keychains and remove them from the search list"
end

.detailsObject


25
26
27
# File 'fastlane/lib/fastlane/actions/delete_keychain.rb', line 25

def self.details
  "Keychains can be deleted after being created with `create_keychain`"
end

.example_codeObject


48
49
50
51
52
53
# File 'fastlane/lib/fastlane/actions/delete_keychain.rb', line 48

def self.example_code
  [
    'delete_keychain(name: "KeychainName")',
    'delete_keychain(keychain_path: "/keychains/project.keychain")'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:


63
64
65
# File 'fastlane/lib/fastlane/actions/delete_keychain.rb', line 63

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'fastlane/lib/fastlane/actions/delete_keychain.rb', line 6

def self.run(params)
  original = Actions.lane_context[Actions::SharedValues::ORIGINAL_DEFAULT_KEYCHAIN]

  if params[:keychain_path]
    if File.exist?(params[:keychain_path])
      keychain_path = params[:keychain_path]
    else
      UI.user_error!("Unable to find the specified keychain.")
    end
  elsif params[:name]
    keychain_path = FastlaneCore::Helper.keychain_path(params[:name])
  else
    UI.user_error!("You either have to set :name or :keychain_path")
  end

  Fastlane::Actions.sh("security default-keychain -s #{original}", log: false) unless original.nil?
  Fastlane::Actions.sh("security delete-keychain #{keychain_path.shellescape}", log: false)
end