lib/kms_encrypted.rb in kms_encrypted-1.2.4 vs lib/kms_encrypted.rb in kms_encrypted-1.3.0

- old
+ new

@@ -37,18 +37,27 @@ ) end def google_client @google_client ||= begin - require "google/apis/cloudkms_v1" - client = ::Google::Apis::CloudkmsV1::CloudKMSService.new - client.authorization = ::Google::Auth.get_application_default( - "https://www.googleapis.com/auth/cloud-platform" - ) - client.client_options.log_http_requests = false - client.client_options.open_timeout_sec = 2 - client.client_options.read_timeout_sec = 2 - client + begin + require "google/apis/cloudkms_v1" + + client = ::Google::Apis::CloudkmsV1::CloudKMSService.new + client.authorization = ::Google::Auth.get_application_default( + "https://www.googleapis.com/auth/cloud-platform" + ) + client.client_options.log_http_requests = false + client.client_options.open_timeout_sec = 2 + client.client_options.read_timeout_sec = 2 + client + rescue LoadError + require "google/cloud/kms" + + Google::Cloud::Kms.key_management_service do |config| + config.timeout = 2 + end + end end end def vault_client @vault_client ||= ::Vault::Client.new