Skip to content

Commit 97e6f02

Browse files
dazumablowmage
authored andcommitted
Update config class to use BasicObject and provide validations
1 parent 16e2777 commit 97e6f02

27 files changed

Lines changed: 1024 additions & 450 deletions

File tree

google-cloud-bigquery/lib/google/cloud/bigquery.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
require "google-cloud-bigquery"
1717
require "google/cloud/bigquery/project"
18-
require "google/cloud/configuration"
18+
require "google/cloud/config"
1919
require "google/cloud/env"
2020

2121
module Google
@@ -543,10 +543,20 @@ def self.new project_id: nil, credentials: nil, scope: nil, retries: nil,
543543
)
544544
end
545545

546-
# Initialize :debugger as a nested Configuration under Google::Cloud if
547-
# haven't already
548-
unless Google::Cloud.configure.option? :bigquery
549-
Google::Cloud.configure.add_options :bigquery
546+
# Initialize :bigquery as a nested Configuration under Google::Cloud if
547+
# we haven't already
548+
unless Google::Cloud.configure.valid_config_name? :bigquery
549+
Google::Cloud.configure.add_config! :bigquery do |config|
550+
config.add_field! :project_id, nil, match: String
551+
config.add_field! :project, nil, match: String
552+
config.add_field! :credentials, nil,
553+
match: [String, Hash, Google::Auth::Credentials]
554+
config.add_field! :keyfile, nil,
555+
match: [String, Hash, Google::Auth::Credentials]
556+
config.add_field! :scope, nil, match: [String, Array]
557+
config.add_field! :retries, nil, match: Integer
558+
config.add_field! :timeout, nil, match: Integer
559+
end
550560
end
551561

552562
##
@@ -566,7 +576,7 @@ def self.new project_id: nil, credentials: nil, scope: nil, retries: nil,
566576
# error.
567577
# * `timeout` - (Integer) Default timeout to use in requests.
568578
#
569-
# @return [Google::Cloud::Configuration] The configuration object the
579+
# @return [Google::Cloud::Config] The configuration object the
570580
# Google::Cloud::Bigquery library uses.
571581
#
572582
def self.configure

google-cloud-bigquery/test/google/cloud/bigquery_test.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,7 @@ def creds.is_a? target
215215
let(:found_credentials) { "{}" }
216216

217217
after do
218-
Google::Cloud.configure.delete :project_id
219-
Google::Cloud.configure.delete :project
220-
Google::Cloud.configure.delete :credentials
221-
Google::Cloud.configure.delete :keyfile
222-
Google::Cloud.configure.bigquery.clear
218+
Google::Cloud.configure.reset!
223219
end
224220

225221
it "uses shared config for project and keyfile" do

google-cloud-core/.rubocop.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ Style/RescueModifier:
1717
Style/MutableConstant:
1818
Exclude:
1919
- "lib/google/cloud/credentials.rb"
20-
Style/MethodMissing:
21-
Exclude:
22-
- "lib/google/cloud/configuration.rb"
2320
Metrics/CyclomaticComplexity:
2421
Max: 10
2522
Metrics/PerceivedComplexity:

0 commit comments

Comments
 (0)