Skip to content

Commit 1620d64

Browse files
committed
fix: fixed wrong file read
1 parent 63300d5 commit 1620d64

File tree

4 files changed

+48
-32
lines changed

4 files changed

+48
-32
lines changed

docs/resources/is_fully_known.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ description: |-
88
Each module can use providermeta. Please keep in mind that these settings only count for resources of this module! (see https://www.terraform.io/internals/provider-meta https://www.terraform.io/internals/provider-meta):
99
```terraform
1010
// Terraform providermeta example
11-
terraform {
12-
// "value" is the provider name
13-
providermeta "value" {
14-
// {workdir} -> The only available placeholder currently (see below for more information)
15-
guidseed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
16-
}
11+
terraform {
12+
// "value" is the provider name
13+
providermeta "value" {
14+
// {workdir} -> The only available placeholder currently (see below for more information)
15+
guidseed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
1716
}
17+
}
1818
```
1919
Optional
2020
guid_seed_addition (String) It serves as addition to each seed of any value_is_fully_known (resource) or value_is_known (resource) within the project if specified in provider, or within the same module if specified in provider-meta.
@@ -32,13 +32,13 @@ Allows you to have a access to `result` during plan phase that states whether `v
3232
Each module can use provider_meta. Please keep in mind that these settings only count for resources of this module! (see [https://www.terraform.io/internals/provider-meta](https://www.terraform.io/internals/provider-meta)):
3333
```terraform
3434
// Terraform provider_meta example
35-
terraform {
36-
// "value" is the provider name
37-
provider_meta "value" {
38-
// {workdir} -> The only available placeholder currently (see below for more information)
39-
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
40-
}
35+
terraform {
36+
// "value" is the provider name
37+
provider_meta "value" {
38+
// {workdir} -> The only available placeholder currently (see below for more information)
39+
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
4140
}
41+
}
4242
```
4343
### Optional
4444
- `guid_seed_addition` (String) It serves as addition to each seed of any `value_is_fully_known` (resource) or `value_is_known` (resource) within the project if specified in provider, or within the same module if specified in provider-meta.

docs/resources/is_known.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ description: |-
88
Each module can use providermeta. Please keep in mind that these settings only count for resources of this module! (see https://www.terraform.io/internals/provider-meta https://www.terraform.io/internals/provider-meta):
99
```terraform
1010
// Terraform providermeta example
11-
terraform {
12-
// "value" is the provider name
13-
providermeta "value" {
14-
// {workdir} -> The only available placeholder currently (see below for more information)
15-
guidseed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
16-
}
11+
terraform {
12+
// "value" is the provider name
13+
providermeta "value" {
14+
// {workdir} -> The only available placeholder currently (see below for more information)
15+
guidseed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
1716
}
17+
}
1818
```
1919
Optional
2020
guid_seed_addition (String) It serves as addition to each seed of any value_is_fully_known (resource) or value_is_known (resource) within the project if specified in provider, or within the same module if specified in provider-meta.
@@ -32,13 +32,13 @@ Allows you to have a access to `result` during plan phase that states whether `v
3232
Each module can use provider_meta. Please keep in mind that these settings only count for resources of this module! (see [https://www.terraform.io/internals/provider-meta](https://www.terraform.io/internals/provider-meta)):
3333
```terraform
3434
// Terraform provider_meta example
35-
terraform {
36-
// "value" is the provider name
37-
provider_meta "value" {
38-
// {workdir} -> The only available placeholder currently (see below for more information)
39-
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
40-
}
35+
terraform {
36+
// "value" is the provider name
37+
provider_meta "value" {
38+
// {workdir} -> The only available placeholder currently (see below for more information)
39+
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
4140
}
41+
}
4242
```
4343
### Optional
4444
- `guid_seed_addition` (String) It serves as addition to each seed of any `value_is_fully_known` (resource) or `value_is_known` (resource) within the project if specified in provider, or within the same module if specified in provider-meta.

isknown/common/provider_meta_schema.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ func getProviderMetaGuidSeedAdditionAttributeDescription() string {
3030
"Each module can use provider_meta. Please keep in mind that these settings only count " +
3131
"for resources of this module! (see [https://www.terraform.io/internals/provider-meta](https://www.terraform.io/internals/provider-meta)):\n" +
3232
"```terraform\n" + `// Terraform provider_meta example
33-
terraform {
34-
// "value" is the provider name
35-
provider_meta "value" {
36-
// {workdir} -> The only available placeholder currently (see below for more information)
37-
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
38-
}
39-
}` + "\n```\n" +
33+
terraform {
34+
// "value" is the provider name
35+
provider_meta "value" {
36+
// {workdir} -> The only available placeholder currently (see below for more information)
37+
guid_seed_addition = "{workdir}#for-example" // Results into "/path/to/workdir#for-example"
38+
}
39+
}` + "\n```\n" +
4040
"### Optional\n" +
4141
"- `guid_seed_addition` (String) " + goproviderconfig.GetGuidSeedAdditionAttributeDescription()
4242
}

isknown/provider/resource_plan.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package provider
22

33
import (
44
"context"
5+
"errors"
56
"os"
67
"path/filepath"
78

@@ -118,7 +119,22 @@ func (s *UserProviderServer) PlanResourceChange(ctx context.Context, req *tfprot
118119
return resp, nil
119120
}
120121
} else {
121-
readBytes, err := os.ReadFile(deterministicTempFilePath)
122+
deterministicFile, err := os.Open(deterministicTempFilePath)
123+
var readBytes []byte
124+
125+
if errors.Is(err, os.ErrNotExist) {
126+
resp.Diagnostics = append(resp.Diagnostics, &tfprotov6.Diagnostic{
127+
Severity: tfprotov6.DiagnosticSeverityError,
128+
Summary: "File does not exist",
129+
Detail: `The file does not exist. This can mean
130+
1. the file got deleted before apply-phase or
131+
2. this plan method got called the third time`,
132+
})
133+
} else if err == nil {
134+
defer deterministicFile.Close() // ignore error intentionally
135+
readBytes = make([]byte, 1)
136+
deterministicFile.Read(readBytes)
137+
}
122138

123139
if err != nil {
124140
resp.Diagnostics = append(resp.Diagnostics, &tfprotov6.Diagnostic{

0 commit comments

Comments
 (0)