Skip to content

Commit

Permalink
chore: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh committed Apr 8, 2022
1 parent fc2e514 commit 117f008
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
19 changes: 4 additions & 15 deletions .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"goconst",
"nestif",
"funlen",
"varnamelen",
"ireturn",
"exhaustivestruct",
"cyclop",
"bodyclose", # https://github.com/timakin/bodyclose/pull/14
]

Expand All @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions cmd/ims/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
21 changes: 18 additions & 3 deletions internal/platform/providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 117f008

Please sign in to comment.