(args []string)
| 96 | } |
| 97 | |
| 98 | func (c *PatchCommand) Run(args []string) int { |
| 99 | f := c.Flags() |
| 100 | |
| 101 | if err := f.Parse(args); err != nil { |
| 102 | c.UI.Error(err.Error()) |
| 103 | return 1 |
| 104 | } |
| 105 | |
| 106 | args = f.Args() |
| 107 | switch { |
| 108 | case len(args) < 1: |
| 109 | c.UI.Error(fmt.Sprintf("Not enough arguments (expected 1, got %d)", len(args))) |
| 110 | return 1 |
| 111 | case len(args) == 1 && !c.flagForce: |
| 112 | c.UI.Error("Must supply data or use -force") |
| 113 | return 1 |
| 114 | } |
| 115 | |
| 116 | // Pull our fake stdin if needed |
| 117 | stdin := (io.Reader)(os.Stdin) |
| 118 | if c.testStdin != nil { |
| 119 | stdin = c.testStdin |
| 120 | } |
| 121 | |
| 122 | path := sanitizePath(args[0]) |
| 123 | |
| 124 | data, err := parseArgsData(stdin, args[1:]) |
| 125 | if err != nil { |
| 126 | c.UI.Error(fmt.Sprintf("Failed to parse K=V data: %s", err)) |
| 127 | return 1 |
| 128 | } |
| 129 | |
| 130 | client, err := c.Client() |
| 131 | if err != nil { |
| 132 | c.UI.Error(err.Error()) |
| 133 | return 2 |
| 134 | } |
| 135 | |
| 136 | secret, err := client.Logical().JSONMergePatch(context.Background(), path, data) |
| 137 | return handleWriteSecretOutput(c.BaseCommand, path, secret, err) |
| 138 | } |
nothing calls this directly
no test coverage detected