Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print errors to stdout #920

Merged
merged 8 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions cmd/engine/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"

engine "github.com/klothoplatform/klotho/pkg/engine2"
Expand All @@ -11,16 +10,11 @@ import (
func main() {
root := newRootCmd()
err := root.Execute()
if err != nil {
switch err.(type) {
case engine.ConfigValidationError:
fmt.Printf("Error: %v\n", err)
os.Exit(2)
default:
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
if err == nil {
return
}
// Shouldn't happen, the engine CLI should handle errors
os.Exit(1)
}

func newRootCmd() *cobra.Command {
Expand Down
14 changes: 9 additions & 5 deletions create_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,25 @@ echo "Running $name"

# Run the engine
echo "Using $out_dir as output directory"
set +e
go run ./cmd/engine Run \
-i "$1" \
-c "$1" \
-o "$out_dir" > $out_dir/out.log 2> $out_dir/err.log
-o "$out_dir" > $out_dir/error_details.json 2> $out_dir/err.log

echo "Successfully ran $name, copying results to testdata"
code=$?
echo "Ran $name return code $code, copying results to testdata"
set -e

test_dir="pkg/engine2/testdata"

if [ ! "$test_dir/$name.input.yaml" -ef "$1" ]; then
cp $1 "$test_dir/$name.input.yaml"
fi

cp "$out_dir/resources.yaml" "$test_dir/$name.expect.yaml"
cp "$out_dir/dataflow-topology.yaml" "$test_dir/$name.dataflow-viz.yaml"
cp "$out_dir/iac-topology.yaml" "$test_dir/$name.iac-viz.yaml"
[ -e "$out_dir/resources.yaml" ] && cp "$out_dir/resources.yaml" "$test_dir/$name.expect.yaml"
[ -e "$out_dir/dataflow-topology.yaml" ] && cp "$out_dir/dataflow-topology.yaml" "$test_dir/$name.dataflow-viz.yaml"
[ -e "$out_dir/iac-topology.yaml" ] && cp "$out_dir/iac-topology.yaml" "$test_dir/$name.iac-viz.yaml"
[ -e "$out_dir/error_details.json" ] && cp "$out_dir/error_details.json" "$test_dir/$name.err.json"

rm -rf $out_dir
Loading
Loading