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

Check deploy message responses for string errors #190

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 21 additions & 4 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"fmt"
"strings"

"github.com/amazeeio/lagoon-cli/internal/lagoon"
"github.com/amazeeio/lagoon-cli/internal/lagoon/client"
Expand Down Expand Up @@ -53,7 +54,11 @@ use 'lagoon deploy latest' instead`,
if err != nil {
return err
}
fmt.Println(result.DeployEnvironmentBranch)
response := result.DeployEnvironmentBranch
if strings.HasPrefix(response, "Error: ") {
return fmt.Errorf(strings.Trim(response, "Error: "))
}
fmt.Println(response)
}
return nil
},
Expand Down Expand Up @@ -99,7 +104,11 @@ var deployPromoteCmd = &cobra.Command{
if err != nil {
return err
}
fmt.Println(result.DeployEnvironmentPromote)
response := result.DeployEnvironmentPromote
if strings.HasPrefix(response, "Error: ") {
return fmt.Errorf(strings.Trim(response, "Error: "))
}
fmt.Println(response)
}
return nil
},
Expand Down Expand Up @@ -142,7 +151,11 @@ This environment should already exist in lagoon. It is analogous with the 'Deplo
if err != nil {
return err
}
fmt.Println(result.DeployEnvironmentLatest)
response := result.DeployEnvironmentLatest
if strings.HasPrefix(response, "Error: ") {
return fmt.Errorf(strings.Trim(response, "Error: "))
}
fmt.Println(response)
}
return nil
},
Expand Down Expand Up @@ -214,7 +227,11 @@ This pullrequest may not already exist as an environment in lagoon.`,
if err != nil {
return err
}
fmt.Println(result.DeployEnvironmentPullrequest)
response := result.DeployEnvironmentPullrequest
if strings.HasPrefix(response, "Error: ") {
return fmt.Errorf(strings.Trim(response, "Error: "))
}
fmt.Println(response)
}
return nil
},
Expand Down