This message was deleted.
# typescript
s
This message was deleted.
l
Does \\ not work?
e
No, it produces \\. That is what I have in the beginning and desire it there. After the .net, I desire a single \ but cannot get it to go.
l
What language is it? Is there a different quote character?
e
typescript
i want an output of a UNC path, like \\<storageAccountName.file.core.windows.net\<shareName>.
l
When I run
console.log("\\");
I see
\
e
When I use a single backslash like what I have in the original example after .net, it makes what comes after it (fileShare.name) raw text. I am unable to escape it.
That may be true with console.log. Not how it is working in Pulumi and typescript.
My first part of "\\" shows \\ and I desire it there. I have tried three \\\, four \\\\, etc. No dice.
l
Are you using typescript? That behaviour differs from what I'm seeing.
e
yes, I am using typescript in Pulumi.
Her is a line with no issues.
Copy code
export const fslProfilesUnc = pulumi.concat("\\", storageAccount.name, ".<http://file.core.windows.net|file.core.windows.net>", fileShareProfiles.name);
Need to get a '\' after the '.net'.
l
Try another "\\", instead of "x.y.net\\".
Honestly, this is too weird to explain 🙂
e
No go. It produces two \\ in output just like it does in the beginning.
+ fslProfilesUnc: "\\saf0de4e4c\\profiles"
Goofy for sure! 😀
l
Could it be something to do with your editor? Is the file being transformed in some way? "\\" is definitely the correct way to produce a single backslash in JS/TS; could there be something odd in your environment?
You could try using '\\'?
There may be a file separator constant that you could use?
e
The way I see it, if I want a \\, it should be \\\\ and if I want a single \, it should be \\.
💯 1
l
How about importing path and using
path.sep
?
e
I am not that fluent. lol
l
Copy code
import * as path from "path";
console.log(path.sep);
On Windows, path.sep will be
\
It removes portability unfortunately; you won't be able to build UNC paths on non-Windows machines.
Have you checked that
storageAccount.name
doesn't start with
\
?
If it does, then "\\" is correctly generating
\
e
no it does not start with \
I am already successfully generating \\ with "\\", no issue. I am just unable to generate a single \. Windows should not matter. I am not trying to use a UNC path yet, in which case it would only work on a Windows OS; understood. I am simply trying to out a text string that represents a UNC path here.
l
Yes. We have a weird issue, which is that "\\" is generating
\\
, which it doesn't do for anyone else. I can't help with that, you'll have to figure that one out yourself. My current suggestion is to get
path.sep
and use it when building your string. On Windows machines,
path.sep
is
\
, so it should do the job.
BTW, what is
pulumi.concat()
? I haven't seen that before.
Ah, I looked it up. It's like interpolate. You could try switching to interpolate, maybe there's a bug in pulumi.concat?
Copy code
export const var = pulumi.interpolate`\\\\${storageAccount.name}.<http://file.core.windows.net|file.core.windows.net>\\${fileShare.name}`
e
Going to sleep on it. Thanks!
l
I'm a Puluminary. Quite familiar with Pulumi 🙂
No worries, I'm here to help.
You'll need to put in a valid variable name. I used the same example as you provided at the top of the thread.
e
Those are valid variable names. It is the position of your \\\\ that is throwing it off.
l
var
is an identifier in typescript, not a valid variable name.
Try "x"
e
You are correct.
I am familiar with pulumi.interpolate and use it often. I thought you nailed it for a minute. I have tried several different combinations with it. Same issue with the single \ whether using pulumi.interpolate or pulumi.concat.
Copy code
export const x = pulumi.interpolate`\\\\${storageAccount.name}.<http://file.core.windows.net|file.core.windows.net>\\${fileShareProfiles.name}`
is valid code and produces the following output: '\\\\fqdn\\share'.
l
Ah yes, sorry, my bad. In backticks, you don't need to quote backslashes.
e
What do you mean?
Copy code
export const x = pulumi.interpolate`\\${storageAccount.name}.<http://file.core.windows.net|file.core.windows.net>\${fileShareProfiles.name}`
turns
$fileShareShareProfiles.name
to a string and produces the following output: '\\fqdn${fileShareProfiles.name}'.
It is the same issue with the not being able to escape the single \ as when we were using
pulumi.concat
.
l
"\$" quotes the $, which breaks the interpolation. "\\" is supposed to escape the "\" but it's not, for you. Can you confirm that this sort of this is happening for you with strings that are not Outputs? What does this output?
Copy code
const simpleString = "foo";
const slashyString = "x\\y";
console.log(`\\ ${simpleString} Continue ${slashyString} \\`);
That issue you posted seems to be exactly what you're encountering.
So it looks like you're foiled for now, unless you find a clever workaround, maybe regex-replacing or something.
e
The console log works just fine, but need a Pulumi output. /smh
Copy code
str = '\\'
Copy code
console.log(str);
output = '\'
Pulumi does not like a single '\' in a string. I tried atChar(index) to try to extract a single character of '\' and then use that as a variable in my complete string. It inserts it as a double '\\'. I tried putting a var of '\' in my stack config and then using that as a variable in my complete string. It still inserts the double '\\'.
l
You will have to upvote that GitHub issue, and work around the problem some other way. Maybe create the resource inside an apply in order to bypass Pulumi's intervention?
e
@little-cartoon-10569 I am happy to report that with more testing, what you gave me last does essentially work. It is deceiving as when you
pulumi up
to create the output, the output value on the screen is not what is expected. However, if I then run a
pulumi stack output
or observe the output from the web app, it is exactly what I need it to be with the extra backslashes removed.
Copy code
export const fslShare = pulumi.interpolate`\\\\${storageAccount.name}.<http://file.core.windows.net|file.core.windows.net>$\\${fileShareProfiles.name}`;
That produces
+ fslShare: "\\<http://name.core.windows.net|name.core.windows.net>\\profiles"
on screen after
pulumi up
. However, the stack output is
fslShare  \\<http://name.file.core.windows.net|name.file.core.windows.net>$\profiles
. A misread that had me chasing something for nothing.
l
Good stuff! 🎉 Would you like to add a comment to that GitHub issue with your findings? It may help them resolve the issue faster.