Skip to content

Commit

Permalink
Update configs for datadog-ci to use env and type
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Aug 17, 2023
1 parent a8bac23 commit e608382
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
14 changes: 6 additions & 8 deletions lib/datadog/ci/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def self.add_settings!(base)
base.class_eval do
settings :ci do
option :enabled do |o|
o.default { env_to_bool(CI::Ext::Settings::ENV_MODE_ENABLED, false) }
o.lazy
o.type :bool
o.env CI::Ext::Settings::ENV_MODE_ENABLED
o.default false
end

# DEV: Alias to Datadog::Tracing::Contrib::Extensions::Configuration::Settings#instrument.
Expand All @@ -33,14 +34,11 @@ def self.add_settings!(base)
# TODO: Deprecate in the next major version, as `instrument` better describes this method's purpose
alias_method :use, :instrument

option :trace_flush do |o|
o.default { nil }
o.lazy
end
option :trace_flush

option :writer_options do |o|
o.default { {} }
o.lazy
o.type :hash
o.default({})
end
end
end
Expand Down
12 changes: 7 additions & 5 deletions lib/datadog/ci/contrib/cucumber/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ module Configuration
# TODO: mark as `@public_api` when GA
class Settings < Datadog::Tracing::Contrib::Configuration::Settings
option :enabled do |o|
o.default { env_to_bool(Ext::ENV_ENABLED, true) }
o.lazy
o.type :bool
o.env Ext::ENV_ENABLED
o.default true
end

option :service_name do |o|
o.type :string
o.default { Datadog.configuration.service_without_fallback || Ext::SERVICE_NAME }
o.lazy
end

option :operation_name do |o|
o.default { ENV.key?(Ext::ENV_OPERATION_NAME) ? ENV[Ext::ENV_OPERATION_NAME] : Ext::OPERATION_NAME }
o.lazy
o.type :string
o.env Ext::ENV_OPERATION_NAME
o.default Ext::OPERATION_NAME
end
end
end
Expand Down
12 changes: 7 additions & 5 deletions lib/datadog/ci/contrib/rspec/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ module Configuration
# TODO: mark as `@public_api` when GA
class Settings < Datadog::Tracing::Contrib::Configuration::Settings
option :enabled do |o|
o.default { env_to_bool(Ext::ENV_ENABLED, true) }
o.lazy
o.type :bool
o.env Ext::ENV_ENABLED
o.default true
end

option :service_name do |o|
o.type :string
o.default { Datadog.configuration.service_without_fallback || Ext::SERVICE_NAME }
o.lazy
end

option :operation_name do |o|
o.default { ENV.key?(Ext::ENV_OPERATION_NAME) ? ENV[Ext::ENV_OPERATION_NAME] : Ext::OPERATION_NAME }
o.lazy
o.type :string
o.env Ext::ENV_OPERATION_NAME
o.default Ext::OPERATION_NAME
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/datadog/ci/configuration/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
end

describe "#ci" do
after do
settings.reset!
end

describe "#enabled" do
subject(:enabled) { settings.ci.enabled }

Expand Down

0 comments on commit e608382

Please sign in to comment.