Skip to content

Commit

Permalink
chore(atlantis): fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
GMartinez-Sisti committed Aug 21, 2023
1 parent 233273f commit e9685c8
Show file tree
Hide file tree
Showing 36 changed files with 152 additions and 150 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
fail_on_error: true
tool_name: golangci-lint
2 changes: 1 addition & 1 deletion cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var passedConfig server.UserConfig

type ServerCreatorMock struct{}

func (s *ServerCreatorMock) NewServer(userConfig server.UserConfig, config server.Config) (ServerStarter, error) {
func (s *ServerCreatorMock) NewServer(userConfig server.UserConfig, _ server.Config) (ServerStarter, error) {
passedConfig = userConfig
return &ServerStarterMock{}, nil
}
Expand Down
8 changes: 4 additions & 4 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ var mockPreWorkflowHookRunner *runtimemocks.MockPreWorkflowHookRunner

var mockPostWorkflowHookRunner *runtimemocks.MockPostWorkflowHookRunner

func (m *NoopTFDownloader) GetFile(dst, src string) error {
func (m *NoopTFDownloader) GetFile(_, _ string) error {
return nil
}

func (m *NoopTFDownloader) GetAny(dst, src string) error {
func (m *NoopTFDownloader) GetAny(_, _ string) error {
return nil
}

Expand Down Expand Up @@ -1541,13 +1541,13 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers

type mockLockURLGenerator struct{}

func (m *mockLockURLGenerator) GenerateLockURL(lockID string) string {
func (m *mockLockURLGenerator) GenerateLockURL(_ string) string {
return "lock-url"
}

type mockWebhookSender struct{}

func (w *mockWebhookSender) Send(log logging.SimpleLogging, result webhooks.ApplyResult) error {
func (w *mockWebhookSender) Send(_ logging.SimpleLogging, _ webhooks.ApplyResult) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion server/controllers/github_app_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (g *GithubAppController) ExchangeCode(w http.ResponseWriter, r *http.Reques
}

// New redirects the user to create a new GitHub app
func (g *GithubAppController) New(w http.ResponseWriter, r *http.Request) {
func (g *GithubAppController) New(w http.ResponseWriter, _ *http.Request) {

if g.GithubSetupComplete {
g.respond(w, logging.Error, http.StatusBadRequest, "Atlantis already has GitHub credentials")
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/locks_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type LocksController struct {

// LockApply handles creating a global apply lock.
// If Lock already exists it will be a no-op
func (l *LocksController) LockApply(w http.ResponseWriter, r *http.Request) {
func (l *LocksController) LockApply(w http.ResponseWriter, _ *http.Request) {
lock, err := l.ApplyLocker.LockApply()
if err != nil {
l.respond(w, logging.Error, http.StatusInternalServerError, "creating apply lock failed with: %s", err)
Expand All @@ -44,7 +44,7 @@ func (l *LocksController) LockApply(w http.ResponseWriter, r *http.Request) {

// UnlockApply handles releasing a global apply lock.
// If Lock doesn't exists it will be a no-op
func (l *LocksController) UnlockApply(w http.ResponseWriter, r *http.Request) {
func (l *LocksController) UnlockApply(w http.ResponseWriter, _ *http.Request) {
err := l.ApplyLocker.UnlockApply()
if err != nil {
l.respond(w, logging.Error, http.StatusInternalServerError, "deleting apply lock failed with: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/status_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type StatusResponse struct {
}

// Get is the GET /status route.
func (d *StatusController) Get(w http.ResponseWriter, r *http.Request) {
func (d *StatusController) Get(w http.ResponseWriter, _ *http.Request) {
status := d.Drainer.GetStatus()
data, err := json.MarshalIndent(&StatusResponse{
ShuttingDown: status.ShuttingDown,
Expand Down
6 changes: 3 additions & 3 deletions server/core/config/raw/global_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ OuterGlobalPlanReqs:
}

// dont add policy_check step if repo have it explicitly disabled
if globalReq == valid.PoliciesPassedCommandReq && r.PolicyCheck != nil && *r.PolicyCheck == false {
if globalReq == valid.PoliciesPassedCommandReq && r.PolicyCheck != nil && !*r.PolicyCheck {
continue
}
mergedPlanReqs = append(mergedPlanReqs, globalReq)
Expand All @@ -294,7 +294,7 @@ OuterGlobalApplyReqs:
}

// dont add policy_check step if repo have it explicitly disabled
if globalReq == valid.PoliciesPassedCommandReq && r.PolicyCheck != nil && *r.PolicyCheck == false {
if globalReq == valid.PoliciesPassedCommandReq && r.PolicyCheck != nil && !*r.PolicyCheck {
continue
}
mergedApplyReqs = append(mergedApplyReqs, globalReq)
Expand All @@ -308,7 +308,7 @@ OuterGlobalImportReqs:
}

// dont add policy_check step if repo have it explicitly disabled
if globalReq == valid.PoliciesPassedCommandReq && r.PolicyCheck != nil && *r.PolicyCheck == false {
if globalReq == valid.PoliciesPassedCommandReq && r.PolicyCheck != nil && !*r.PolicyCheck {
continue
}
mergedImportReqs = append(mergedImportReqs, globalReq)
Expand Down
12 changes: 6 additions & 6 deletions server/core/config/raw/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ const (
//
// 2. A map for an env step with name and command or value, or a run step with a command and output config
// - env:
// name: test
// command: echo 312
// value: value
// name: test
// command: echo 312
// value: value
// - run:
// command: my custom command
// output: hide
// command: my custom command
// output: hide
//
// 3. A map for a built-in command and extra_args:
// - plan:
// extra_args: [-var-file=staging.tfvars]
// extra_args: [-var-file=staging.tfvars]
//
// 4. A map for a custom run command:
// - run: my custom command
Expand Down
14 changes: 7 additions & 7 deletions server/core/db/boltdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ func TestUnlockingMultiple(t *testing.T) {
_, _, err := b.TryLock(lock)
Ok(t, err)

new := lock
new.Project.RepoFullName = "new/repo"
_, _, err = b.TryLock(new)
new1 := lock
new1.Project.RepoFullName = "new/repo"
_, _, err = b.TryLock(new1)
Ok(t, err)

new2 := lock
Expand All @@ -306,7 +306,7 @@ func TestUnlockingMultiple(t *testing.T) {
Ok(t, err)
_, err = b.Unlock(new2.Project, workspace)
Ok(t, err)
_, err = b.Unlock(new.Project, workspace)
_, err = b.Unlock(new1.Project, workspace)
Ok(t, err)
_, err = b.Unlock(project, workspace)
Ok(t, err)
Expand Down Expand Up @@ -383,9 +383,9 @@ func TestUnlockByPullMatching(t *testing.T) {
Ok(t, err)

// add additional locks with the same repo and pull num but different paths/workspaces
new := lock
new.Project.Path = "dif/path"
_, _, err = b.TryLock(new)
new1 := lock
new1.Project.Path = "dif/path"
_, _, err = b.TryLock(new1)
Ok(t, err)
new2 := lock
new2.Workspace = "new-workspace"
Expand Down
8 changes: 4 additions & 4 deletions server/core/locking/locking.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ func NewNoOpLocker() *NoOpLocker {
}

// TryLock attempts to acquire a lock to a project and workspace.
func (c *NoOpLocker) TryLock(p models.Project, workspace string, pull models.PullRequest, user models.User) (TryLockResponse, error) {
func (c *NoOpLocker) TryLock(p models.Project, workspace string, _ models.PullRequest, _ models.User) (TryLockResponse, error) {
return TryLockResponse{true, models.ProjectLock{}, c.key(p, workspace)}, nil
}

// Unlock attempts to unlock a project and workspace. If successful,
// a pointer to the now deleted lock will be returned. Else, that
// pointer will be nil. An error will only be returned if there was
// an error deleting the lock (i.e. not if there was no lock).
func (c *NoOpLocker) Unlock(key string) (*models.ProjectLock, error) {
func (c *NoOpLocker) Unlock(_ string) (*models.ProjectLock, error) {
return &models.ProjectLock{}, nil
}

Expand All @@ -186,15 +186,15 @@ func (c *NoOpLocker) List() (map[string]models.ProjectLock, error) {
}

// UnlockByPull deletes all locks associated with that pull request.
func (c *NoOpLocker) UnlockByPull(repoFullName string, pullNum int) ([]models.ProjectLock, error) {
func (c *NoOpLocker) UnlockByPull(_ string, _ int) ([]models.ProjectLock, error) {
return []models.ProjectLock{}, nil
}

// GetLock attempts to get the lock stored at key. If successful,
// a pointer to the lock will be returned. Else, the pointer will be nil.
// An error will only be returned if there was an error getting the lock
// (i.e. not if there was no lock).
func (c *NoOpLocker) GetLock(key string) (*models.ProjectLock, error) {
func (c *NoOpLocker) GetLock(_ string) (*models.ProjectLock, error) {
return nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion server/core/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func New(hostname string, port int, password string, tlsEnabled bool, insecureSk
}

// NewWithClient is used for testing.
func NewWithClient(client *redis.Client, bucket string, globalBucket string) (*RedisDB, error) {
func NewWithClient(client *redis.Client, _ string, _ string) (*RedisDB, error) {
return &RedisDB{
client: client,
}, nil
Expand Down
14 changes: 7 additions & 7 deletions server/core/redis/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ func TestUnlockingMultiple(t *testing.T) {
_, _, err := rdb.TryLock(lock)
Ok(t, err)

new := lock
new.Project.RepoFullName = "new/repo"
_, _, err = rdb.TryLock(new)
new1 := lock
new1.Project.RepoFullName = "new/repo"
_, _, err = rdb.TryLock(new1)
Ok(t, err)

new2 := lock
Expand All @@ -342,7 +342,7 @@ func TestUnlockingMultiple(t *testing.T) {
Ok(t, err)
_, err = rdb.Unlock(new2.Project, workspace)
Ok(t, err)
_, err = rdb.Unlock(new.Project, workspace)
_, err = rdb.Unlock(new1.Project, workspace)
Ok(t, err)
_, err = rdb.Unlock(project, workspace)
Ok(t, err)
Expand Down Expand Up @@ -419,9 +419,9 @@ func TestUnlockByPullMatching(t *testing.T) {
Ok(t, err)

// add additional locks with the same repo and pull num but different paths/workspaces
new := lock
new.Project.Path = "dif/path"
_, _, err = rdb.TryLock(new)
new1 := lock
new1.Project.Path = "dif/path"
_, _, err = rdb.TryLock(new1)
Ok(t, err)
new2 := lock
new2.Workspace = "new-workspace"
Expand Down
2 changes: 1 addition & 1 deletion server/core/runtime/apply_step_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ type remoteApplyMock struct {
}

// RunCommandAsync fakes out running terraform async.
func (r *remoteApplyMock) RunCommandAsync(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan runtimemodels.Line) {
func (r *remoteApplyMock) RunCommandAsync(_ command.ProjectContext, _ string, args []string, _ map[string]string, _ *version.Version, _ string) (chan<- string, <-chan runtimemodels.Line) {
r.CalledArgs = args

in := make(chan string)
Expand Down
4 changes: 2 additions & 2 deletions server/core/runtime/plan_step_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ locally at this time.
tfVersion: "1.1.0",
remoteOpsErr: `╷
│ Error: Saving a generated plan is currently not supported
│ Terraform Cloud does not support saving the generated execution plan
│ locally at this time.
Expand Down Expand Up @@ -545,7 +545,7 @@ type remotePlanMock struct {
CalledArgs []string
}

func (r *remotePlanMock) RunCommandAsync(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan runtimemodels.Line) {
func (r *remotePlanMock) RunCommandAsync(_ command.ProjectContext, _ string, args []string, _ map[string]string, _ *version.Version, _ string) (chan<- string, <-chan runtimemodels.Line) {
r.CalledArgs = args
in := make(chan string)
out := make(chan runtimemodels.Line)
Expand Down
4 changes: 2 additions & 2 deletions server/core/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ type Runner interface {
// NullRunner is a runner that isn't configured for a given plan type but outputs nothing
type NullRunner struct{}

func (p NullRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
func (p NullRunner) Run(ctx command.ProjectContext, _ []string, _ string, _ map[string]string) (string, error) {
ctx.Log.Debug("runner not configured for plan type")
return "", nil
}

// RemoteBackendUnsupportedRunner is a runner that is responsible for outputting that the remote backend is unsupported
type RemoteBackendUnsupportedRunner struct{}

func (p RemoteBackendUnsupportedRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
func (p RemoteBackendUnsupportedRunner) Run(ctx command.ProjectContext, _ []string, _ string, _ map[string]string) (string, error) {
ctx.Log.Debug("runner not configured for remote backend")
return "Remote backend is unsupported for this step.", nil
}
Expand Down
2 changes: 1 addition & 1 deletion server/core/runtime/show_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type showStepRunner struct {
defaultTFVersion *version.Version
}

func (p *showStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
func (p *showStepRunner) Run(ctx command.ProjectContext, _ []string, path string, envs map[string]string) (string, error) {
tfVersion := p.defaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
Expand Down
2 changes: 1 addition & 1 deletion server/core/runtime/version_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type VersionStepRunner struct {
}

// Run ensures a given version for the executable, builds the args from the project context and then runs executable returning the result
func (v *VersionStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
func (v *VersionStepRunner) Run(ctx command.ProjectContext, _ []string, path string, envs map[string]string) (string, error) {
tfVersion := v.DefaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
Expand Down
Loading

0 comments on commit e9685c8

Please sign in to comment.