Skip to content

Commit

Permalink
Feat: drift in variable_sets of environment resource in every plan
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber committed Jul 31, 2024
1 parent 6155863 commit be4dd42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion env0/resource_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ func getEnvironmentVariableSetIdsFromApi(d *schema.ResourceData, apiClient clien

var environmentVariableSetIds []string
for _, variableSet := range environmentVariableSets {
if variableSet.AssignmentScope == "ENVIRONMENT" {
if variableSet.AssignmentScope == "environment" {
environmentVariableSetIds = append(environmentVariableSetIds, variableSet.Id)
}
}
Expand Down
12 changes: 6 additions & 6 deletions env0/resource_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,34 +362,34 @@ func TestUnitEnvironmentResource(t *testing.T) {
configurationSets := []client.ConfigurationSet{
{
Id: "id1",
AssignmentScope: "ENVIRONMENT",
AssignmentScope: "environment",
},
{
Id: "id2",
AssignmentScope: "ENVIRONMENT",
AssignmentScope: "environment",
},
}

updatedConfigurationSets := []client.ConfigurationSet{
{
Id: "id2",
AssignmentScope: "ENVIRONMENT",
AssignmentScope: "environment",
},
{
Id: "id3",
AssignmentScope: "ENVIRONMENT",
AssignmentScope: "environment",
},
}

// Same as updatedConfigurationSets, but in a different order.
updatedConfigurationSets2 := []client.ConfigurationSet{
{
Id: "id3",
AssignmentScope: "ENVIRONMENT",
AssignmentScope: "environment",
},
{
Id: "id2",
AssignmentScope: "ENVIRONMENT",
AssignmentScope: "environment",
},
}

Expand Down
5 changes: 3 additions & 2 deletions env0/resource_variable_set_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package env0

import (
"context"
"strings"

"github.com/env0/terraform-provider-env0/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -89,7 +90,7 @@ func resourceVariableSetAssignmentUpdate(ctx context.Context, d *schema.Resource

// In API but not in Schema - delete.
for _, apiConfigurationSet := range apiConfigurationSets {
if apiConfigurationSet.AssignmentScope != assignmentSchema.Scope {
if !strings.EqualFold(apiConfigurationSet.AssignmentScope, assignmentSchema.Scope) {
continue
}

Expand Down Expand Up @@ -187,7 +188,7 @@ func resourceVariableSetAssignmentRead(ctx context.Context, d *schema.ResourceDa
}

for _, apiConfigurationSet := range apiConfigurationSets {
if apiConfigurationSet.AssignmentScope != assignmentSchema.Scope {
if !strings.EqualFold(apiConfigurationSet.AssignmentScope, assignmentSchema.Scope) {
continue
}

Expand Down

0 comments on commit be4dd42

Please sign in to comment.