mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 21:33:22 +01:00
lint: fix issues
This commit is contained in:
@@ -79,7 +79,7 @@ func (s *ServeCmd) Run(ctx *Context) error {
|
|||||||
case "block":
|
case "block":
|
||||||
defer profile.Start(profile.BlockProfile, profilePath).Stop()
|
defer profile.Start(profile.BlockProfile, profilePath).Stop()
|
||||||
default:
|
default:
|
||||||
log.Fatal().Msgf("Unknown profiler: %s", s.Profiler)
|
log.Fatal().Msgf("Unknown profiler: %s", s.Profiler) //nolint:gocritic // defer not set if profiler is unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,11 +87,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
|||||||
q := u.Query()
|
q := u.Query()
|
||||||
u.RawQuery = q.Encode()
|
u.RawQuery = q.Encode()
|
||||||
|
|
||||||
hc := http.Client{}
|
cancelCtx, cancel := context.WithCancelCause(context.Background())
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), *c.cfg.Timeout)
|
timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, *c.cfg.Timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||||
defer cancel()
|
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", u.String(), dataBuf)
|
hc := http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(timeoutCtx, "POST", u.String(), dataBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,11 +128,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := http.Client{}
|
cancelCtx, cancel := context.WithCancelCause(context.Background())
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), *c.cfg.Timeout)
|
timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, *c.cfg.Timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||||
defer cancel()
|
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", u.String(), dataBuf)
|
hc := http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(timeoutCtx, "POST", u.String(), dataBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,11 +89,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
|||||||
q.Set("token", token)
|
q.Set("token", token)
|
||||||
u.RawQuery = q.Encode()
|
u.RawQuery = q.Encode()
|
||||||
|
|
||||||
hc := http.Client{}
|
cancelCtx, cancel := context.WithCancelCause(context.Background())
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), *c.cfg.Timeout)
|
timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, *c.cfg.Timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||||
defer cancel()
|
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", u.String(), bytes.NewBuffer(jsonBody))
|
hc := http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(timeoutCtx, "POST", u.String(), bytes.NewBuffer(jsonBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,11 +81,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
|||||||
q := u.Query()
|
q := u.Query()
|
||||||
u.RawQuery = q.Encode()
|
u.RawQuery = q.Encode()
|
||||||
|
|
||||||
hc := http.Client{}
|
cancelCtx, cancel := context.WithCancelCause(context.Background())
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), *c.cfg.Timeout)
|
timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, *c.cfg.Timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||||
defer cancel()
|
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", u.String(), dataBuf)
|
hc := http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(timeoutCtx, "POST", u.String(), dataBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,11 +122,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
|||||||
}
|
}
|
||||||
u.Path = path.Join(u.Path, "api/v1/chat.postMessage")
|
u.Path = path.Join(u.Path, "api/v1/chat.postMessage")
|
||||||
|
|
||||||
hc := http.Client{}
|
cancelCtx, cancel := context.WithCancelCause(context.Background())
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), *c.cfg.Timeout)
|
timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, *c.cfg.Timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||||
defer cancel()
|
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", u.String(), dataBuf)
|
hc := http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(timeoutCtx, "POST", u.String(), dataBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/crazy-max/diun/v4/internal/model"
|
"github.com/crazy-max/diun/v4/internal/model"
|
||||||
"github.com/crazy-max/diun/v4/internal/msg"
|
"github.com/crazy-max/diun/v4/internal/msg"
|
||||||
"github.com/crazy-max/diun/v4/internal/notif/notifier"
|
"github.com/crazy-max/diun/v4/internal/notif/notifier"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client represents an active signalrest notification object
|
// Client represents an active signalrest notification object
|
||||||
@@ -62,11 +63,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := http.Client{}
|
cancelCtx, cancel := context.WithCancelCause(context.Background())
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), *c.cfg.Timeout)
|
timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, *c.cfg.Timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||||
defer cancel()
|
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", c.cfg.Endpoint, bytes.NewBuffer(body))
|
hc := http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(timeoutCtx, "POST", c.cfg.Endpoint, bytes.NewBuffer(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,11 +110,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := http.Client{}
|
cancelCtx, cancel := context.WithCancelCause(context.Background())
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(10)*time.Second)
|
timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, 10*time.Second, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||||
defer cancel()
|
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", webhookURL, bytes.NewBuffer(jsonBody))
|
hc := http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(timeoutCtx, "POST", webhookURL, bytes.NewBuffer(jsonBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/crazy-max/diun/v4/internal/model"
|
"github.com/crazy-max/diun/v4/internal/model"
|
||||||
"github.com/crazy-max/diun/v4/internal/msg"
|
"github.com/crazy-max/diun/v4/internal/msg"
|
||||||
"github.com/crazy-max/diun/v4/internal/notif/notifier"
|
"github.com/crazy-max/diun/v4/internal/notif/notifier"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client represents an active webhook notification object
|
// Client represents an active webhook notification object
|
||||||
@@ -47,11 +48,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := http.Client{}
|
cancelCtx, cancel := context.WithCancelCause(context.Background())
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), *c.cfg.Timeout)
|
timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, *c.cfg.Timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||||
defer cancel()
|
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", c.cfg.Endpoint, bytes.NewBuffer(body))
|
hc := http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(timeoutCtx, "POST", c.cfg.Endpoint, bytes.NewBuffer(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func newInClusterClient(opts Options) (*kubernetes.Clientset, error) {
|
|||||||
config.Host = opts.Endpoint
|
config.Host = opts.Endpoint
|
||||||
}
|
}
|
||||||
if opts.TLSInsecure != nil {
|
if opts.TLSInsecure != nil {
|
||||||
config.TLSClientConfig.Insecure = *opts.TLSInsecure
|
config.Insecure = *opts.TLSInsecure
|
||||||
}
|
}
|
||||||
|
|
||||||
return kubernetes.NewForConfig(config)
|
return kubernetes.NewForConfig(config)
|
||||||
@@ -80,7 +80,7 @@ func newExternalClusterClientFromFile(opts Options, file string) (*kubernetes.Cl
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if opts.TLSInsecure != nil {
|
if opts.TLSInsecure != nil {
|
||||||
configFromFlags.TLSClientConfig.Insecure = *opts.TLSInsecure
|
configFromFlags.Insecure = *opts.TLSInsecure
|
||||||
}
|
}
|
||||||
|
|
||||||
return kubernetes.NewForConfig(configFromFlags)
|
return kubernetes.NewForConfig(configFromFlags)
|
||||||
@@ -113,7 +113,7 @@ func newExternalClusterClient(opts Options) (*kubernetes.Clientset, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if opts.TLSInsecure != nil {
|
if opts.TLSInsecure != nil {
|
||||||
config.TLSClientConfig.Insecure = *opts.TLSInsecure
|
config.Insecure = *opts.TLSInsecure
|
||||||
}
|
}
|
||||||
|
|
||||||
return kubernetes.NewForConfig(config)
|
return kubernetes.NewForConfig(config)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/image/v5/types"
|
"github.com/containers/image/v5/types"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client represents an active docker registry object
|
// Client represents an active docker registry object
|
||||||
@@ -43,9 +44,11 @@ func New(opts Options) (*Client, error) {
|
|||||||
|
|
||||||
func (c *Client) timeoutContext() (context.Context, context.CancelFunc) {
|
func (c *Client) timeoutContext() (context.Context, context.CancelFunc) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
var cancel context.CancelFunc = func() {}
|
var cancelFunc context.CancelFunc = func() {}
|
||||||
if c.opts.Timeout > 0 {
|
if c.opts.Timeout > 0 {
|
||||||
ctx, cancel = context.WithTimeout(ctx, c.opts.Timeout)
|
cancelCtx, cancel := context.WithCancelCause(ctx)
|
||||||
|
ctx, _ = context.WithTimeoutCause(cancelCtx, c.opts.Timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||||
|
cancelFunc = func() { cancel(errors.WithStack(context.Canceled)) }
|
||||||
}
|
}
|
||||||
return ctx, cancel
|
return ctx, cancelFunc
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user