-
-
Notifications
You must be signed in to change notification settings - Fork 999
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing modules output corruption (#3459)
* fix: modules output corruption * chore: fix strict lint * chore: fix fmt * chore: fix tests * chore: fix tests * chore: fix tests * chore: fix tests * chore: fix tests * chore: fix tests * chore: update testdata * fix: Removing non non-interactive logic in err stream redirect (#3464) * chore: revert code * Redirect engine messages to stderr (#3468) * Add option to redirect stdout to stderr * Engine tests update * Tests update * Lint issues update * chore: log message * chore: revert testdatda --------- Co-authored-by: Yousif Akbar <[email protected]> Co-authored-by: Denis O <[email protected]>
- Loading branch information
1 parent
af89a98
commit a36f34b
Showing
15 changed files
with
343 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package configstack | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/gruntwork-io/terragrunt/internal/errors" | ||
) | ||
|
||
// ModuleWriter represents a Writer with data buffering. | ||
// We should avoid outputting data directly to the output out, | ||
// since when modules run in parallel, the output data may be mixed with each other, thereby spoiling each other's results. | ||
type ModuleWriter struct { | ||
buffer *bytes.Buffer | ||
out io.Writer | ||
} | ||
|
||
// NewModuleWriter returns a new ModuleWriter instance. | ||
func NewModuleWriter(out io.Writer) *ModuleWriter { | ||
return &ModuleWriter{ | ||
buffer: &bytes.Buffer{}, | ||
out: out, | ||
} | ||
} | ||
|
||
// Write appends the contents of p to the buffer. | ||
func (writer *ModuleWriter) Write(p []byte) (int, error) { | ||
n, err := writer.buffer.Write(p) | ||
if err != nil { | ||
return n, errors.New(err) | ||
} | ||
|
||
return n, nil | ||
} | ||
|
||
// Flush flushes buffer data to the `out` writer. | ||
func (writer *ModuleWriter) Flush() error { | ||
if _, err := fmt.Fprint(writer.out, writer.buffer); err != nil { | ||
return errors.New(err) | ||
} | ||
|
||
writer.buffer.Reset() | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
terraform { | ||
required_providers { | ||
null = { | ||
source = "registry.terraform.io/hashicorp/null" | ||
version = "2.1.2" | ||
} | ||
} | ||
} | ||
|
||
provider "null" {} | ||
|
||
# Create a large string by repeating a smaller string multiple times | ||
resource "null_resource" "large_json" { | ||
count = 1 | ||
|
||
triggers = { | ||
large_data = join("", [ | ||
for i in range(0, 1024) : "ThisIsAVeryLongStringRepeatedManyTimesToCreateLargeDataBlock_" | ||
]) | ||
} | ||
} | ||
|
||
resource "null_resource" "large_json_2" { | ||
count = 1 | ||
|
||
triggers = { | ||
large_data = join("", [ | ||
for i in range(0, 1024) : "ThisIsAVeryLongStringRepeatedManyTimesToCreateLargeDataBlock_1024" | ||
]) | ||
} | ||
} | ||
|
||
|
||
output "large_json_output" { | ||
value = null_resource.large_json[0].triggers.large_data | ||
} | ||
|
||
|
||
output "large_json_output_2" { | ||
value = null_resource.large_json_2[0].triggers.large_data | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
provider "null" {} | ||
|
||
terraform { | ||
required_providers { | ||
null = { | ||
source = "registry.terraform.io/hashicorp/null" | ||
version = "2.1.2" | ||
} | ||
} | ||
} | ||
|
||
|
||
# Create a large string by repeating a smaller string multiple times | ||
resource "null_resource" "large_json" { | ||
count = 1 | ||
|
||
triggers = { | ||
large_data = join("", [ | ||
for i in range(0, 1024) : "ThisIsAVeryLongStringRepeatedManyTimesToCreateLargeDataBlock_" | ||
]) | ||
} | ||
} | ||
|
||
resource "null_resource" "large_json_2" { | ||
count = 1 | ||
|
||
triggers = { | ||
large_data = join("", [ | ||
for i in range(0, 1024) : "ThisIsAVeryLongStringRepeatedManyTimesToCreateLargeDataBlock_1024" | ||
]) | ||
} | ||
} | ||
|
||
|
||
output "large_json_output" { | ||
value = null_resource.large_json[0].triggers.large_data | ||
} | ||
|
||
|
||
output "large_json_output_2" { | ||
value = null_resource.large_json_2[0].triggers.large_data | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
terraform { | ||
required_providers { | ||
null = { | ||
source = "registry.terraform.io/hashicorp/null" | ||
version = "2.1.2" | ||
} | ||
} | ||
} | ||
|
||
provider "null" {} | ||
|
||
# Create a large string by repeating a smaller string multiple times | ||
resource "null_resource" "large_json" { | ||
count = 1 | ||
|
||
triggers = { | ||
large_data = join("", [ | ||
for i in range(0, 1024) : "ThisIsAVeryLongStringRepeatedManyTimesToCreateLargeDataBlock_" | ||
]) | ||
} | ||
} | ||
|
||
resource "null_resource" "large_json_2" { | ||
count = 1 | ||
|
||
triggers = { | ||
large_data = join("", [ | ||
for i in range(0, 1024) : "ThisIsAVeryLongStringRepeatedManyTimesToCreateLargeDataBlock_1024" | ||
]) | ||
} | ||
} | ||
|
||
|
||
output "large_json_output" { | ||
value = null_resource.large_json[0].triggers.large_data | ||
} | ||
|
||
|
||
output "large_json_output_2" { | ||
value = null_resource.large_json_2[0].triggers.large_data | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters