refactor: moved all fatal errors to logrus
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This will allow us to test commands that would normally exit
This commit is contained in:
parent
2158dc851c
commit
29971c36a0
|
@ -101,7 +101,7 @@ var appPsCommand = &cli.Command{
|
|||
cl := client.NewClientWithContext(Context)
|
||||
tasks, err := cl.TaskList(ctx, types.TaskListOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
for _, task := range tasks {
|
||||
resolver := idresolver.New(cl, false)
|
||||
|
@ -113,7 +113,7 @@ var appPsCommand = &cli.Command{
|
|||
}
|
||||
containers, err := cl.ContainerList(ctx, types.ContainerListOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
table := createTable([]string{"ID", "Image", "Command", "Created", "Status", "Ports", "Names"})
|
||||
var conTable [][]string
|
||||
|
@ -166,7 +166,7 @@ var appSecretCommand = &cli.Command{
|
|||
passgen.WordListDefault,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
for _, password := range passwords {
|
||||
|
|
|
@ -2,9 +2,9 @@ package cli
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
@ -46,6 +46,6 @@ func RunApp(version string, commit string) {
|
|||
|
||||
err := app.Run(os.Args)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package client
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
|
@ -12,6 +11,7 @@ import (
|
|||
dCliContextStore "github.com/docker/cli/cli/context/store"
|
||||
dClient "github.com/docker/docker/client"
|
||||
"github.com/moby/term"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func NewClientWithContext(contextURL string) *dClient.Client {
|
||||
|
@ -44,8 +44,7 @@ func NewClientWithContext(contextURL string) *dClient.Client {
|
|||
cl, err := dClient.NewClientWithOpts(clientOpts...)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Unable to create docker client")
|
||||
panic(err)
|
||||
logrus.Fatalf("unable to create Docker client: %s", err)
|
||||
}
|
||||
return cl
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package client
|
||||
|
||||
import "github.com/docker/cli/cli/connhelper"
|
||||
import (
|
||||
"github.com/docker/cli/cli/connhelper"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func newConnectionHelper(daemonURL string) *connhelper.ConnectionHelper {
|
||||
helper, err := connhelper.GetConnectionHelper(daemonURL)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
return helper
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue