aboutsummaryrefslogtreecommitdiffhomepage
path: root/config
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-11-11 15:54:19 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-11-11 15:54:19 -0800
commitbecd086865f35d64a80d01ffb1ca96d0493dfa03 (patch)
tree6dea31c665873162742f29b4b198adb88b65cbcc /config
parent487852f07eb191ef56967b7b7d7f01537a55eabd (diff)
Add config options to disable HTTP and scheduler services
Diffstat (limited to 'config')
-rw-r--r--config/config.go10
-rw-r--r--config/config_test.go50
2 files changed, 60 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go
index 281a8a3..7ba3a93 100644
--- a/config/config.go
+++ b/config/config.go
@@ -214,6 +214,16 @@ func (c *Config) ProxyImages() string {
return getStringValue("PROXY_IMAGES", defaultProxyImages)
}
+// HasHTTPService returns true if the HTTP service is enabled.
+func (c *Config) HasHTTPService() bool {
+ return !getBooleanValue("DISABLE_HTTP_SERVICE")
+}
+
+// HasSchedulerService returns true if the scheduler service is enabled.
+func (c *Config) HasSchedulerService() bool {
+ return !getBooleanValue("DISABLE_SCHEDULER_SERVICE")
+}
+
// NewConfig returns a new Config.
func NewConfig() *Config {
cfg := &Config{
diff --git a/config/config_test.go b/config/config_test.go
index 76b3ac5..1c188db 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -658,6 +658,56 @@ func TestHSTS(t *testing.T) {
}
}
+func TestDisableHTTPServiceWhenUnset(t *testing.T) {
+ os.Clearenv()
+
+ cfg := NewConfig()
+ expected := true
+ result := cfg.HasHTTPService()
+
+ if result != expected {
+ t.Fatalf(`Unexpected DISABLE_HTTP_SERVICE value, got %v instead of %v`, result, expected)
+ }
+}
+
+func TestDisableHTTPService(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("DISABLE_HTTP_SERVICE", "1")
+
+ cfg := NewConfig()
+ expected := false
+ result := cfg.HasHTTPService()
+
+ if result != expected {
+ t.Fatalf(`Unexpected DISABLE_HTTP_SERVICE value, got %v instead of %v`, result, expected)
+ }
+}
+
+func TestDisableSchedulerServiceWhenUnset(t *testing.T) {
+ os.Clearenv()
+
+ cfg := NewConfig()
+ expected := true
+ result := cfg.HasSchedulerService()
+
+ if result != expected {
+ t.Fatalf(`Unexpected DISABLE_SCHEDULER_SERVICE value, got %v instead of %v`, result, expected)
+ }
+}
+
+func TestDisableSchedulerService(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("DISABLE_SCHEDULER_SERVICE", "1")
+
+ cfg := NewConfig()
+ expected := false
+ result := cfg.HasSchedulerService()
+
+ if result != expected {
+ t.Fatalf(`Unexpected DISABLE_SCHEDULER_SERVICE value, got %v instead of %v`, result, expected)
+ }
+}
+
func TestRunMigrationsWhenUnset(t *testing.T) {
os.Clearenv()