Skip to content

Commit

Permalink
allow lines length 200 (#82)
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Paskal <paskal.maksim@gmail.com>
  • Loading branch information
maksim-paskal committed May 3, 2024
1 parent 74dce44 commit 4c226ee
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ run:
timeout: 5m
issues:
fix: true
linters-settings:
lll:
line-length: 200
linters:
enable-all: true
disable:
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func addTaint(ctx context.Context, node *corev1.Node, taintKey string, taintValu
var err error

updateErr := wait.ExponentialBackoff(retry.DefaultBackoff, func() (bool, error) {
if freshNode, err = client.GetKubernetesClient().CoreV1().Nodes().Get(ctx, freshNode.Name, metav1.GetOptions{}); err != nil { //nolint:lll
if freshNode, err = client.GetKubernetesClient().CoreV1().Nodes().Get(ctx, freshNode.Name, metav1.GetOptions{}); err != nil {
nodeErr := errors.Wrapf(err, "failed to get node %s", freshNode.Name)
log.Error(nodeErr)

Expand Down
8 changes: 4 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ var config = Type{
WebHookURL: flag.String("webhook.url", os.Getenv("WEBHOOK_URL"), "send alerts to webhook"),
WebHookTimeout: flag.Duration("webhook.timeout", defaultWebHookTimeout, "request timeout"),
WebHookTemplate: flag.String("webhook.template", os.Getenv("WEBHOOK_TEMPLATE"), "request body"),
WebHookTemplateFile: flag.String("webhook.template-file", os.Getenv("WEBHOOK_TEMPLATE_FILE"), "path to request body template file"), //nolint:lll
WebHookTemplateFile: flag.String("webhook.template-file", os.Getenv("WEBHOOK_TEMPLATE_FILE"), "path to request body template file"),
SentryDSN: flag.String("sentry.dsn", "", "sentry DSN"),
WebHTTPAddress: flag.String("web.address", ":17923", ""),
TaintNode: flag.Bool("taint.node", false, "Taint the node before cordon and draining"),
TaintEffect: flag.String("taint.effect", "NoSchedule", "Taint effect to set on the node"),
PodGracePeriodSeconds: flag.Int("podGracePeriodSeconds", defaultPodGracePeriodSeconds, "grace period is seconds for pods termination"), //nolint:lll
NodeGracePeriodSeconds: flag.Int("nodeGracePeriodSeconds", defaultNodeGracePeriodSeconds, "maximum time in seconds to drain the node"), //nolint:lll
GracePeriodSeconds: flag.Int("gracePeriodSeconds", defaultGracePeriodSecond, "grace period is seconds for application termination"), //nolint:lll
PodGracePeriodSeconds: flag.Int("podGracePeriodSeconds", defaultPodGracePeriodSeconds, "grace period is seconds for pods termination"),
NodeGracePeriodSeconds: flag.Int("nodeGracePeriodSeconds", defaultNodeGracePeriodSeconds, "maximum time in seconds to drain the node"),
GracePeriodSeconds: flag.Int("gracePeriodSeconds", defaultGracePeriodSecond, "grace period is seconds for application termination"),
DrainOnFreezeEvent: flag.Bool("drainOnFreezeEvent", false, "drain node on freeze event"),
ResourceName: flag.String("resource.name", "", "Azure resource name to drain"),
ExitAfterNodeDrain: flag.Bool("exitAfterNodeDrain", false, "process will exit after node drain"),
Expand Down
2 changes: 1 addition & 1 deletion pkg/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (r *Reader) ReadEndpoint(ctx context.Context) (bool, error) {
// add to cache, ignore similar events for 10 minutes
cache.Add(event.EventId, eventCacheTTL)

metrics.ScheduledEventsTotal.WithLabelValues(append(r.getMetricsLabels(), string(event.EventType))...).Inc() //nolint:lll
metrics.ScheduledEventsTotal.WithLabelValues(append(r.getMetricsLabels(), string(event.EventType))...).Inc()

if r.EventReceived != nil {
return r.EventReceived(ctx, event)
Expand Down
2 changes: 1 addition & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (i *Instrumenter) InstrumentedRoundTripper() http.RoundTripper {
)
}

func (i *Instrumenter) instrumentRoundTripperEndpoint(counter *prometheus.CounterVec, next http.RoundTripper) promhttp.RoundTripperFunc { //nolint:lll
func (i *Instrumenter) instrumentRoundTripperEndpoint(counter *prometheus.CounterVec, next http.RoundTripper) promhttp.RoundTripperFunc {
return func(r *http.Request) (*http.Response, error) {
resp, err := next.RoundTrip(r)
if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ func printType(prefix string, message interface{}) {
func TestNewMessageType(t *testing.T) {
t.Parallel()

if _, err := template.NewMessageType(context.TODO(), "!!invalid!!GetNodeLabels", types.ScheduledEventsEvent{}); err == nil { //nolint:lll
if _, err := template.NewMessageType(context.TODO(), "!!invalid!!GetNodeLabels", types.ScheduledEventsEvent{}); err == nil {
t.Fatal("error expected")
}

if _, err := template.NewMessageType(context.TODO(), "!!invalid!!GetNodePods", types.ScheduledEventsEvent{}); err == nil { //nolint:lll
if _, err := template.NewMessageType(context.TODO(), "!!invalid!!GetNodePods", types.ScheduledEventsEvent{}); err == nil {
t.Fatal("error expected")
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ const (

// https://docs.microsoft.com/en-us/azure/virtual-machines/linux/scheduled-events
type ScheduledEventsEvent struct {
EventId string `description:"Globally unique identifier for this event."` //nolint:golint,revive,stylecheck,lll
EventId string `description:"Globally unique identifier for this event."` //nolint:golint,revive,stylecheck
EventType ScheduledEventsEventType `description:"Impact this event causes."`
ResourceType string `description:"Type of resource this event affects."`
Resources []string `description:"List of resources this event affects."`
EventStatus string `description:"Status of this event."`
NotBefore string `description:"Time after which this event can start. The event is guaranteed to not start before this time. Will be blank if the event has already started"` //nolint:lll
Description string `description:"Description of this event."`
EventSource string `description:"Initiator of the event."`
DurationInSeconds int `description:"The expected duration of the interruption caused by the event."` //nolint:lll
DurationInSeconds int `description:"The expected duration of the interruption caused by the event."`
}

var (
virtualMachineScaleSetsRe = regexp.MustCompile("^azure:///subscriptions/(.+)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines/(.+)$") //nolint:lll
virtualMachineRe = regexp.MustCompile("^azure:///subscriptions/(.+)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachines/(.+)$") //nolint:lll
virtualMachineScaleSetsRe = regexp.MustCompile("^azure:///subscriptions/(.+)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines/(.+)$")
virtualMachineRe = regexp.MustCompile("^azure:///subscriptions/(.+)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachines/(.+)$")
)

type AzureResource struct {
Expand Down

0 comments on commit 4c226ee

Please sign in to comment.