Skip to content

Commit

Permalink
use AssignmentScopeId instead
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber committed Oct 7, 2024
1 parent 7495287 commit 7afa8ea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
12 changes: 7 additions & 5 deletions client/configuration_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ type UpdateConfigurationSetPayload struct {
}

type ConfigurationSet struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AssignmentScope string `json:"assignmentScope"`
CreationScopeId string `json:"creationScopeId"`
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AssignmentScope string `json:"assignmentScope"`
CreationScopeId string `json:"creationScopeId"`
AssignmentScopeId string `json:"assignmentScopeId"`
}

func (client *ApiClient) ConfigurationSetCreate(payload *CreateConfigurationSetPayload) (*ConfigurationSet, error) {
var result ConfigurationSet

var err error

if payload.Scope == "organization" && payload.ScopeId == "" {
Expand Down
2 changes: 1 addition & 1 deletion env0/resource_variable_set_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func resourceVariableSetAssignmentRead(ctx context.Context, d *schema.ResourceDa
}

// Filter out inherited assignments (e.g parent project).
if apiConfigurationSet.CreationScopeId != assignmentSchema.ScopeId {
if apiConfigurationSet.AssignmentScopeId != assignmentSchema.ScopeId {
continue
}

Expand Down
54 changes: 27 additions & 27 deletions env0/resource_variable_set_assignment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,46 @@ func TestUnitVariableSetAssignmentResource(t *testing.T) {
setIds := []string{"a1", "a2"}
configurationSetIds := []client.ConfigurationSet{
{
Id: "a1",
AssignmentScope: scope,
CreationScopeId: scopeId,
Id: "a1",
AssignmentScope: scope,
AssignmentScopeId: scopeId,
},
{
Id: "a2",
AssignmentScope: scope,
CreationScopeId: scopeId,
Id: "a2",
AssignmentScope: scope,
AssignmentScopeId: scopeId,
},
{
Id: "filtered_out",
AssignmentScope: scope,
CreationScopeId: "otherCreationScopeId",
Id: "filtered_out",
AssignmentScope: scope,
AssignmentScopeId: "otherAssignmentScopeId",
},
}
// Validates that drifts do not occur due to ordering.
flippedConfigurationSetIds := []client.ConfigurationSet{
{
Id: "a2",
AssignmentScope: scope,
CreationScopeId: scopeId,
Id: "a2",
AssignmentScope: scope,
AssignmentScopeId: scopeId,
},
{
Id: "a1",
AssignmentScope: scope,
CreationScopeId: scopeId,
Id: "a1",
AssignmentScope: scope,
AssignmentScopeId: scopeId,
},
}

updatedSetIds := []string{"a1", "a3"}
updatedConfigurationSetIds := []client.ConfigurationSet{
{
Id: "a3",
AssignmentScope: scope,
CreationScopeId: scopeId,
Id: "a3",
AssignmentScope: scope,
AssignmentScopeId: scopeId,
},
{
Id: "a1",
AssignmentScope: scope,
CreationScopeId: scopeId,
Id: "a1",
AssignmentScope: scope,
AssignmentScopeId: scopeId,
},
}

Expand Down Expand Up @@ -114,14 +114,14 @@ func TestUnitVariableSetAssignmentResource(t *testing.T) {
setIds := []string{"a1"}
configurationSetIds := []client.ConfigurationSet{
{
Id: "a1",
AssignmentScope: scope,
CreationScopeId: scopeId,
Id: "a1",
AssignmentScope: scope,
AssignmentScopeId: scopeId,
},
{
Id: "a2",
AssignmentScope: scope,
CreationScopeId: scopeId,
Id: "a2",
AssignmentScope: scope,
AssignmentScopeId: scopeId,
},
}

Expand Down

0 comments on commit 7afa8ea

Please sign in to comment.