Class: Fastlane::Actions::SetKeyPartitionListAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



33
34
35
# File 'lib/fastlane/plugin/provisioning/actions/set_key_partition_list_action.rb', line 33

def self.authors
  ["paweljankowski"]
end

.available_optionsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 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

.descriptionObject



29
30
31
# 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

.detailsObject



37
38
39
# 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) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# 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) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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