From 49d852ee02e327677a1c7cd1698e2398f4c7c72c Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Mon, 16 Jun 2025 13:28:02 -0400 Subject: [PATCH] lints --- cmd/zrok/accessPrivate.go | 43 +++++++++++++---------------- cmd/zrok/controllerMetricsBridge.go | 11 ++++---- cmd/zrok/enable.go | 2 +- cmd/zrok/invite.go | 8 +++--- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/cmd/zrok/accessPrivate.go b/cmd/zrok/accessPrivate.go index c06e2a2f..2af9a697 100644 --- a/cmd/zrok/accessPrivate.go +++ b/cmd/zrok/accessPrivate.go @@ -5,6 +5,12 @@ import ( "encoding/json" "errors" "fmt" + "net/url" + "os" + "os/signal" + "syscall" + "time" + tea "github.com/charmbracelet/bubbletea" "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" @@ -24,11 +30,6 @@ import ( "github.com/openziti/zrok/util" "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "net/url" - "os" - "os/signal" - "syscall" - "time" ) func init() { @@ -259,7 +260,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root) }() } - c := make(chan os.Signal) + c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGQUIT) go func() { <-c @@ -281,27 +282,21 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root) if cmd.headless { logrus.Infof("access the zrok share at the following endpoint: %v", endpointUrl.String()) - for { - select { - case req := <-requests: - logrus.Infof("%v -> %v %v", req.RemoteAddr, req.Method, req.Path) - } + for req := range requests { + logrus.Infof("%v -> %v %v", req.RemoteAddr, req.Method, req.Path) } } else if cmd.subordinate { - for { - select { - case req := <-requests: - data := make(map[string]interface{}) - data[subordinate.MessageKey] = "access" - data["remote-address"] = req.RemoteAddr - data["method"] = req.Method - data["path"] = req.Path - jsonData, err := json.Marshal(data) - if err != nil { - fmt.Println(err) - } - fmt.Println(string(jsonData)) + for req := range requests { + data := make(map[string]interface{}) + data[subordinate.MessageKey] = "access" + data["remote-address"] = req.RemoteAddr + data["method"] = req.Method + data["path"] = req.Path + jsonData, err := json.Marshal(data) + if err != nil { + fmt.Println(err) } + fmt.Println(string(jsonData)) } } else { mdl := newAccessModel(shrToken, endpointUrl.String()) diff --git a/cmd/zrok/controllerMetricsBridge.go b/cmd/zrok/controllerMetricsBridge.go index 1e59a01f..40bb5d0d 100644 --- a/cmd/zrok/controllerMetricsBridge.go +++ b/cmd/zrok/controllerMetricsBridge.go @@ -1,16 +1,17 @@ package main import ( + "os" + "os/signal" + "syscall" + "time" + "github.com/michaelquigley/cf" "github.com/openziti/zrok/controller/config" "github.com/openziti/zrok/controller/env" "github.com/openziti/zrok/controller/metrics" "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "os" - "os/signal" - "syscall" - "time" ) func init() { @@ -47,7 +48,7 @@ func (cmd *bridgeCommand) run(_ *cobra.Command, args []string) { panic(err) } - c := make(chan os.Signal) + c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { <-c diff --git a/cmd/zrok/enable.go b/cmd/zrok/enable.go index 0cd8f814..06f89b30 100644 --- a/cmd/zrok/enable.go +++ b/cmd/zrok/enable.go @@ -136,7 +136,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) { } if !cmd.headless && prg != nil { - prg.Send(fmt.Sprintf("the zrok environment was successfully enabled...")) + prg.Send("the zrok environment was successfully enabled...") prg.Quit() } else { logrus.Infof("the zrok environment was successfully enabled...") diff --git a/cmd/zrok/invite.go b/cmd/zrok/invite.go index 91b68605..32efbc81 100644 --- a/cmd/zrok/invite.go +++ b/cmd/zrok/invite.go @@ -2,6 +2,9 @@ package main import ( "fmt" + "os" + "strings" + "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" @@ -11,8 +14,6 @@ import ( "github.com/openziti/zrok/tui" "github.com/openziti/zrok/util" "github.com/spf13/cobra" - "os" - "strings" ) func init() { @@ -87,7 +88,7 @@ func (cmd *inviteCommand) run(_ *cobra.Command, _ []string) { } fmt.Printf("invitation sent to '%v'!\n\n", email) - fmt.Println(fmt.Sprintf("%v\n", tui.Attention.Render("*** be sure to check your SPAM folder if you do not receive the invitation email!"))) + fmt.Printf("%v\n", tui.Attention.Render("*** be sure to check your SPAM folder if you do not receive the invitation email!")) } } @@ -104,7 +105,6 @@ type inviteTui struct { msg string emailInputs []textinput.Model tokenInput textinput.Model - cursorMode textinput.CursorMode done bool invitesOpen bool requireInviteToken bool