Skip to content

Commit 117f008

Browse files
committed
chore: linting
1 parent fc2e514 commit 117f008

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

.golangci.toml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"goconst",
1616
"nestif",
1717
"funlen",
18+
"varnamelen",
19+
"ireturn",
20+
"exhaustivestruct",
21+
"cyclop",
1822
"bodyclose", # https://github.com/timakin/bodyclose/pull/14
1923
]
2024

@@ -23,21 +27,6 @@
2327
[[issues.exclude-rules]]
2428
path = "internal/platform/providers/providers.go"
2529
linters = ["gocritic"]
26-
[[issues.exclude-rules]]
27-
path = "internal/image/provider/gcs.go"
28-
linters = ["exhaustivestruct"]
29-
[[issues.exclude-rules]]
30-
path = "internal/platform/providers/providers_test.go"
31-
linters = ["exhaustivestruct"]
32-
[[issues.exclude-rules]]
33-
path = "cmd/ims"
34-
linters = ["exhaustivestruct"]
35-
[[issues.exclude-rules]]
36-
path = "internal/image/encoder/png/png.go"
37-
linters = ["exhaustivestruct"]
38-
[[issues.exclude-rules]]
39-
path = "internal/image/provider/proxy.go"
40-
linters = ["exhaustivestruct"]
4130
[[issues.exclude-rules]]
4231
linters = ["wsl"]
4332
text = "declarations should never be cuddled"

cmd/ims/app/server.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func MountEndpoint(mux *http.ServeMux, endpoint string, handler http.Handler) {
2525

2626
// ServerOpts is the options for starting a new Server.
2727
type ServerOpts struct {
28-
2928
// Addr is the address to listen for http requests on.
3029
Addr string
3130

@@ -134,5 +133,9 @@ func Serve(opts *ServerOpts) error {
134133

135134
logrus.WithField("address", opts.Addr).Info("now listening")
136135

137-
return http.ListenAndServe(opts.Addr, n)
136+
if err := http.ListenAndServe(opts.Addr, n); err != nil {
137+
return errors.Wrap(err, "could not listen on the address for http traffic")
138+
}
139+
140+
return nil
138141
}

internal/platform/providers/providers.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ func NewProviders(providers map[string]provider.Provider) *Providers {
3838
func GetUnderlyingTransport(ctx context.Context, originURL *url.URL) (http.RoundTripper, error) {
3939
switch originURL.Scheme {
4040
case "gs":
41-
return provider.NewGCSTransport(ctx)
41+
transport, err := provider.NewGCSTransport(ctx)
42+
if err != nil {
43+
return nil, errors.Wrap(err, "could not create transport for scheme")
44+
}
45+
46+
return transport, nil
4247
default:
4348
return http.DefaultTransport, nil
4449
}
@@ -79,9 +84,19 @@ func WrapCacheRoundTripper(ctx context.Context, underlyingTransport http.RoundTr
7984
func GetRemoteProviderClient(ctx context.Context, originURL *url.URL, transport http.RoundTripper) (provider.Provider, error) {
8085
switch originURL.Scheme {
8186
case "gs":
82-
return provider.NewGCS(ctx, originURL.Host, transport)
87+
transport, err := provider.NewGCS(ctx, originURL.Host, transport)
88+
if err != nil {
89+
return nil, errors.Wrap(err, "could not create provider for the gs scheme")
90+
}
91+
92+
return transport, nil
8393
case "s3":
84-
return provider.NewS3(originURL.Host, transport)
94+
transport, err := provider.NewS3(originURL.Host, transport)
95+
if err != nil {
96+
return nil, errors.Wrap(err, "could not create provider for the s3 scheme")
97+
}
98+
99+
return transport, nil
85100
case "http", "https":
86101
return provider.NewOrigin(originURL, transport), nil
87102
default:

0 commit comments

Comments
 (0)