fw icon indicating copy to clipboard operation
fw copied to clipboard

Allow placeholder in tags

Open bomgar opened this issue 7 years ago • 8 comments

Would help a lot to set override-path for go projects

bomgar avatar Apr 26 '17 13:04 bomgar

@bomgar do you still need this?

mriehl avatar May 05 '17 15:05 mriehl

yes. because i have to specify a go tag per github group. with a placehoder that won't be nescessary

bomgar avatar May 05 '17 16:05 bomgar

Hmm ok but the workspace path is dependent on the git repo in the golang case. If you have to specifiy the github org in the project instead of setting the org tag then you've gained nothing. So we have to look into not just placeholders but some actual string processing magic I guess (python, lua?).

We could try to compute the github org and offer that as a placeholder ($GITHUB_ORG) but that seems awfully specific for a placeholder given that git urls are not guaranteed to be github ones

On 5. May 2017, at 18:48, Patrick Haun [email protected] wrote:

yes. because i have to specify a go tag per github group. with a placehoder that won't be nescessary

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

mriehl avatar May 06 '17 09:05 mriehl

@bomgar now that you have integrated lua in fblog I think we could consider doing that here too. Spawn a lua func with all sorts of stuff as locals and use the value produced by the func as result.

Maybe this could look like

"override_path": "lua: strlower(github_repo)"

Performance might become an actual concern because we have to evaluate most of the config greedily on load (to ensure sanity for instance)

mriehl avatar Aug 16 '17 15:08 mriehl

I don't think using an embedded interpreter is necessary here. What could also be a much easier and more convenient option is to actually just use a custom binary, and pipe the supplied string into stdin with relevant data being set in environment variables. This would allow for usage like this:

# using bash
override_path = "/bin/sh: echo ${repo_name,,}"

# using lua
override_path = '/usr/bin/lua: print(strlower(os.getenv("repo_name")))'

These would both return the name of the repo to lower case. I think this would allow for more flexibility, and if we're gonna add the prefix, then we might as well use a path to a binary to give users more freedom and allow any scripting language.

Maybe we could also use a shebang like syntax for this, and then write the script to a file in /tmp:

# using bash
override_path = '''
#!/bin/sh
echo ${repo_name,,}
'''

# using lua
override_path = '''
#!/usr/bin/lua
print(strlower(os.getenv("repo_name")))
'''

LordMZTE avatar Jun 13 '21 20:06 LordMZTE

I'm not convinced executing arbitrary code is a good thing here. Maybe a template language like handlebars would be sufficient. But I'm not sure yet.

bomgar avatar Jun 13 '21 20:06 bomgar

Well, a template language would still not allow complicated operations, such as lower casing a string, or converting from camel case to snake_case for example (unless we manually add those functions, but we can't cover everything). Besides that, the proposed lua functionality would also allow executing arbitrary code unless it's sandboxed. I also don't really see a security concern here, as this is a user's personal config which should be trusted.

LordMZTE avatar Jun 13 '21 23:06 LordMZTE

Embedded lua would be fine I guess. Calling external processes adds a lot of complexity to everything and is harder to implement.

bomgar avatar Jun 14 '21 05:06 bomgar