-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to toggle normalization of whitespace/tickfmt #426
Comments
Not in the current version. I would think that the normalization would help with the diffs. The system being used to format the scripts is available via the command https://github.com/influxdata/kapacitor/tree/master/tick/cmd/tickfmt or the package function https://github.com/influxdata/kapacitor/blob/master/tick/fmt.go#L9 You can use those resources before performing a diff to get consistent accurate results. |
Aha, I'll probably end up using that. I still think a toggle for this behaviour would be a good idea, though I don't know if it'd be problematic code-wise. |
It looks like |
Yes that's a good idea thanks
|
Was this implemented somewhere? |
@anlutro No, l closed the issue since |
Right. Like I said, I want to be able to generate diffs - and if those diffs are different from the actual scripts being input (because they have to be normalized by tickfmt), then the diff could be confusing/misleading. Normally this is fine because I can replace tabs with 4 spaces and it's close enough, but I have seen a few cases where I've had to change multi-line lambdas to a less readable format. You could make the argument that tickfmt should always output the most readable format, but everything is subjective, and I'd hate it if I had to go through all my TICKscripts every time there was a new kapacitor release purely because tickfmt's style has changed. Another thing I didn't consider checking is, are comments removed when the script is added? Also, I can't re-open closed issues, only project maintainers (i.e. you) can. |
@anlutro Some thoughts...
Agreed
Comment are preserved.
I would love to see these example if only to improve the format. |
Here's an example:
When I run this through my configuration manager, which does a diff of the file against what the Kapacitor API returns for TICKscript, I always get this diff:
|
@anlutro If we added the toggle as a flag in the API would that be sufficient. Meaning if we always format the script for the output of |
Oh, I thought the script was normalized when you store it with Sure, a query string or something to disable normalization would work as well. |
It is currently but if we are going to toggle it we should change the behavior to store the exact input and on display format. See #480 |
Awesome. Thanks for these great tools 👍 |
I noticed that with 0.12, Kapacitor normalizes whitespace in TICKscripts. It replaces tabs with 4 spaces, and changes this:
Into this:
I'm not necessarily against that, but am writing some code that does diffs of existing scripts compared to new ones. This obviously breaks if Kapacitor says the TICKscript whitespace is different from what it actually is in the source file.
Can the whitespace normalization be disabled?
The text was updated successfully, but these errors were encountered: