Skip to content

Commit

Permalink
Remove unused feature flags (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayyush authored Mar 3, 2022
1 parent 4ccd1fd commit 8ff637a
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ null_resource.automerge[0]: Creation complete after *s [id=*******************]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.


```

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ null_resource.automerge[0]: Creation complete after *s [id=*******************]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.


```

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Terraform will perform the following actions:

Plan: 1 to add, 0 to change, 0 to destroy.


```

* :arrow_forward: To **apply** this plan, comment:
Expand Down Expand Up @@ -50,6 +51,7 @@ Terraform will perform the following actions:

Plan: 1 to add, 0 to change, 0 to destroy.


```

* :arrow_forward: To **apply** this plan, comment:
Expand Down
8 changes: 1 addition & 7 deletions server/core/terraform/terraform_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,9 @@ func (c *DefaultClient) EnsureVersion(log logging.SimpleLogging, v *version.Vers

// See Client.RunCommandWithVersion.
func (c *DefaultClient) RunCommandWithVersion(ctx command.ProjectContext, path string, args []string, customEnvVars map[string]string, v *version.Version, workspace string) (string, error) {
shouldAllocate, err := c.featureAllocator.ShouldAllocate(feature.LogStreaming, ctx.BaseRepo.FullName)

if err != nil {
ctx.Log.Err("unable to allocate for feature: %s, error: %s", feature.LogStreaming, err)
}

// if the feature is enabled, we use the async workflow else we default to the original sync workflow
// Don't stream terraform show output to outCh
if shouldAllocate && isAsyncEligibleCommand(args[0]) {
if len(args) > 0 && isAsyncEligibleCommand(args[0]) {
outCh := c.RunCommandAsync(ctx, path, args, customEnvVars, v, workspace)

var lines []string
Expand Down
3 changes: 0 additions & 3 deletions server/core/terraform/terraform_client_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/runatlantis/atlantis/server/events/models"
jobmocks "github.com/runatlantis/atlantis/server/jobs/mocks"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/lyft/feature"
fmocks "github.com/runatlantis/atlantis/server/lyft/feature/mocks"
. "github.com/runatlantis/atlantis/testing"
)
Expand Down Expand Up @@ -50,7 +49,6 @@ func TestDefaultClient_Synchronous_RunCommandWithVersion(t *testing.T) {
AsyncClient: asyncClient,
featureAllocator: allocator,
}
When(allocator.ShouldAllocate(feature.LogStreaming, "owner/repo")).ThenReturn(false, nil)
When(mockBuilder.Build(nil, workspace, path, args)).ThenReturn(echoCommand, nil)

customEnvVars := map[string]string{}
Expand Down Expand Up @@ -126,7 +124,6 @@ func TestDefaultClient_Synchronous_RunCommandWithVersion_Error(t *testing.T) {
featureAllocator: allocator,
}

When(allocator.ShouldAllocate(feature.LogStreaming, "owner/repo")).ThenReturn(false, nil)
When(mockBuilder.Build(nil, workspace, path, args)).ThenReturn(echoCommand, nil)
out, err := client.RunCommandWithVersion(ctx, path, args, map[string]string{}, nil, workspace)
ErrEquals(t, fmt.Sprintf(`running "/bin/sh -c echo dying && exit 1" in %q: exit status 1`, path), err)
Expand Down
6 changes: 0 additions & 6 deletions server/core/terraform/terraform_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import (
"path/filepath"
"testing"

. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/cmd"
"github.com/runatlantis/atlantis/server/core/terraform"
"github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
jobmocks "github.com/runatlantis/atlantis/server/jobs/mocks"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/lyft/feature"
fmocks "github.com/runatlantis/atlantis/server/lyft/feature/mocks"
. "github.com/runatlantis/atlantis/testing"
)
Expand All @@ -44,8 +42,6 @@ func TestNewClient_NoTF(t *testing.T) {
defer tempSetEnv(t, "PATH", tmp)()

allocator := fmocks.NewMockAllocator()
When(allocator.ShouldAllocate(feature.LogStreaming, "owner/repo")).ThenReturn(false, nil)

_, err := terraform.NewClient(logger, binDir, cacheDir, "", "", "", cmd.DefaultTFVersionFlag, cmd.DefaultTFDownloadURL, nil, true, projectCmdOutputHandler, allocator)
ErrEquals(t, "getting default version: terraform not found in $PATH. Set --default-tf-version or download terraform from https://www.terraform.io/downloads.html", err)
}
Expand All @@ -72,7 +68,6 @@ func TestNewClient_DefaultTFFlagInPath(t *testing.T) {
defer tempSetEnv(t, "PATH", fmt.Sprintf("%s:%s", tmp, os.Getenv("PATH")))()

allocator := fmocks.NewMockAllocator()
When(allocator.ShouldAllocate(feature.LogStreaming, "owner/repo")).ThenReturn(false, nil)

c, err := terraform.NewClient(logger, binDir, cacheDir, "", "", "0.11.10", cmd.DefaultTFVersionFlag, cmd.DefaultTFDownloadURL, nil, true, projectCmdOutputHandler, allocator)
Ok(t, err)
Expand Down Expand Up @@ -105,7 +100,6 @@ func TestNewClient_DefaultTFFlagInBinDir(t *testing.T) {
defer tempSetEnv(t, "PATH", fmt.Sprintf("%s:%s", tmp, os.Getenv("PATH")))()

allocator := fmocks.NewMockAllocator()
When(allocator.ShouldAllocate(feature.LogStreaming, "owner/repo")).ThenReturn(false, nil)

c, err := terraform.NewClient(logging.NewNoopLogger(t), binDir, cacheDir, "", "", "0.11.10", cmd.DefaultTFVersionFlag, cmd.DefaultTFDownloadURL, nil, true, projectCmdOutputHandler, allocator)
Ok(t, err)
Expand Down
4 changes: 1 addition & 3 deletions server/lyft/feature/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ package feature
type Name string

// list of feature names used in the code base. These must be kept in sync with any external config.
const LogStreaming Name = "log-streaming"
const ForceApply Name = "force-apply"
const LogPersistence Name = "log-persistence"
const LogPersistence Name = "log-persistence"

0 comments on commit 8ff637a

Please sign in to comment.