* fix: template apply uses better diff checking
Previously, we did a DeepEqual of all the returned data about each changed entity,
but due to our template overrides that is not actually all the information
available for each entity. So we marked trivial things as 'conflicts' (e.g.
telegraf config ID's 'changing' from the empty string to the real, current value)
while not catching important conflicts like flux script changes in checks and tasks.
Changes to make things more straightforward:
* Change the --force behaviour to be more similar to `apt install`, where even
in non-interactive mode `--force yes` is required to bypass the prompt to apply.
* Before, there were two stages of diff checking - once to print diffs, and once
after the 'Yes/No' prompt. If any conflicts were detected in the second check,
the user got an inscrutable error message that did not highlight what the difference
was or how to force it to apply. `--force conflict` was required to avoid this error.
Instead, we now have simplified to `--force yes` to bypass the 'Yes/No' prompt, and
we never do a second stage of diff checking.
* Because we do not currently properly account for more complicated diffs (e.g.
flux tasks), we now assume in the diff printing that every object has changes,
except for Labels, Buckets, Variables, and Label Mappings. This could be improved
in the future.
* fix: when statestatus is 'remove', mark as removed
* feat(write): warn about standalone CR characters in header lines
* feat(write): add test for Windows CRLF line endings
* chore: improve warning message
Co-authored-by: Daniel Moran <danxmoran@gmail.com>
* chore: update test with a new warning message
Co-authored-by: Daniel Moran <danxmoran@gmail.com>
* refactor: take clients out of internal
* refactor: move stdio to pkg
* Move internal/api to api
* refactor: final changes for Kapacitor to access shared functionality
* chore: regenerate mocks
* fix: bad automated refactor
* chore: extra formatting not caught by make fmt
This commit represents a few experiments of features I've used in Cobra
1. Uses cli.GenericFlag to encapsulate parsing and validation of flag
values at parse time. This removes the burden from the individual
CLI commands to parse and validate args and options.
2. Add influxid.ID that may be used by any flag that requires an
Influx ID. influxid.ID parses and validates string value is a valid
ID, removing this burden from individual commands and ensuring valid
values before the command actions begins.
3. Binds cli.Flags directly to params structures to directly capture
the values when parsing flags.
4. Moves from global state to local builder functions for the majority
of the commands. This allows the commands to bind to flag variables
reducing the repeated ctx.String(), ctx.Int(), etc
5. Leverages the BeforeFunc to create middleware and inject the CLI and
API client into commands, saving the repeated boilerplate across
all of the instantiated commands. This is extensible, so additional
middleware can be appends using the middleware.WithBeforeFns