mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-09 11:42:48 +02:00
chore: Changing fmt.Errorf to errors.New when there is no formatting required (#1044)
Co-authored-by: Sergey Alexandrovich <DarthSim@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
@@ -571,7 +572,7 @@ func Configure() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(Bind) == 0 {
|
if len(Bind) == 0 {
|
||||||
return fmt.Errorf("Bind address is not defined")
|
return errors.New("Bind address is not defined")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ReadTimeout <= 0 {
|
if ReadTimeout <= 0 {
|
||||||
@@ -639,7 +640,7 @@ func Configure() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(PreferredFormats) == 0 {
|
if len(PreferredFormats) == 0 {
|
||||||
return fmt.Errorf("At least one preferred format should be specified")
|
return errors.New("At least one preferred format should be specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
if IgnoreSslVerification {
|
if IgnoreSslVerification {
|
||||||
@@ -654,7 +655,7 @@ func Configure() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !stat.IsDir() {
|
if !stat.IsDir() {
|
||||||
return fmt.Errorf("Cannot use local directory: not a directory")
|
return errors.New("Cannot use local directory: not a directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
if LocalFileSystemRoot == "/" {
|
if LocalFileSystemRoot == "/" {
|
||||||
@@ -668,35 +669,35 @@ func Configure() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if WatermarkOpacity <= 0 {
|
if WatermarkOpacity <= 0 {
|
||||||
return fmt.Errorf("Watermark opacity should be greater than 0")
|
return errors.New("Watermark opacity should be greater than 0")
|
||||||
} else if WatermarkOpacity > 1 {
|
} else if WatermarkOpacity > 1 {
|
||||||
return fmt.Errorf("Watermark opacity should be less than or equal to 1")
|
return errors.New("Watermark opacity should be less than or equal to 1")
|
||||||
}
|
}
|
||||||
|
|
||||||
if FallbackImageHTTPCode < 100 || FallbackImageHTTPCode > 599 {
|
if FallbackImageHTTPCode < 100 || FallbackImageHTTPCode > 599 {
|
||||||
return fmt.Errorf("Fallback image HTTP code should be between 100 and 599")
|
return errors.New("Fallback image HTTP code should be between 100 and 599")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(PrometheusBind) > 0 && PrometheusBind == Bind {
|
if len(PrometheusBind) > 0 && PrometheusBind == Bind {
|
||||||
return fmt.Errorf("Can't use the same binding for the main server and Prometheus")
|
return errors.New("Can't use the same binding for the main server and Prometheus")
|
||||||
}
|
}
|
||||||
|
|
||||||
if OpenTelemetryConnectionTimeout < 1 {
|
if OpenTelemetryConnectionTimeout < 1 {
|
||||||
return fmt.Errorf("OpenTelemetry connection timeout should be greater than zero")
|
return errors.New("OpenTelemetry connection timeout should be greater than zero")
|
||||||
}
|
}
|
||||||
|
|
||||||
if FreeMemoryInterval <= 0 {
|
if FreeMemoryInterval <= 0 {
|
||||||
return fmt.Errorf("Free memory interval should be greater than zero")
|
return errors.New("Free memory interval should be greater than zero")
|
||||||
}
|
}
|
||||||
|
|
||||||
if DownloadBufferSize < 0 {
|
if DownloadBufferSize < 0 {
|
||||||
return fmt.Errorf("Download buffer size should be greater than or equal to 0")
|
return errors.New("Download buffer size should be greater than or equal to 0")
|
||||||
} else if DownloadBufferSize > math.MaxInt32 {
|
} else if DownloadBufferSize > math.MaxInt32 {
|
||||||
return fmt.Errorf("Download buffer size can't be greater than %d", math.MaxInt32)
|
return fmt.Errorf("Download buffer size can't be greater than %d", math.MaxInt32)
|
||||||
}
|
}
|
||||||
|
|
||||||
if BufferPoolCalibrationThreshold < 64 {
|
if BufferPoolCalibrationThreshold < 64 {
|
||||||
return fmt.Errorf("Buffer pool calibration threshold should be greater than or equal to 64")
|
return errors.New("Buffer pool calibration threshold should be greater than or equal to 64")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -288,7 +289,7 @@ func buildTLSConfig() (*tls.Config, error) {
|
|||||||
|
|
||||||
certPool := x509.NewCertPool()
|
certPool := x509.NewCertPool()
|
||||||
if !certPool.AppendCertsFromPEM(prepareKeyCert(config.OpenTelemetryServerCert)) {
|
if !certPool.AppendCertsFromPEM(prepareKeyCert(config.OpenTelemetryServerCert)) {
|
||||||
return nil, fmt.Errorf("Can't load OpenTelemetry server cert")
|
return nil, errors.New("Can't load OpenTelemetry server cert")
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsConf := tls.Config{RootCAs: certPool}
|
tlsConf := tls.Config{RootCAs: certPool}
|
||||||
|
@@ -8,7 +8,6 @@ package vips
|
|||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -53,7 +52,7 @@ func Init() error {
|
|||||||
|
|
||||||
if err := C.vips_initialize(); err != 0 {
|
if err := C.vips_initialize(); err != 0 {
|
||||||
C.vips_shutdown()
|
C.vips_shutdown()
|
||||||
return fmt.Errorf("unable to start vips!")
|
return errors.New("unable to start vips!")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable libvips cache. Since processing pipeline is fine tuned, we won't get much profit from it.
|
// Disable libvips cache. Since processing pipeline is fine tuned, we won't get much profit from it.
|
||||||
|
Reference in New Issue
Block a user