class Fastlane::Actions::SetKeyPartitionListAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/provisioning/actions/set_key_partition_list_action.rb, line 33
def self.authors
  ["paweljankowski"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/provisioning/actions/set_key_partition_list_action.rb, line 41
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :path,
                            env_name: "KEYCHAIN_PATH",
                         description: "Path to the keychain",
                            optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :name,
                            env_name: "KEYCHAIN_NAME",
                         description: "Name of the keychain",
                            optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :password,
                            env_name: "KEYCHAIN_PASSWORD",
                         description: "Password to the keychain",
                            optional: false,
                                type: String)
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/provisioning/actions/set_key_partition_list_action.rb, line 29
def self.description
  "Sets key partition list (required by macOS Sierra)"
end
details() click to toggle source
# File lib/fastlane/plugin/provisioning/actions/set_key_partition_list_action.rb, line 37
def self.details
  "Sets key partition list (required by macOS Sierra)"
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/provisioning/actions/set_key_partition_list_action.rb, line 61
def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end
run(params) click to toggle source
# File lib/fastlane/plugin/provisioning/actions/set_key_partition_list_action.rb, line 4
def self.run(params)
  if `security -h | grep set-key-partition-list`.length > 0
    escaped_password = params[:password].shellescape

    if params[:name]
      escaped_name = params[:name].shellescape
      keychain_path = "~/Library/Keychains/#{escaped_name}"
    else
      keychain_path = params[:path].shellescape
    end

    if keychain_path.nil?
      UI.user_error!("You either have to set :name or :path")
    end

    command = "security set-key-partition-list"
    command << " -S apple-tool:,apple:"
    command << " -k \"#{escaped_password}\""
    command << " #{keychain_path}"
    command << " &> /dev/null"

    Fastlane::Actions.sh(command, log: false)
  end
end