mirror of https://github.com/docker/cli.git
Move secret name or ID prefix resolving from client to daemon
This fix is a follow up for comment: https://github.com/docker/docker/pull/28896#issuecomment-265392703 Currently secret name or ID prefix resolving is done at the client side, which means different behavior of API and CMD. This fix moves the resolving from client to daemon, with exactly the same rule: - Full ID - Full Name - Partial ID (prefix) All existing tests should pass. This fix is related to #288896, #28884 and may be related to #29125. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
parent
485a2b2b2f
commit
383ed6f121
|
@ -33,13 +33,9 @@ func runSecretInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
|||
client := dockerCli.Client()
|
||||
ctx := context.Background()
|
||||
|
||||
ids, err := getCliRequestedSecretIDs(ctx, client, opts.names)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
getRef := func(id string) (interface{}, []byte, error) {
|
||||
return client.SecretInspectWithRaw(ctx, id)
|
||||
}
|
||||
|
||||
return inspect.Inspect(dockerCli.Out(), ids, opts.format, getRef)
|
||||
return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getRef)
|
||||
}
|
||||
|
|
|
@ -33,20 +33,15 @@ func runSecretRemove(dockerCli *command.DockerCli, opts removeOptions) error {
|
|||
client := dockerCli.Client()
|
||||
ctx := context.Background()
|
||||
|
||||
ids, err := getCliRequestedSecretIDs(ctx, client, opts.names)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var errs []string
|
||||
|
||||
for _, id := range ids {
|
||||
if err := client.SecretRemove(ctx, id); err != nil {
|
||||
for _, name := range opts.names {
|
||||
if err := client.SecretRemove(ctx, name); err != nil {
|
||||
errs = append(errs, err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Fprintln(dockerCli.Out(), id)
|
||||
fmt.Fprintln(dockerCli.Out(), name)
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
|
|
Loading…
Reference in New Issue