diff --git a/.golangci.toml b/.golangci.toml index 622e240..424b1db 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -15,6 +15,10 @@ "goconst", "nestif", "funlen", + "varnamelen", + "ireturn", + "exhaustivestruct", + "cyclop", "bodyclose", # https://github.com/timakin/bodyclose/pull/14 ] @@ -23,21 +27,6 @@ [[issues.exclude-rules]] path = "internal/platform/providers/providers.go" linters = ["gocritic"] - [[issues.exclude-rules]] - path = "internal/image/provider/gcs.go" - linters = ["exhaustivestruct"] - [[issues.exclude-rules]] - path = "internal/platform/providers/providers_test.go" - linters = ["exhaustivestruct"] - [[issues.exclude-rules]] - path = "cmd/ims" - linters = ["exhaustivestruct"] - [[issues.exclude-rules]] - path = "internal/image/encoder/png/png.go" - linters = ["exhaustivestruct"] - [[issues.exclude-rules]] - path = "internal/image/provider/proxy.go" - linters = ["exhaustivestruct"] [[issues.exclude-rules]] linters = ["wsl"] text = "declarations should never be cuddled" diff --git a/cmd/ims/app/server.go b/cmd/ims/app/server.go index 2cc5872..7e8058c 100644 --- a/cmd/ims/app/server.go +++ b/cmd/ims/app/server.go @@ -25,7 +25,6 @@ func MountEndpoint(mux *http.ServeMux, endpoint string, handler http.Handler) { // ServerOpts is the options for starting a new Server. type ServerOpts struct { - // Addr is the address to listen for http requests on. Addr string @@ -134,5 +133,9 @@ func Serve(opts *ServerOpts) error { logrus.WithField("address", opts.Addr).Info("now listening") - return http.ListenAndServe(opts.Addr, n) + if err := http.ListenAndServe(opts.Addr, n); err != nil { + return errors.Wrap(err, "could not listen on the address for http traffic") + } + + return nil } diff --git a/internal/platform/providers/providers.go b/internal/platform/providers/providers.go index 1e49f2f..5fc64db 100644 --- a/internal/platform/providers/providers.go +++ b/internal/platform/providers/providers.go @@ -38,7 +38,12 @@ func NewProviders(providers map[string]provider.Provider) *Providers { func GetUnderlyingTransport(ctx context.Context, originURL *url.URL) (http.RoundTripper, error) { switch originURL.Scheme { case "gs": - return provider.NewGCSTransport(ctx) + transport, err := provider.NewGCSTransport(ctx) + if err != nil { + return nil, errors.Wrap(err, "could not create transport for scheme") + } + + return transport, nil default: return http.DefaultTransport, nil } @@ -79,9 +84,19 @@ func WrapCacheRoundTripper(ctx context.Context, underlyingTransport http.RoundTr func GetRemoteProviderClient(ctx context.Context, originURL *url.URL, transport http.RoundTripper) (provider.Provider, error) { switch originURL.Scheme { case "gs": - return provider.NewGCS(ctx, originURL.Host, transport) + transport, err := provider.NewGCS(ctx, originURL.Host, transport) + if err != nil { + return nil, errors.Wrap(err, "could not create provider for the gs scheme") + } + + return transport, nil case "s3": - return provider.NewS3(originURL.Host, transport) + transport, err := provider.NewS3(originURL.Host, transport) + if err != nil { + return nil, errors.Wrap(err, "could not create provider for the s3 scheme") + } + + return transport, nil case "http", "https": return provider.NewOrigin(originURL, transport), nil default: