mirror of https://github.com/docker/cli.git
Remove use of deprecated IsErr...NotFound checks
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
448d56a491
commit
532a3942d6
|
@ -54,7 +54,7 @@ func runInspect(dockerCli command.Cli, opts inspectOptions) error {
|
||||||
getRef := func(ref string) (interface{}, []byte, error) {
|
getRef := func(ref string) (interface{}, []byte, error) {
|
||||||
// Service inspect shows defaults values in empty fields.
|
// Service inspect shows defaults values in empty fields.
|
||||||
service, _, err := client.ServiceInspectWithRaw(ctx, ref, types.ServiceInspectOptions{InsertDefaults: true})
|
service, _, err := client.ServiceInspectWithRaw(ctx, ref, types.ServiceInspectOptions{InsertDefaults: true})
|
||||||
if err == nil || !apiclient.IsErrServiceNotFound(err) {
|
if err == nil || !apiclient.IsErrNotFound(err) {
|
||||||
return service, nil, err
|
return service, nil, err
|
||||||
}
|
}
|
||||||
return nil, nil, errors.Errorf("Error: no such service: %s", ref)
|
return nil, nil, errors.Errorf("Error: no such service: %s", ref)
|
||||||
|
@ -62,7 +62,7 @@ func runInspect(dockerCli command.Cli, opts inspectOptions) error {
|
||||||
|
|
||||||
getNetwork := func(ref string) (interface{}, []byte, error) {
|
getNetwork := func(ref string) (interface{}, []byte, error) {
|
||||||
network, _, err := client.NetworkInspectWithRaw(ctx, ref, types.NetworkInspectOptions{Scope: "swarm"})
|
network, _, err := client.NetworkInspectWithRaw(ctx, ref, types.NetworkInspectOptions{Scope: "swarm"})
|
||||||
if err == nil || !apiclient.IsErrNetworkNotFound(err) {
|
if err == nil || !apiclient.IsErrNotFound(err) {
|
||||||
return network, nil, err
|
return network, nil, err
|
||||||
}
|
}
|
||||||
return nil, nil, errors.Errorf("Error: no such network: %s", ref)
|
return nil, nil, errors.Errorf("Error: no such network: %s", ref)
|
||||||
|
|
|
@ -102,7 +102,7 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error {
|
||||||
}
|
}
|
||||||
task, _, err := cli.TaskInspectWithRaw(ctx, opts.target)
|
task, _, err := cli.TaskInspectWithRaw(ctx, opts.target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if client.IsErrTaskNotFound(err) {
|
if client.IsErrNotFound(err) {
|
||||||
// if the task isn't found, rewrite the error to be clear
|
// if the task isn't found, rewrite the error to be clear
|
||||||
// that we looked for services AND tasks and found none
|
// that we looked for services AND tasks and found none
|
||||||
err = fmt.Errorf("no such task or service: %v", opts.target)
|
err = fmt.Errorf("no such task or service: %v", opts.target)
|
||||||
|
|
|
@ -222,7 +222,7 @@ func createSecrets(
|
||||||
if err := client.SecretUpdate(ctx, secret.ID, secret.Meta.Version, secretSpec); err != nil {
|
if err := client.SecretUpdate(ctx, secret.ID, secret.Meta.Version, secretSpec); err != nil {
|
||||||
return errors.Wrapf(err, "failed to update secret %s", secretSpec.Name)
|
return errors.Wrapf(err, "failed to update secret %s", secretSpec.Name)
|
||||||
}
|
}
|
||||||
case apiclient.IsErrSecretNotFound(err):
|
case apiclient.IsErrNotFound(err):
|
||||||
// secret does not exist, then we create a new one.
|
// secret does not exist, then we create a new one.
|
||||||
if _, err := client.SecretCreate(ctx, secretSpec); err != nil {
|
if _, err := client.SecretCreate(ctx, secretSpec); err != nil {
|
||||||
return errors.Wrapf(err, "failed to create secret %s", secretSpec.Name)
|
return errors.Wrapf(err, "failed to create secret %s", secretSpec.Name)
|
||||||
|
@ -249,7 +249,7 @@ func createConfigs(
|
||||||
if err := client.ConfigUpdate(ctx, config.ID, config.Meta.Version, configSpec); err != nil {
|
if err := client.ConfigUpdate(ctx, config.ID, config.Meta.Version, configSpec); err != nil {
|
||||||
errors.Wrapf(err, "failed to update config %s", configSpec.Name)
|
errors.Wrapf(err, "failed to update config %s", configSpec.Name)
|
||||||
}
|
}
|
||||||
case apiclient.IsErrConfigNotFound(err):
|
case apiclient.IsErrNotFound(err):
|
||||||
// config does not exist, then we create a new one.
|
// config does not exist, then we create a new one.
|
||||||
if _, err := client.ConfigCreate(ctx, configSpec); err != nil {
|
if _, err := client.ConfigCreate(ctx, configSpec); err != nil {
|
||||||
errors.Wrapf(err, "failed to create config %s", configSpec.Name)
|
errors.Wrapf(err, "failed to create config %s", configSpec.Name)
|
||||||
|
|
Loading…
Reference in New Issue