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