File tree 4 files changed +16
-15
lines changed
4 files changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,7 @@ type Billing struct {
290
290
}
291
291
292
292
type Metronome struct {
293
- Enabled bool `json:"enabled " mapstructure:"enabled " yaml:"enabled "`
293
+ Disabled bool `json:"disabled " mapstructure:"disabled " yaml:"disabled "`
294
294
URL string `json:"url" mapstructure:"url" yaml:"url"`
295
295
ApiKey string `json:"api_key" mapstructure:"api_key" yaml:"api_key"`
296
296
DefaultPlan string `json:"default_plan" mapstructure:"default_plan" yaml:"default_plan"`
@@ -300,7 +300,7 @@ type Metronome struct {
300
300
type BilledMetrics = map [string ]string
301
301
302
302
type BillingReporter struct {
303
- Enabled bool `json:"enabled " mapstructure:"enabled " yaml:"enabled "`
303
+ Disabled bool `json:"disabled " mapstructure:"disabled " yaml:"disabled "`
304
304
RefreshInterval time.Duration `json:"refresh_interval" mapstructure:"refresh_interval" yaml:"refresh_interval"`
305
305
}
306
306
@@ -354,14 +354,12 @@ var DefaultConfig = Config{
354
354
},
355
355
Billing : Billing {
356
356
Metronome : Metronome {
357
- Enabled : false ,
358
- URL : "https://api.metronome.com/v1" ,
359
- ApiKey : "replace_me" ,
357
+ URL : "https://api.metronome.com/v1" ,
358
+ ApiKey : "replace_me" ,
360
359
// random placeholder UUID and not an actual plan
361
360
DefaultPlan : "47eda90f-d2e8-4184-8955-cb3a6467782b" ,
362
361
},
363
362
Reporter : BillingReporter {
364
- Enabled : false ,
365
363
RefreshInterval : time .Second * 60 , // 60 seconds
366
364
},
367
365
},
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ func (w WindowSize) String() string {
64
64
}
65
65
66
66
func NewProvider () Provider {
67
- if config .DefaultConfig .Billing .Metronome .Enabled {
67
+ if ! config .DefaultConfig .Billing .Metronome .Disabled {
68
68
svc , err := NewMetronomeProvider (config .DefaultConfig .Billing .Metronome )
69
69
if ! ulog .E (err ) {
70
70
return svc
Original file line number Diff line number Diff line change @@ -22,24 +22,27 @@ import (
22
22
)
23
23
24
24
func TestNewProvider (t * testing.T ) {
25
- t .Run ("billing is disabled" , func (t * testing.T ) {
25
+ t .Run ("billing is enabled by default" , func (t * testing.T ) {
26
+ require .False (t , config .DefaultConfig .Billing .Metronome .Disabled )
26
27
provider := NewProvider ()
27
28
28
29
_ , ok := provider .(* noop )
29
- require .True (t , ok )
30
+ require .False (t , ok )
30
31
31
32
_ , ok = provider .(* Metronome )
32
- require .False (t , ok )
33
+ require .True (t , ok )
33
34
})
34
35
35
- t .Run ("billing is enabled " , func (t * testing.T ) {
36
- config .DefaultConfig .Billing .Metronome .Enabled = true
36
+ t .Run ("billing is disabled " , func (t * testing.T ) {
37
+ config .DefaultConfig .Billing .Metronome .Disabled = true
37
38
provider := NewProvider ()
38
39
39
40
_ , ok := provider .(* noop )
40
- require .False (t , ok )
41
+ require .True (t , ok )
41
42
42
43
_ , ok = provider .(* Metronome )
43
- require .True (t , ok )
44
+ require .False (t , ok )
45
+ // reset
46
+ config .DefaultConfig .Billing .Metronome .Disabled = false
44
47
})
45
48
}
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ func NewUsageReporter(
62
62
}
63
63
64
64
func (r * UsageReporter ) Start () {
65
- if config .DefaultConfig .Billing .Reporter .Enabled {
65
+ if ! config .DefaultConfig .Billing .Reporter .Disabled {
66
66
go r .refreshLoop ()
67
67
}
68
68
}
You can’t perform that action at this time.
0 commit comments