mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
v2: housekeeping: address minor lint complaints (#2957)
* v2: housekeeping: update tools * v2: housekeeping: adhere to US locale in spelling * v2: housekeeping: simplify code
This commit is contained in:
parent
8c7c2e4af2
commit
dff78d82ce
9 changed files with 12 additions and 15 deletions
|
@ -78,7 +78,7 @@ jobs:
|
||||||
condition: eq( variables['Agent.OS'], 'Windows_NT' )
|
condition: eq( variables['Agent.OS'], 'Windows_NT' )
|
||||||
displayName: Install Go on Windows
|
displayName: Install Go on Windows
|
||||||
|
|
||||||
- bash: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.19.1
|
- bash: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.22.2
|
||||||
displayName: Install golangci-lint
|
displayName: Install golangci-lint
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
|
@ -198,7 +198,7 @@ jobs:
|
||||||
sudo apt update && sudo apt install -y clang-7 lldb-7 lld-7
|
sudo apt update && sudo apt install -y clang-7 lldb-7 lld-7
|
||||||
|
|
||||||
go get -v github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
|
go get -v github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
|
||||||
wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.74/fuzzit_Linux_x86_64
|
wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.77/fuzzit_Linux_x86_64
|
||||||
chmod a+x fuzzit
|
chmod a+x fuzzit
|
||||||
mv fuzzit $(GOBIN)
|
mv fuzzit $(GOBIN)
|
||||||
displayName: Download go-fuzz tools and the Fuzzit CLI, and move Fuzzit CLI to GOBIN
|
displayName: Download go-fuzz tools and the Fuzzit CLI, and move Fuzzit CLI to GOBIN
|
||||||
|
|
|
@ -30,7 +30,7 @@ import (
|
||||||
// that spawned the modules which are loaded. It should be used
|
// that spawned the modules which are loaded. It should be used
|
||||||
// with care and wrapped with derivation functions from the
|
// with care and wrapped with derivation functions from the
|
||||||
// standard context package only if you don't need the Caddy
|
// standard context package only if you don't need the Caddy
|
||||||
// specific features. These contexts are cancelled when the
|
// specific features. These contexts are canceled when the
|
||||||
// lifetime of the modules loaded from it is over.
|
// lifetime of the modules loaded from it is over.
|
||||||
//
|
//
|
||||||
// Use NewContext() to get a valid value (but most modules will
|
// Use NewContext() to get a valid value (but most modules will
|
||||||
|
@ -75,7 +75,7 @@ func NewContext(ctx Context) (Context, context.CancelFunc) {
|
||||||
return newCtx, wrappedCancel
|
return newCtx, wrappedCancel
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnCancel executes f when ctx is cancelled.
|
// OnCancel executes f when ctx is canceled.
|
||||||
func (ctx *Context) OnCancel(f func()) {
|
func (ctx *Context) OnCancel(f func()) {
|
||||||
ctx.cleanupFuncs = append(ctx.cleanupFuncs, f)
|
ctx.cleanupFuncs = append(ctx.cleanupFuncs, f)
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ func (fcl *fakeCloseListener) Accept() (net.Conn, error) {
|
||||||
fcl.deadlineMu.Unlock()
|
fcl.deadlineMu.Unlock()
|
||||||
|
|
||||||
if atomic.LoadInt32(&fcl.closed) == 1 {
|
if atomic.LoadInt32(&fcl.closed) == 1 {
|
||||||
// if we cancelled the Accept() by setting a deadline
|
// if we canceled the Accept() by setting a deadline
|
||||||
// on the listener, we need to make sure any callers of
|
// on the listener, we need to make sure any callers of
|
||||||
// Accept() think the listener was actually closed;
|
// Accept() think the listener was actually closed;
|
||||||
// if we return the timeout error instead, callers might
|
// if we return the timeout error instead, callers might
|
||||||
|
|
|
@ -76,7 +76,7 @@ type Logging struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// openLogs sets up the config and opens all the configured writers.
|
// openLogs sets up the config and opens all the configured writers.
|
||||||
// It closes its logs when ctx is cancelled, so it should clean up
|
// It closes its logs when ctx is canceled, so it should clean up
|
||||||
// after itself.
|
// after itself.
|
||||||
func (logging *Logging) openLogs(ctx Context) error {
|
func (logging *Logging) openLogs(ctx Context) error {
|
||||||
// make sure to deallocate resources when context is done
|
// make sure to deallocate resources when context is done
|
||||||
|
@ -184,7 +184,7 @@ func (logging *Logging) setupNewDefault(ctx Context) error {
|
||||||
|
|
||||||
// closeLogs cleans up resources allocated during openLogs.
|
// closeLogs cleans up resources allocated during openLogs.
|
||||||
// A successful call to openLogs calls this automatically
|
// A successful call to openLogs calls this automatically
|
||||||
// when the context is cancelled.
|
// when the context is canceled.
|
||||||
func (logging *Logging) closeLogs() error {
|
func (logging *Logging) closeLogs() error {
|
||||||
for _, key := range logging.writerKeys {
|
for _, key := range logging.writerKeys {
|
||||||
_, err := writers.Delete(key)
|
_, err := writers.Delete(key)
|
||||||
|
|
|
@ -68,7 +68,6 @@ func (h Handler) handleUpgradeResponse(rw http.ResponseWriter, req *http.Request
|
||||||
go spc.copyToBackend(errc)
|
go spc.copyToBackend(errc)
|
||||||
go spc.copyFromBackend(errc)
|
go spc.copyFromBackend(errc)
|
||||||
<-errc
|
<-errc
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// flushInterval returns the p.FlushInterval value, conditionally
|
// flushInterval returns the p.FlushInterval value, conditionally
|
||||||
|
|
|
@ -60,7 +60,7 @@ func (r *LoadMiddleware) Run(thread *starlark.Thread, fn *starlark.Builtin, args
|
||||||
|
|
||||||
js := json.RawMessage(cfg.String())
|
js := json.RawMessage(cfg.String())
|
||||||
|
|
||||||
if strings.Index(name, "http.handlers.") == -1 {
|
if !strings.Contains(name, "http.handlers.") {
|
||||||
name = fmt.Sprintf("http.handlers.%s", name)
|
name = fmt.Sprintf("http.handlers.%s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ func (r *LoadResponder) Run(thread *starlark.Thread, fn *starlark.Builtin, args
|
||||||
|
|
||||||
js := json.RawMessage(cfg.String())
|
js := json.RawMessage(cfg.String())
|
||||||
|
|
||||||
if strings.Index(name, "http.handlers.") == -1 {
|
if !strings.Contains(name, "http.handlers.") {
|
||||||
name = fmt.Sprintf("http.handlers.%s", name)
|
name = fmt.Sprintf("http.handlers.%s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,9 +259,7 @@ func (t *Templates) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddy
|
||||||
// refresh, so disable them until we find a better way to do this
|
// refresh, so disable them until we find a better way to do this
|
||||||
rec.Header().Del("Etag")
|
rec.Header().Del("Etag")
|
||||||
|
|
||||||
rec.WriteResponse()
|
return rec.WriteResponse()
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// executeTemplate executes the template contained in wb.buf and replaces it with the results.
|
// executeTemplate executes the template contained in wb.buf and replaces it with the results.
|
||||||
|
|
|
@ -179,7 +179,7 @@ func (p *ConnectionPolicy) buildStandardTLSConfig(ctx caddy.Context) error {
|
||||||
// session ticket key rotation
|
// session ticket key rotation
|
||||||
tlsApp.SessionTickets.register(cfg)
|
tlsApp.SessionTickets.register(cfg)
|
||||||
ctx.OnCancel(func() {
|
ctx.OnCancel(func() {
|
||||||
// do cleanup when the context is cancelled because,
|
// do cleanup when the context is canceled because,
|
||||||
// though unlikely, it is possible that a context
|
// though unlikely, it is possible that a context
|
||||||
// needing a TLS server config could exist for less
|
// needing a TLS server config could exist for less
|
||||||
// than the lifetime of the whole app
|
// than the lifetime of the whole app
|
||||||
|
|
|
@ -96,7 +96,7 @@ func (fw FileWriter) WriterKey() string {
|
||||||
// OpenWriter opens a new file writer.
|
// OpenWriter opens a new file writer.
|
||||||
func (fw FileWriter) OpenWriter() (io.WriteCloser, error) {
|
func (fw FileWriter) OpenWriter() (io.WriteCloser, error) {
|
||||||
// roll log files by default
|
// roll log files by default
|
||||||
if fw.Roll == nil || *fw.Roll == true {
|
if fw.Roll == nil || *fw.Roll {
|
||||||
if fw.RollSizeMB == 0 {
|
if fw.RollSizeMB == 0 {
|
||||||
fw.RollSizeMB = 100
|
fw.RollSizeMB = 100
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue