(ctx context.Context, dockerCLI command.Cli, opts inspectOptions)
| 42 | } |
| 43 | |
| 44 | func runSecretInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions) error { |
| 45 | apiClient := dockerCLI.Client() |
| 46 | |
| 47 | if opts.pretty { |
| 48 | opts.format = "pretty" |
| 49 | } |
| 50 | |
| 51 | getRef := func(id string) (any, []byte, error) { |
| 52 | res, err := apiClient.SecretInspect(ctx, id, client.SecretInspectOptions{}) |
| 53 | return res.Secret, res.Raw, err |
| 54 | } |
| 55 | |
| 56 | // check if the user is trying to apply a template to the pretty format, which |
| 57 | // is not supported |
| 58 | if strings.HasPrefix(opts.format, "pretty") && opts.format != "pretty" { |
| 59 | return errors.New("cannot supply extra formatting options to the pretty template") |
| 60 | } |
| 61 | |
| 62 | secretCtx := formatter.Context{ |
| 63 | Output: dockerCLI.Out(), |
| 64 | Format: newFormat(opts.format, false), |
| 65 | } |
| 66 | |
| 67 | if err := inspectFormatWrite(secretCtx, opts.names, getRef); err != nil { |
| 68 | return cli.StatusError{StatusCode: 1, Status: err.Error()} |
| 69 | } |
| 70 | return nil |
| 71 | } |
no test coverage detected
searching dependent graphs…