Skip to content

Commit

Permalink
Add option to skip google account confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
trsneed committed Apr 28, 2022
1 parent 90a0345 commit 5b3f12f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions match/lib/match/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def import_cert(params, cert_path: nil, p12_path: nil, profile_path: nil)
google_cloud_bucket_name: params[:google_cloud_bucket_name].to_s,
google_cloud_keys_file: params[:google_cloud_keys_file].to_s,
google_cloud_project_id: params[:google_cloud_project_id].to_s,
skip_google_cloud_account_confirmation: params[:skip_google_cloud_account_confirmation],
s3_bucket: params[:s3_bucket],
s3_region: params[:s3_region],
s3_access_key: params[:s3_access_key],
Expand Down
5 changes: 5 additions & 0 deletions match/lib/match/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ def self.available_options
env_name: "MATCH_GOOGLE_CLOUD_PROJECT_ID",
description: "ID of the Google Cloud project to use for authentication",
optional: true),
FastlaneCore::ConfigItem.new(key: :skip_google_cloud_account_confirmation,
env_name: "MATCH_SKIP_GOOGLE_CLOUD_ACCOUNT_CONFIRMATION",
description: "Skips confirming to use the system google account",
type: Boolean,
default_value: false),

# Storage: S3
FastlaneCore::ConfigItem.new(key: :s3_region,
Expand Down
1 change: 1 addition & 0 deletions match/lib/match/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def run(params)
google_cloud_bucket_name: params[:google_cloud_bucket_name].to_s,
google_cloud_keys_file: params[:google_cloud_keys_file].to_s,
google_cloud_project_id: params[:google_cloud_project_id].to_s,
skip_google_cloud_account_confirmation: params[:skip_google_cloud_account_confirmation],
s3_region: params[:s3_region],
s3_access_key: params[:s3_access_key],
s3_secret_access_key: params[:s3_secret_access_key],
Expand Down
13 changes: 7 additions & 6 deletions match/lib/match/storage/google_cloud_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def self.configure(params)
team_id: params[:team_id],
team_name: params[:team_name],
api_key_path: params[:api_key_path],
api_key: params[:api_key]
api_key: params[:api_key],
skip_google_cloud_account_confirmation: params[:skip_google_cloud_account_confirmation]
)
end

Expand All @@ -62,7 +63,8 @@ def initialize(type: nil,
team_id: nil,
team_name: nil,
api_key_path: nil,
api_key: nil)
api_key: nil,
skip_google_cloud_account_confirmation: nil)
@type = type if type
@platform = platform if platform
@google_cloud_project_id = google_cloud_project_id if google_cloud_project_id
Expand All @@ -76,8 +78,7 @@ def initialize(type: nil,
@api_key_path = api_key_path
@api_key = api_key

@google_cloud_keys_file = ensure_keys_file_exists(google_cloud_keys_file, google_cloud_project_id)

@google_cloud_keys_file = ensure_keys_file_exists(google_cloud_keys_file, google_cloud_project_id, skip_google_cloud_account_confirmation)
if self.google_cloud_keys_file.to_s.length > 0
# Extract the Project ID from the `JSON` file
# so the user doesn't have to provide it manually
Expand Down Expand Up @@ -223,7 +224,7 @@ def bucket

# This method will make sure the keys file exists
# If it's missing, it will help the user set things up
def ensure_keys_file_exists(google_cloud_keys_file, google_cloud_project_id)
def ensure_keys_file_exists(google_cloud_keys_file, google_cloud_project_id, skip_google_cloud_account_confirmation)
if google_cloud_keys_file && File.exist?(google_cloud_keys_file)
return google_cloud_keys_file
end
Expand Down Expand Up @@ -251,7 +252,7 @@ def ensure_keys_file_exists(google_cloud_keys_file, google_cloud_project_id)
# we can continue and ask the user if they want to use a keys file.
end

if application_default_keys && UI.confirm("Do you want to use this system's Google Cloud application default keys?")
if application_default_keys && (skip_google_cloud_account_confirmation || UI.confirm("Do you want to use this system's Google Cloud application default keys?"))
return nil
end
end
Expand Down
1 change: 1 addition & 0 deletions match/spec/importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def setup_fake_storage(repo_dir, config)
google_cloud_bucket_name: "",
google_cloud_keys_file: "",
google_cloud_project_id: "",
skip_google_cloud_account_confirmation: false,
s3_bucket: nil,
s3_region: nil,
s3_access_key: nil,
Expand Down
4 changes: 4 additions & 0 deletions match/spec/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
google_cloud_bucket_name: "",
google_cloud_keys_file: "",
google_cloud_project_id: "",
skip_google_cloud_account_confirmation: false,
s3_region: nil,
s3_access_key: nil,
s3_secret_access_key: nil,
Expand Down Expand Up @@ -142,6 +143,7 @@
google_cloud_bucket_name: "",
google_cloud_keys_file: "",
google_cloud_project_id: "",
skip_google_cloud_account_confirmation: false,
s3_region: nil,
s3_access_key: nil,
s3_secret_access_key: nil,
Expand Down Expand Up @@ -226,6 +228,7 @@
google_cloud_bucket_name: "",
google_cloud_keys_file: "",
google_cloud_project_id: "",
skip_google_cloud_account_confirmation: false,
s3_region: nil,
s3_access_key: nil,
s3_secret_access_key: nil,
Expand Down Expand Up @@ -296,6 +299,7 @@
google_cloud_bucket_name: "",
google_cloud_keys_file: "",
google_cloud_project_id: "",
skip_google_cloud_account_confirmation: false,
s3_region: nil,
s3_access_key: nil,
s3_secret_access_key: nil,
Expand Down

0 comments on commit 5b3f12f

Please sign in to comment.