centralize harded-code message

Signed-off-by: Fahed Dorgaa <fahed.dorgaa@gmail.com>
This commit is contained in:
Fahed Dorgaa
2019-07-13 15:07:23 +02:00
parent f2b6c31d0f
commit db95af43f3
6 changed files with 37 additions and 24 deletions

View File

@@ -27,6 +27,7 @@ import (
"runtime"
"time"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/services/server"
@@ -152,7 +153,7 @@ func App() *cli.App {
ttrpcAddress = fmt.Sprintf("%s.ttrpc", config.GRPC.Address)
)
if address == "" {
return errors.New("grpc address cannot be empty")
return errdefs.ErrEmptyGRCPAddress
}
log.G(ctx).WithFields(logrus.Fields{
"version": version.Version,

View File

@@ -51,7 +51,7 @@ var publishCommand = cli.Command{
ctx := namespaces.WithNamespace(gocontext.Background(), context.String("namespace"))
topic := context.String("topic")
if topic == "" {
return errors.New("topic required to publish event")
return errdefs.ErrEmptyTopic
}
payload, err := getEventPayload(os.Stdin)
if err != nil {

View File

@@ -18,7 +18,6 @@ package command
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"log"
@@ -28,6 +27,7 @@ import (
"time"
"unsafe"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/services/server"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
@@ -162,7 +162,7 @@ func (h *etwHook) Fire(e *logrus.Entry) error {
etype = windows.EVENTLOG_INFORMATION_TYPE
eid = eventDebug
default:
return errors.New("unknown level")
return errdefs.ErrUnknownLevel
}
// If there is additional data, include it as a second string.
@@ -311,7 +311,7 @@ func registerUnregisterService(root string) (bool, error) {
if unregisterServiceFlag {
if registerServiceFlag {
return true, errors.New("--register-service and --unregister-service cannot be used together")
return true, errdefs.ErrRegisterAndUnregisterService
}
return true, unregisterService()
}