-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
689440f
commit 0f4c5cd
Showing
3 changed files
with
54 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package pulumitest | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
// YAML does not allow tabs, so this function will error if the program contains tabs. | ||
func (a *PulumiTest) WritePulumiYaml(t PT, program string) { | ||
t.Helper() | ||
|
||
// find the line of the program that contains tabs | ||
lines := strings.Split(program, "\n") | ||
for i, line := range lines { | ||
if strings.Contains(line, "\t") { | ||
ptFatalF(t, "program contains tabs on line %d: %s\nTry replacing it with:\n%s", i+1, line, strings.ReplaceAll(program, "\t", " ")) | ||
} | ||
} | ||
|
||
pulumiYamlPath := filepath.Join(a.CurrentStack().Workspace().WorkDir(), "Pulumi.yaml") | ||
err := os.WriteFile(pulumiYamlPath, []byte(program), 0o600) | ||
if err != nil { | ||
ptFatalF(t, "failed to replace program %s", err) | ||
} | ||
} | ||
|
||
func (a *PulumiTest) ReadPulumiYaml(t PT) string { | ||
t.Helper() | ||
|
||
pulumiYamlPath := filepath.Join(a.CurrentStack().Workspace().WorkDir(), "Pulumi.yaml") | ||
program, err := os.ReadFile(pulumiYamlPath) | ||
if err != nil { | ||
ptFatalF(t, "failed to read program %s", err) | ||
} | ||
return string(program) | ||
} |
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 was deleted.
Oops, something went wrong.