match/lib/match/importer.rb in fastlane_hotfix-2.165.1 vs match/lib/match/importer.rb in fastlane_hotfix-2.187.0

- old
+ new

@@ -20,10 +20,13 @@ shallow_clone: params[:shallow_clone], skip_docs: params[:skip_docs], git_branch: params[:git_branch], git_full_name: params[:git_full_name], git_user_email: params[:git_user_email], + git_private_key: params[:git_private_key], + git_basic_authorization: params[:git_basic_authorization], + git_bearer_authorization: params[:git_bearer_authorization], clone_branch_directly: params[:clone_branch_directly], type: params[:type].to_s, platform: params[:platform].to_s, google_cloud_bucket_name: params[:google_cloud_bucket_name].to_s, google_cloud_keys_file: params[:google_cloud_keys_file].to_s, @@ -91,19 +94,21 @@ # Make dir if doesn't exist FileUtils.mkdir_p(output_dir_certs) dest_cert_path = File.join(output_dir_certs, "#{cert_name}.cer") dest_p12_path = File.join(output_dir_certs, "#{p12_name}.p12") else - # Need to get the cert id by comparing base64 encoded cert content with certificate content from the API responses - token = api_token(params) - if token + if (api_token = Spaceship::ConnectAPI::Token.from(hash: params[:api_key], filepath: params[:api_key_path])) UI.message("Creating authorization token for App Store Connect API") - Spaceship::ConnectAPI.token = token + Spaceship::ConnectAPI.token = api_token + elsif !Spaceship::ConnectAPI.token.nil? + UI.message("Using existing authorization token for App Store Connect API") else UI.message("Login to App Store Connect (#{params[:username]})") Spaceship::ConnectAPI.login(params[:username], use_portal: true, use_tunes: false, portal_team_id: params[:team_id], team_name: params[:team_name]) end + + # Need to get the cert id by comparing base64 encoded cert content with certificate content from the API responses certs = Spaceship::ConnectAPI::Certificate.all(filter: { certificateType: certificate_type }) # Base64 encode contents to find match from API to find a cert ID cert_contents_base_64 = Base64.strict_encode64(File.binread(cert_path)) matching_cert = certs.find do |cert| @@ -144,14 +149,8 @@ file_path = File.absolute_path(file_path) unless file_path == "" file_path = File.exist?(file_path) ? file_path : nil UI.user_error!("#{file_description} does not exist at path: #{file_path}") unless !file_path.nil? || optional file_path - end - - def api_token(params) - @api_token ||= Spaceship::ConnectAPI::Token.create(params[:api_key]) if params[:api_key] - @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(params[:api_key_path]) if params[:api_key_path] - return @api_token end end end