Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: drift in variable_sets of environment resource in every plan #921

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading