Skip to content
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
21 changes: 18 additions & 3 deletions cli/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,22 @@ var _deployCmd = &cobra.Command{
exit.Error(err)
}
fmt.Println(string(bytes))
return
case flags.MixedOutputType:
err := mixedPrint(deployResults)
if err != nil {
exit.Error(err)
}
return
case flags.PrettyOutputType:
message := deployMessage(deployResults, env.Name)
print.BoldFirstBlock(message)
if didAnyResultsError(deployResults) {
print.StderrBoldFirstBlock(message)
} else {
print.BoldFirstBlock(message)
}
}

if didAnyResultsError(deployResults) {
exit.Error(nil)
}
},
}
Expand Down Expand Up @@ -297,6 +303,15 @@ func didAllResultsError(results []schema.DeployResult) bool {
return true
}

func didAnyResultsError(results []schema.DeployResult) bool {
for _, result := range results {
if result.Error != "" {
return true
}
}
return false
}

func getAPICommandsMessage(results []schema.DeployResult, envName string) string {
apiName := "<api_name>"
if len(results) == 1 {
Expand Down
3 changes: 1 addition & 2 deletions pkg/lib/errors/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ limitations under the License.
package errors

import (
"os"
"strings"

"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/cortexlabs/cortex/pkg/lib/print"
)

func PrintError(err error, strs ...string) {
os.Stderr.WriteString(ErrorStr(err, strs...) + "\n")
print.StderrPrintln(ErrorStr(err, strs...))
// PrintStacktrace(err)
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/lib/exit/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func Error(err error, wrapStrs ...string) {
err = errors.Wrap(err, str)
}

if !errors.IsNoTelemetry(err) {
if err != nil && !errors.IsNoTelemetry(err) {
telemetry.Error(err)
}

if !errors.IsNoPrint(err) {
if err != nil && !errors.IsNoPrint(err) {
errors.PrintErrorForUser(err)
}

Expand All @@ -51,7 +51,7 @@ func Panic(err error, wrapStrs ...string) {
err = errors.Wrap(err, str)
}

if !errors.IsNoTelemetry(err) {
if err != nil && !errors.IsNoTelemetry(err) {
telemetry.Error(err)
}

Expand Down
25 changes: 22 additions & 3 deletions pkg/lib/print/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ func StderrBoldFirstLine(msg string) {
msgParts := strings.Split(msg, "\n")

if len(msgParts[0]) > _maxBoldLength {
os.Stderr.WriteString(msg + "\n")
StderrPrintln(msg)
return
}

os.Stderr.WriteString(console.Bold(msgParts[0]) + "\n")
StderrPrintln(console.Bold(msgParts[0]))

if len(msgParts) > 1 {
os.Stderr.WriteString(strings.Join(msgParts[1:], "\n") + "\n")
StderrPrintln(strings.Join(msgParts[1:], "\n"))
}
}

Expand All @@ -71,7 +71,26 @@ func BoldFirstBlock(msg string) {
}
}

func StderrBoldFirstBlock(msg string) {
msgParts := strings.Split(msg, "\n\n")

if len(msgParts[0]) > _maxBoldLength {
StderrPrintln(msg)
return
}

StderrPrintln(console.Bold(msgParts[0]))

if len(msgParts) > 1 {
StderrPrintln("\n" + strings.Join(msgParts[1:], "\n\n"))
}
}

func Dot() error {
fmt.Print(".")
return nil
}

func StderrPrintln(str string) {
os.Stderr.WriteString(str + "\n")
}
4 changes: 4 additions & 0 deletions pkg/workloads/cortex/client/cortex/binary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def run_cli(
result = "~"
output = output[:-1]
if result_found:
output = output[:-1]
if c == "\n":
result_found = False
result = result[len(MIXED_CORTEX_MARKER) : -len(MIXED_CORTEX_MARKER)]
Expand All @@ -96,6 +97,9 @@ def run_cli(
return result
return output

if result != "":
raise CortexBinaryException(result + "\n" + process.stderr.read())

raise CortexBinaryException(process.stderr.read())


Expand Down