Skip to content

Commit cc749d3

Browse files
committed
Fix removing project constraints
Fixes a bug when constraints are being removed from a project. Signed-off-by: Ferran Rodenas <[email protected]>
1 parent 2f6d4c5 commit cc749d3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

vra/resource_project.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,11 @@ func flattenZoneAssignment(list []*models.ZoneAssignment) []map[string]interface
321321
}
322322

323323
func expandProjectConstraints(configProjectConstraints []interface{}) map[string][]models.Constraint {
324-
projectConstraints := make(map[string][]models.Constraint)
324+
projectConstraints := map[string][]models.Constraint{
325+
"extensibility": {},
326+
"network": {},
327+
"storage": {},
328+
}
325329

326330
for _, configProjectConstraint := range configProjectConstraints {
327331
configConstraints := configProjectConstraint.(map[string]interface{})

vra/resource_project_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ func TestExpandProjectConstraints(t *testing.T) {
2424
projectConstraints := make([]interface{}, 0)
2525
expandedConstraints := expandProjectConstraints(projectConstraints)
2626

27-
if len(expandedConstraints) != 0 {
28-
t.Errorf("error while expanding when there are no project constraints")
27+
if len(expandedConstraints["extensibility"]) != 0 {
28+
t.Errorf("error while expanding when there are no project extensibility constraints")
29+
}
30+
if len(expandedConstraints["network"]) != 0 {
31+
t.Errorf("error while expanding when there are no project network constraints")
32+
}
33+
if len(expandedConstraints["storage"]) != 0 {
34+
t.Errorf("error while expanding when there are no project storage constraints")
2935
}
3036

3137
constraints := make([]interface{}, 0)

0 commit comments

Comments
 (0)