Skip to content

Commit

Permalink
remove dead code and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
theFong committed Nov 15, 2024
1 parent 268cccd commit 14ed1ec
Show file tree
Hide file tree
Showing 15 changed files with 9 additions and 146 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ require (
golang.org/x/crypto v0.24.0
golang.org/x/text v0.16.0
k8s.io/cli-runtime v0.31.1
k8s.io/client-go v0.31.1
)

require (
Expand Down Expand Up @@ -110,6 +109,7 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
gotest.tools/v3 v3.4.0 // indirect
k8s.io/apimachinery v0.31.1 // indirect
k8s.io/client-go v0.31.1 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/auth/kas.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (a KasAuthenticator) MakeLoginCall(id, email string) (LoginCallResponse, er
}

// Create a new POST request with JSON payload
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) //nolint:noctx // fine
if err != nil {
return LoginCallResponse{}, breverrors.WrapAndTrace(err)
}
Expand All @@ -93,7 +93,7 @@ func (a KasAuthenticator) MakeLoginCall(id, email string) (LoginCallResponse, er
if err != nil {
return LoginCallResponse{}, breverrors.WrapAndTrace(err)
}
defer resp.Body.Close()
defer resp.Body.Close() //nolint:errcheck // fine

// Read the response body
body, err := io.ReadAll(resp.Body)
Expand Down Expand Up @@ -196,7 +196,7 @@ type RetrieveIDTokenResponse struct {
func (a KasAuthenticator) retrieveIDToken(sessionKey, deviceID string) (string, error) {
tokenURL := fmt.Sprintf("%s/token", a.BaseURL)
client := &http.Client{}
tokenReq, err := http.NewRequest("GET", tokenURL, nil)
tokenReq, err := http.NewRequest("GET", tokenURL, nil) //nolint:noctx // fine
if err != nil {
return "", fmt.Errorf("error creating token request: %v", err)
}
Expand All @@ -208,7 +208,7 @@ func (a KasAuthenticator) retrieveIDToken(sessionKey, deviceID string) (string,
if err != nil {
return "", fmt.Errorf("error sending token request: %v", err)
}
defer tokenResp.Body.Close()
defer tokenResp.Body.Close() //nolint:errcheck // fine

tokenBody, err := io.ReadAll(tokenResp.Body)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pkg/cmd/cmderrors/cmderrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (

// determines if should print error stack trace and/or send to crash monitor

//nolint:wrapcheck //no check

func DisplayAndHandleError(err error) {
er := breverrors.GetDefaultErrorReporter()
er.AddBreadCrumb(breverrors.ErrReportBreadCrumb{
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/tasks/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/brevdev/brev-cli/pkg/cmd/cmderrors"
"github.com/brevdev/brev-cli/pkg/entity"
breverrors "github.com/brevdev/brev-cli/pkg/errors"
"github.com/brevdev/brev-cli/pkg/k8s"
"github.com/brevdev/brev-cli/pkg/ssh"
"github.com/brevdev/brev-cli/pkg/tasks"
"github.com/brevdev/brev-cli/pkg/terminal"
Expand All @@ -20,7 +19,7 @@ type TaskMap map[string]tasks.Task
var all bool // used for run command

type TaskStore interface {
k8s.K8sStore
GetCurrentUserKeys() (*entity.UserKeys, error)
CopyBin(targetBin string) error
WriteString(path, data string) error
GetOrCreateFile(path string) (afero.File, error)
Expand Down
26 changes: 0 additions & 26 deletions pkg/cmd/textceo/textceo.go

This file was deleted.

1 change: 0 additions & 1 deletion pkg/cmd/textceo/textceo_test.go

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/collections/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"net/http"
"sort"
"sync"
"time"

"github.com/brevdev/brev-cli/pkg/errors"
Expand Down Expand Up @@ -297,11 +296,6 @@ type ContextKey string

const IdempotencyKeyName ContextKey = "idempotencyKey"

type SafeCounter struct {
mu sync.Mutex
c int
}

type AsyncResult[T any] struct {
result chan result[T]
}
Expand All @@ -326,10 +320,6 @@ func (ar *AsyncResult[T]) Await() (T, error) {
return r.value, r.err
}

type Rollback struct {
undos []func() error
}

var (
// ErrCanceled is the error returned when the context is canceled.
ErrCanceled = context.Canceled
Expand Down
27 changes: 2 additions & 25 deletions pkg/entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"path"
"path/filepath"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -182,31 +181,14 @@ type User struct {
}

type UserKeys struct {
PrivateKey string `json:"privateKey"`
PublicKey string `json:"publicKey"`
WorkspaceGroups []WorkspaceGroupKeys `json:"workspaceGroups"`
}

type WorkspaceGroupKeys struct {
GroupID string `json:"groupId"`
Cert string `json:"cert"`
CA string `json:"ca"`
APIURL string `json:"apiUrl"`
PrivateKey string `json:"privateKey"`
PublicKey string `json:"publicKey"`
}

func (v VscodeExtensionMetadata) GetID() string {
return fmt.Sprintf("%s.%s", v.Publisher, v.Name)
}

func (u UserKeys) GetWorkspaceGroupKeysByGroupID(groupID string) (*WorkspaceGroupKeys, error) {
for _, wgk := range u.WorkspaceGroups {
if wgk.GroupID == groupID {
return &wgk, nil
}
}
return nil, fmt.Errorf("group id %s not found", groupID)
}

type Organization struct {
ID string `json:"id"`
Name string `json:"name"`
Expand Down Expand Up @@ -497,11 +479,6 @@ func (w Workspace) GetHostIdentifier() WorkspaceLocalID {
return w.createSimpleName() + "-host"
}

var (
whitespaceCharPattern = regexp.MustCompile(`\s+`)
invalidCharPattern = regexp.MustCompile(`[^a-z0-9-]`)
)

// lowercase, replace whitespace with '-', remove all [^a-z0-9-], trim '-' front and back

func (w Workspace) GetID() string {
Expand Down
46 changes: 0 additions & 46 deletions pkg/k8s/client.go

This file was deleted.

10 changes: 1 addition & 9 deletions pkg/portforward/portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@ package portforward
import (
"net/url"

"github.com/brevdev/brev-cli/pkg/k8s"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

type PortForwardOptions struct {
PortForwarder PortForwarder
WorkspaceGroupClientMapper k8s.WorkspaceGroupClientMapper

K8sClient k8s.K8sClient
K8sAPIURL string

Namespace string
PodName string
PortForwarder PortForwarder

Address []string
Ports []string
Expand Down
2 changes: 0 additions & 2 deletions pkg/prefixid/prefixid.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ package prefixid

type PrefixID string

const prefixSep = "-"

// New generates a unique ID that can be used as an identifier for an entity.
4 changes: 0 additions & 4 deletions pkg/ssh/sshconfigurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,6 @@ func doesUserSSHConfigIncludeBrevConfig(conf string, brevConfigPath string) bool
return strings.Contains(conf, makeIncludeBrevStr(brevConfigPath))
}

type SSHConfigurerServiceMesh struct {
store SSHConfigurerV2Store
}

// Deprecated: var _ Config = SSHConfigurerServiceMesh{}

// openssh-7.3
Expand Down
4 changes: 0 additions & 4 deletions pkg/store/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ type NoAuthHTTPClient struct {
restyClient *resty.Client
}

type OllamaHTTPClient struct {
restyClient *resty.Client
}

func NewNoAuthHTTPClient(brevAPIURL string) *NoAuthHTTPClient {
restyClient := NewRestyClient(brevAPIURL)
return &NoAuthHTTPClient{restyClient}
Expand Down
8 changes: 0 additions & 8 deletions pkg/store/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ func TestGetCurrentUserKeys(t *testing.T) {
expected := &entity.UserKeys{
PrivateKey: "priv",
PublicKey: "pub",
WorkspaceGroups: []entity.WorkspaceGroupKeys{
{
GroupID: "gi",
Cert: "cert",
CA: "ca",
APIURL: "url",
},
},
}
res, err := httpmock.NewJsonResponder(200, expected)
if !assert.Nil(t, err) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ func (t *Terminal) Errprint(err error, a string) {
}
}

type silentWriter struct{}

func (t *Terminal) NewSpinner() *spinner.Spinner {
spinner := spinner.New(spinner.CharSets[11], 100*time.Millisecond, spinner.WithWriter(os.Stderr))
err := spinner.Color("cyan", "bold")
Expand Down

0 comments on commit 14ed1ec

Please sign in to comment.