diff --git a/storage/config.go b/storage/config.go index a125637a..19c4d385 100644 --- a/storage/config.go +++ b/storage/config.go @@ -6,8 +6,8 @@ import ( ) var ( - ErrSQLStorageRequiresFile = errors.New("sql storage requires a non-empty file to be defined") - ErrMemoryStorageDoesNotSupportFile = errors.New("memory storage does not support persistence, use sqlite if you want persistence on file") + ErrSQLStorageRequiresPath = errors.New("sql storage requires a non-empty path to be defined") + ErrMemoryStorageDoesNotSupportPath = errors.New("memory storage does not support persistence, use sqlite if you want persistence on file") ErrCannotSetBothFileAndPath = errors.New("file has been deprecated in favor of path: you cannot set both of them") ) @@ -45,7 +45,7 @@ func (c *Config) ValidateAndSetDefaults() error { c.Type = TypeMemory } if (c.Type == TypePostgres || c.Type == TypeSQLite) && len(c.Path) == 0 { - return ErrSQLStorageRequiresFile + return ErrSQLStorageRequiresPath } if c.Type == TypeMemory && len(c.Path) > 0 { log.Println("WARNING: Your configuration is using a storage of type memory with persistence, which has been deprecated") @@ -53,7 +53,7 @@ func (c *Config) ValidateAndSetDefaults() error { log.Println("WARNING: If you want persistence, use 'storage.type: sqlite' instead of 'storage.type: memory'") log.Println("WARNING: See https://github.com/TwiN/gatus/issues/198") // XXX: Uncomment the following line for v4.0.0 - //return ErrMemoryStorageDoesNotSupportFile + //return ErrMemoryStorageDoesNotSupportPath } return nil } diff --git a/storage/store/sql/sql.go b/storage/store/sql/sql.go index 644efeab..3543efd8 100644 --- a/storage/store/sql/sql.go +++ b/storage/store/sql/sql.go @@ -493,12 +493,6 @@ func (s *Store) getEndpointStatusByKey(tx *sql.Tx, key string, parameters *pagin log.Printf("[sql][getEndpointStatusByKey] Failed to retrieve results for key=%s: %s", key, err.Error()) } } - //if parameters.IncludeUptime { - // now := time.Now() - // endpointStatus.Uptime.LastHour, _, err = s.getEndpointUptime(tx, endpointID, now.Add(-time.Hour), now) - // endpointStatus.Uptime.LastTwentyFourHours, _, err = s.getEndpointUptime(tx, endpointID, now.Add(-24*time.Hour), now) - // endpointStatus.Uptime.LastSevenDays, _, err = s.getEndpointUptime(tx, endpointID, now.Add(-7*24*time.Hour), now) - //} return endpointStatus, nil } diff --git a/storage/store/store.go b/storage/store/store.go index ca6a8c5a..fc1afa8a 100644 --- a/storage/store/store.go +++ b/storage/store/store.go @@ -74,6 +74,7 @@ var ( func Get() Store { if !initialized { + // This only happens in tests log.Println("[store][Get] Provider requested before it was initialized, automatically initializing") err := Initialize(nil) if err != nil { @@ -92,12 +93,12 @@ func Initialize(cfg *storage.Config) error { cancelFunc() } if cfg == nil { + // This only happens in tests + log.Println("[store][Initialize] nil storage config passed as parameter. This should only happen in tests. Defaulting to an empty config.") cfg = &storage.Config{} } if len(cfg.Path) == 0 && cfg.Type != storage.TypePostgres { - log.Printf("[store][Initialize] Creating storage provider with type=%s and file=%s", cfg.Type, cfg.Path) - } else { - log.Printf("[store][Initialize] Creating storage provider with type=%s", cfg.Type) + log.Printf("[store][Initialize] Creating storage provider of type=%s", cfg.Type) } ctx, cancelFunc = context.WithCancel(context.Background()) switch cfg.Type {