prevent developer account execution unless needed by Xcode, add new auth properties

This commit is contained in:
Jacob Zaval 2021-07-21 16:08:19 -04:00
Родитель 600a244b3a
Коммит 931e2c3237
2 изменённых файлов: 18 добавлений и 8 удалений

Просмотреть файл

@ -5,7 +5,7 @@ module MacOS
class DeveloperAccount
attr_reader :credentials
def initialize(data_bag_retrieval, node_credential_attributes, download_url)
def initialize(data_bag_retrieval, node_credential_attributes, _property_credentials, download_url)
if download_url.empty?
developer_id = find_apple_id(data_bag_retrieval, node_credential_attributes)
@credentials = {
@ -26,6 +26,11 @@ module MacOS
'apple_id' => node_credential_attributes['user'],
'password' => node_credential_attributes['password'],
}
elsif property_credentials.values.all?
{
'apple_id' => property_credentials['user'],
'password' => property_credentials['password'],
}
else
data_bag_retrieval.call
end

Просмотреть файл

@ -7,6 +7,8 @@ property :version, String, name_property: true
property :path, String, default: '/Applications/Xcode.app'
property :ios_simulators, Array
property :download_url, String, default: ''
property :apple_id, String
property :password, String
action :install_gem do
command_line_tools 'latest'
@ -24,18 +26,21 @@ action :install_gem do
end
action :install_xcode do
developer = DeveloperAccount.new(
-> { data_bag_item(:credentials, :apple_id) },
node['macos']['apple_id'],
new_resource.download_url
)
xcode = Xcode.new(
new_resource.version,
new_resource.path,
new_resource.download_url
)
unless xcode.installed?
developer = DeveloperAccount.new(
-> { data_bag_item(:credentials, :apple_id) },
node['macos']['apple_id'],
{ user: new_resource.apple_id, password: new_resource.password },
new_resource.download_url
)
end
unless xcode.compatible_with_platform?(node['platform_version'])
ruby_block 'exception' do
raise("Xcode #{xcode.version} not supported on #{node['platform_version']}")
@ -44,7 +49,7 @@ action :install_xcode do
execute "install Xcode #{xcode.version}" do
command XCVersion.install_xcode(xcode)
environment developer.credentials
environment lazy { developer.credentials }
cwd '/Users/Shared'
not_if { xcode.installed? }
live_stream true