Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/travis/services/find_caches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ def fetch_s3(cache_objects, options)
def fetch_gcs(cache_objects, options)
config = cache_options[:gcs]
storage = ::Google::Apis::StorageV1::StorageService.new
json_key_io = StringIO.new(JSON.dump(config.to_h[:json_key]))
bucket_name = config[:bucket_name]
json_key_obj = config.to_h[:json_key]
json_key_obj = JSON.dump(json_key_obj) unless json_key_obj.is_a?(String)
json_key_io = StringIO.new(json_key_obj)
bucket_name = config[:bucket_name]

storage.authorization = ::Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: json_key_io,
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/services/find_caches_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
context 'with GCS configuration' do
let(:cache_options) { { gcs: { bucket_name: '', json_key: { type: 'service_account', project_id: 'test-project-id' } } } }
its(:size) { is_expected.to eq 0 }

context 'when configuration is a String' do
let(:cache_options) { { gcs: { bucket_name: '', json_key: JSON.dump(type: 'service_account', project_id: 'test-project-id') } } }
its(:size) { is_expected.to eq 0 }
end
end
end
end