Skip to content

Commit

Permalink
Fix: tf apply fails when switching from v1.2.4 to v1.2.5 (#509)
Browse files Browse the repository at this point in the history
* extracting bluprintId from lastDeployment

* fix tests

* formatting

* checking for environment.BlueprintId also
  • Loading branch information
eladmosh authored Sep 29, 2022
1 parent b08125a commit 3c3799e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions env0/resource_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,16 @@ func setEnvironmentSchema(d *schema.ResourceData, environment client.Environment
d.Set("template_id", environment.LatestDeploymentLog.BlueprintId)
d.Set("revision", environment.LatestDeploymentLog.BlueprintRevision)
}
} else if environment.BlueprintId != "" {
} else if environment.BlueprintId != "" || environment.LatestDeploymentLog.BlueprintId != "" {
settings := d.Get("without_template_settings").([]interface{})
elem := settings[0].(map[string]interface{})
elem["id"] = environment.BlueprintId

if environment.BlueprintId != "" {
elem["id"] = environment.BlueprintId
} else {
elem["id"] = environment.LatestDeploymentLog.BlueprintId
}

d.Set("without_template_settings", settings)
}

Expand Down
3 changes: 3 additions & 0 deletions env0/resource_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,9 @@ func TestUnitEnvironmentWithoutTemplateResource(t *testing.T) {
WorkspaceName: "workspace-name",
TerragruntWorkingDirectory: "/terragrunt/directory/",
VcsCommandsAlias: "alias",
LatestDeploymentLog: client.DeploymentLog{
BlueprintId: "id-template-0",
},
}

environmentWithBluePrint := environment
Expand Down

0 comments on commit 3c3799e

Please sign in to comment.