Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c493bf9

Browse files
committed
Fix linting errors
1 parent aac220f commit c493bf9

File tree

9 files changed

+34
-32
lines changed

9 files changed

+34
-32
lines changed

cli/clitest/clitest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func extractTar(data []byte, directory string) error {
9696
if err != nil {
9797
return xerrors.Errorf("read project source archive: %w", err)
9898
}
99+
// #nosec
99100
path := filepath.Join(directory, header.Name)
100101
mode := header.FileInfo().Mode()
101102
if mode == 0 {

cli/login_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package cli_test
33
import (
44
"testing"
55

6+
"github.com/stretchr/testify/require"
7+
68
"github.com/coder/coder/cli/clitest"
79
"github.com/coder/coder/coderd/coderdtest"
8-
"github.com/stretchr/testify/require"
910

1011
"github.com/ActiveState/termtest/expect"
1112
)

cli/projectcreate.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,29 @@ func projectCreate() *cobra.Command {
112112
cmd.Flags().StringVarP(&directory, "directory", "d", currentDirectory, "Specify the directory to create from")
113113
cmd.Flags().StringVarP(&provisioner, "provisioner", "p", "terraform", "Customize the provisioner backend")
114114
// This is for testing! There's only 1 provisioner type right now.
115-
cmd.Flags().MarkHidden("provisioner")
116-
115+
err := cmd.Flags().MarkHidden("provisioner")
116+
if err != nil {
117+
panic(err)
118+
}
117119
return cmd
118120
}
119121

120122
func validateProjectVersionSource(cmd *cobra.Command, client *codersdk.Client, organization coderd.Organization, provisioner database.ProvisionerType, directory string, parameters ...coderd.CreateParameterValueRequest) (*coderd.ProvisionerJob, error) {
121123
spin := spinner.New(spinner.CharSets[5], 100*time.Millisecond)
122124
spin.Writer = cmd.OutOrStdout()
123125
spin.Suffix = " Uploading current directory..."
124-
spin.Color("fgHiGreen")
126+
err := spin.Color("fgHiGreen")
127+
if err != nil {
128+
return nil, err
129+
}
125130
spin.Start()
126131
defer spin.Stop()
127132

128-
bytes, err := tarDirectory(directory)
133+
tarData, err := tarDirectory(directory)
129134
if err != nil {
130135
return nil, err
131136
}
132-
133-
resp, err := client.UploadFile(cmd.Context(), codersdk.ContentTypeTar, bytes)
137+
resp, err := client.UploadFile(cmd.Context(), codersdk.ContentTypeTar, tarData)
134138
if err != nil {
135139
return nil, err
136140
}

cli/projectcreate_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"testing"
55

66
"github.com/ActiveState/termtest/expect"
7+
"github.com/stretchr/testify/require"
8+
79
"github.com/coder/coder/cli/clitest"
810
"github.com/coder/coder/coderd/coderdtest"
911
"github.com/coder/coder/database"
1012
"github.com/coder/coder/provisioner/echo"
1113
"github.com/coder/coder/provisionersdk/proto"
12-
"github.com/stretchr/testify/require"
1314
)
1415

1516
func TestProjectCreate(t *testing.T) {
@@ -19,13 +20,13 @@ func TestProjectCreate(t *testing.T) {
1920
console, err := expect.NewConsole(expect.WithStdout(clitest.StdoutLogs(t)))
2021
require.NoError(t, err)
2122
client := coderdtest.New(t)
22-
_ = coderdtest.NewProvisionerDaemon(t, client)
2323
source := clitest.CreateProjectVersionSource(t, &echo.Responses{
2424
Parse: echo.ParseComplete,
2525
Provision: echo.ProvisionComplete,
2626
})
2727
cmd, root := clitest.New(t, "projects", "create", "--directory", source, "--provisioner", string(database.ProvisionerTypeEcho))
2828
_ = clitest.CreateInitialUser(t, client, root)
29+
_ = coderdtest.NewProvisionerDaemon(t, client)
2930
cmd.SetIn(console.Tty())
3031
cmd.SetOut(console.Tty())
3132
closeChan := make(chan struct{})
@@ -57,7 +58,6 @@ func TestProjectCreate(t *testing.T) {
5758
console, err := expect.NewConsole(expect.WithStdout(clitest.StdoutLogs(t)))
5859
require.NoError(t, err)
5960
client := coderdtest.New(t)
60-
_ = coderdtest.NewProvisionerDaemon(t, client)
6161
source := clitest.CreateProjectVersionSource(t, &echo.Responses{
6262
Parse: []*proto.Parse_Response{{
6363
Type: &proto.Parse_Response_Complete{
@@ -75,6 +75,7 @@ func TestProjectCreate(t *testing.T) {
7575
})
7676
cmd, root := clitest.New(t, "projects", "create", "--directory", source, "--provisioner", string(database.ProvisionerTypeEcho))
7777
_ = clitest.CreateInitialUser(t, client, root)
78+
_ = coderdtest.NewProvisionerDaemon(t, client)
7879
cmd.SetIn(console.Tty())
7980
cmd.SetOut(console.Tty())
8081
closeChan := make(chan struct{})

cli/projects.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/coder/coder/coderd"
8-
"github.com/coder/coder/database"
97
"github.com/fatih/color"
108
"github.com/spf13/cobra"
119
"github.com/xlab/treeprint"
1210
"golang.org/x/xerrors"
11+
12+
"github.com/coder/coder/coderd"
13+
"github.com/coder/coder/database"
1314
)
1415

1516
func projects() *cobra.Command {

cli/workspacecreate.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"fmt"
66
"time"
77

8-
"github.com/coder/coder/coderd"
9-
"github.com/coder/coder/database"
108
"github.com/fatih/color"
119
"github.com/google/uuid"
1210
"github.com/manifoldco/promptui"
1311
"github.com/spf13/cobra"
1412
"golang.org/x/xerrors"
13+
14+
"github.com/coder/coder/coderd"
15+
"github.com/coder/coder/database"
1516
)
1617

1718
func workspaceCreate() *cobra.Command {
@@ -108,17 +109,17 @@ func workspaceCreate() *cobra.Command {
108109
if err != nil {
109110
return err
110111
}
111-
logBuffer := make([]coderd.ProvisionerJobLog, 0, 64)
112+
// logBuffer := make([]coderd.ProvisionerJobLog, 0, 64)
112113
for {
113114
log, ok := <-logs
114115
if !ok {
115116
break
116117
}
117-
fmt.Printf("Logging: %s\n", log.Output)
118-
logBuffer = append(logBuffer, log)
118+
_, _ = fmt.Printf("Logging: %s\n", log.Output)
119+
// logBuffer = append(logBuffer, log)
119120
}
120121

121-
fmt.Printf("Create workspace! %s\n", name)
122+
_, _ = fmt.Printf("Create workspace! %s\n", name)
122123

123124
return nil
124125
},

coderd/provisionerdaemons.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ func (server *provisionerdServer) AcquireJob(ctx context.Context, _ *proto.Empty
219219
}
220220
// Convert parameters to the protobuf type.
221221
protoParameters := make([]*sdkproto.ParameterValue, 0, len(parameters))
222-
for _, parameter := range parameters {
223-
converted, err := convertComputedParameterValue(parameter)
222+
for _, computedParameter := range parameters {
223+
converted, err := convertComputedParameterValue(computedParameter)
224224
if err != nil {
225225
return nil, failJob(fmt.Sprintf("convert parameter: %s", err))
226226
}
@@ -371,8 +371,8 @@ func (server *provisionerdServer) UpdateJob(ctx context.Context, request *proto.
371371
}
372372
// Convert parameters to the protobuf type.
373373
protoParameters := make([]*sdkproto.ParameterValue, 0, len(parameters))
374-
for _, parameter := range parameters {
375-
converted, err := convertComputedParameterValue(parameter)
374+
for _, computedParameter := range parameters {
375+
converted, err := convertComputedParameterValue(computedParameter)
376376
if err != nil {
377377
return nil, xerrors.Errorf("convert parameter: %s", err)
378378
}
@@ -597,7 +597,7 @@ func convertLogSource(logSource proto.LogSource) (database.LogSource, error) {
597597
}
598598

599599
func convertComputedParameterValue(param parameter.ComputedValue) (*sdkproto.ParameterValue, error) {
600-
scheme := sdkproto.ParameterDestination_ENVIRONMENT_VARIABLE
600+
var scheme sdkproto.ParameterDestination_Scheme
601601
switch param.DestinationScheme {
602602
case database.ParameterDestinationSchemeEnvironmentVariable:
603603
scheme = sdkproto.ParameterDestination_ENVIRONMENT_VARIABLE

codersdk/provisioners_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,3 @@ func TestFollowProvisionerJobLogsAfter(t *testing.T) {
106106
require.False(t, ok)
107107
})
108108
}
109-
110-
func TestProvisionerJobParameterSchemas(t *testing.T) {
111-
t.Parallel()
112-
t.Run("Error", func(t *testing.T) {
113-
114-
})
115-
}

database/databasefake/databasefake.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func (q *fakeQuerier) GetProjectByOrganizationAndName(_ context.Context, arg dat
401401
return database.Project{}, sql.ErrNoRows
402402
}
403403

404-
func (q *fakeQuerier) GetProjectImportJobResourcesByJobID(ctx context.Context, jobID uuid.UUID) ([]database.ProjectImportJobResource, error) {
404+
func (q *fakeQuerier) GetProjectImportJobResourcesByJobID(_ context.Context, jobID uuid.UUID) ([]database.ProjectImportJobResource, error) {
405405
q.mutex.Lock()
406406
defer q.mutex.Unlock()
407407

@@ -685,7 +685,7 @@ func (q *fakeQuerier) InsertProject(_ context.Context, arg database.InsertProjec
685685
return project, nil
686686
}
687687

688-
func (q *fakeQuerier) InsertProjectImportJobResource(ctx context.Context, arg database.InsertProjectImportJobResourceParams) (database.ProjectImportJobResource, error) {
688+
func (q *fakeQuerier) InsertProjectImportJobResource(_ context.Context, arg database.InsertProjectImportJobResourceParams) (database.ProjectImportJobResource, error) {
689689
q.mutex.Lock()
690690
defer q.mutex.Unlock()
691691

0 commit comments

Comments
 (0)