From 6e16207221657ae6eca6fba2a8eb440d15aaaae2 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Thu, 22 Apr 2021 09:43:45 -0700 Subject: [PATCH 1/2] pipeline: better error handling on WriteFile Signed-off-by: Sam Alba --- dagger/pipeline.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dagger/pipeline.go b/dagger/pipeline.go index c8f76b81..3f490a9e 100644 --- a/dagger/pipeline.go +++ b/dagger/pipeline.go @@ -831,8 +831,10 @@ func (p *Pipeline) WriteFile(ctx context.Context, op *compiler.Value, st llb.Sta if err == nil { content = []byte(str) } + case cue.BottomKind: + err = fmt.Errorf("%s: WriteFile content is not set", op.Path().String()) default: - err = fmt.Errorf("unhandled data type in WriteFile: %s", kind) + err = fmt.Errorf("%s: unhandled data type in WriteFile: %s", op.Path().String(), kind) } if err != nil { return st, err From 5be4ac1a1d744d515cbfd8e84d2aec77fdb7ef80 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Thu, 22 Apr 2021 09:44:18 -0700 Subject: [PATCH 2/2] stdlib/rds: fixed error management Signed-off-by: Sam Alba --- stdlib/aws/rds/rds.cue | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/stdlib/aws/rds/rds.cue b/stdlib/aws/rds/rds.cue index 3865006e..f62787f8 100644 --- a/stdlib/aws/rds/rds.cue +++ b/stdlib/aws/rds/rds.cue @@ -47,6 +47,8 @@ import ( sql="CREATE DATABASE \"$(cat /inputs/name)\"" fi + cp /inputs/name /db_created + aws rds-data execute-statement \ --resource-arn "$(cat /inputs/db_arn)" \ --secret-arn "$(cat /inputs/secret_arn)" \ @@ -56,11 +58,8 @@ import ( |& tee /tmp/out exit_code=${PIPESTATUS[0]} if [ $exit_code -ne 0 ]; then - cat /tmp/out - grep -q "database exists\|already exists" /tmp/out - [ $? -ne 0 ] && exit $exit_code + grep -q "database exists\|already exists" /tmp/out || exit $exit_code fi - cp /inputs/name /db_created """# } } @@ -113,6 +112,8 @@ import ( sql="CREATE USER \"$(cat /inputs/username)\" WITH PASSWORD '$(cat /inputs/password)'" fi + cp /inputs/username /username + aws rds-data execute-statement \ --resource-arn "$(cat /inputs/db_arn)" \ --secret-arn "$(cat /inputs/secret_arn)" \ @@ -122,11 +123,8 @@ import ( |& tee tmp/out exit_code=${PIPESTATUS[0]} if [ $exit_code -ne 0 ]; then - cat tmp/out - grep -q "Operation CREATE USER failed for\|ERROR" tmp/out - [ $? -ne 0 ] && exit $exit_code + grep -q "Operation CREATE USER failed for\|ERROR" tmp/out || exit $exit_code fi - cp /inputs/username /username sql="SET PASSWORD FOR '$(cat /inputs/username)'@'%' = PASSWORD('$(cat /inputs/password)')" if [ "$dbType" = postgres ]; then