feat: show successful resource delete message#212
Conversation
| } | ||
|
|
||
| output, err := output.CmdOutputCreate( | ||
| output, err := output.CmdOutputCreateResource( |
There was a problem hiding this comment.
The API has one less param now.
|
|
||
| // CmdOutputCreateResource returns a response from a resource create action formatted based on the | ||
| // output flag. | ||
| func CmdOutputCreateResource(outputKind string, input []byte) (string, error) { |
There was a problem hiding this comment.
The create and update versions are very similar but delete is different.
dbolson
left a comment
There was a problem hiding this comment.
I can simplify the output function for error handling in another PR.
| response, | ||
| output.SingularPlaintextOutputFn, | ||
| ) | ||
| output, err := output.CmdOutput("get", viper.GetString(cliflags.OutputFlag), response) |
There was a problem hiding this comment.
We need to know if the plaintext output should include a success message, so we pass in this value.
| return nil, errors.NewLDAPIError(err) | ||
| } | ||
| memberJson, err := json.Marshal(members.Items) | ||
| membersJson, err := json.Marshal(members) |
There was a problem hiding this comment.
Updated this for consistency with other responses for multiple resources.
|
|
||
| // CmdOutputCreate builds a command response based on the flag the user provided and the shape of | ||
| // the input with a successfully created message. The expected shape is a single JSON object. | ||
| func CmdOutputCreate(outputKind string, input []byte, fn PlaintextOutputFn) (string, error) { |
There was a problem hiding this comment.
Removed these to have a single CmdOutput function so it's simpler for dynamic resource commands.
|
|
||
| // CmdOutputMultiple builds a command response based on the flag the user provided and the shape of | ||
| // the input. The expected shape is a list of JSON objects. | ||
| func CmdOutputMultiple(outputKind string, input []byte, fn PlaintextOutputFn) (string, error) { |
There was a problem hiding this comment.
This is now unused.
|
|
||
| // CmdOutput returns a response from a resource create action formatted based on the | ||
| // output flag along with an optional message based on the action. | ||
| func CmdOutput(action string, outputKind string, input []byte) (string, error) { |
There was a problem hiding this comment.
This is the "do all the things" function.
We needed to refactor some things to support showing a "Successfully deleted {resource}" message because we don't get a JSON response from API delete requests.
Requirements
Related issues
Provide links to any issues in this repository or elsewhere relating to this pull request.
Describe the solution you've provided
Provide a clear and concise description of what you expect to happen.
Describe alternatives you've considered
Provide a clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context about the pull request here.