-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Fix up EC2 go-discover docs and possibly change escaping behavior #3417
Comments
I just hit this as well when attempting to bring up a consul server cluster during testing, and thought my eyes were bugging out on me re: id vs key. URL escaping behavior was quite the gotcha as well - is there a way to quote the value directly in the array itself so poor end users wouldn't need to worry about escaping in the config? |
@featheredtoast I'm really sorry for the eye strain. In all fairness, the example in the next sentence was using the correct name. :)
I'm not sure what you mean with your escaping question. The format of the retry-join config is |
Merged and updated the website. |
Sure thing - I had the same issue as was recorded in that gitter link. AWS keys may occasionally have slashes or plus characters. Naively copy/pasting these into a consul config doesn't work, as these characters need to be replaced with the URL encoded equivalents, which isn't super clear in the docs. Eg a key like: I see glancing back at the docs, a single reference:
but I seemed to have missed this when parsing through. Perhaps an example making the URL encoded bit a more explicit would help? |
@featheredtoast I've added that reference today so you did not miss that. The intended syntax is If nobody sees an edge case then I'd change the documentation to only replace space with |
Note that the password I was using contained a "+" which absolutely had to be %-escaped in the current model. Saying that spaces are the only issue here is incomplete, at minimum all "+"s and "%"s need to be changed as well. |
More specific: space -> +
|
@odysseus654 of course you're right. Sleep deprivation doesn't help. However, the issue that have to encode this at all is bugging me a bit since you can't just copy and paste the values you got from the cloud providers and make it work. I could write a custom parser which could handle this without encoding since the keys are known tokens and can become the separators. However, that would be a backwards incompatible change since Crude BNF attempt:
|
Is there a reason why we can't just use an object instead of an encoded string here? |
The main motivation was to have a single format that works for all providers so that we could move that code into a separate library and use it across multiple projects. (https://github.com/hashicorp/go-discover) Otherwise, each project would have to implement the argument parsing. Since Having said that, I could also provide a parser that can handle both strings and objects/maps. You could then write
I'll chew on this a bit more. |
@odysseus654 The other argument for a string value is that you can then use it on the command line without introducing flags for all possible parameters. This allows us to have a unified interface for all current and future cloud providers we want to support without adding lots of flags. |
FWIW I am grateful that retry_join takes an array now (and that retry_join_wan exists now, if I recognize what it does). I was coming close to having this need to scan multiple EC2 regions and I wasn't certain how to do it with the previous implementation. |
Opening this up again to capture potentially changing the escaping. |
I've come to the conclusion that using URL encoding for the values was a mistake. It was easy to implement and I only thought of escaping spaces with Therefore, I think we should replace this with a better solution which will be a breaking change for 1.0. I see two options: HCLHCL would have the benefit of already being used in other places but it would require to quote all string values.
Keep custom DSL format but change escaping rulesWith a custom parser we can keep the current format and only fix the quoting and escaping rules. All keys and values are literals and cannot contain spaces. To use spaces you have to double-quote either key and/or value and standard escaping rules with
Unquoting of keys and values would follow the same rules as strconv.Unquote for double-quoted strings. Single quoted and backquoted strings are not supported. Since almost all keys and values will not contain spaces I suggest to stick with the custom DSL option with the changed escaping rules. |
This patch updates the go-discover library to use the new config parser which uses a different encoding scheme for the go-discover config DSL. Values are no longer URL encoded but taken literally unless they contain spaces, backslashes or double quotes. To support keys or values with these special characters the string needs to be double quoted and usual escaping rules apply. Fixes #3417
This patch updates the go-discover library to use the new config parser which uses a different encoding scheme for the go-discover config DSL. Values are no longer URL encoded but taken literally unless they contain spaces, backslashes or double quotes. To support keys or values with these special characters the string needs to be double quoted and usual escaping rules apply. Fixes #3417
Capturing the conversation from https://gitter.im/hashicorp-consul/Lobby?at=599f7b80ee5c9a4c5ff81fe4:
Looks like a documentation issue. We should also make the URL unescaping behavior more prominent/clear.
The text was updated successfully, but these errors were encountered: