Skip to content

Expose Coder Name to Extension #2791

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

Closed
yorrd opened this issue Feb 28, 2021 · 3 comments
Closed

Expose Coder Name to Extension #2791

yorrd opened this issue Feb 28, 2021 · 3 comments
Labels
feature New user visible feature

Comments

@yorrd
Copy link

yorrd commented Feb 28, 2021

I'm writing internal tooling and would like to access the coder's name (or URL) from within an installed extension in that specific coder. Is there an API for that?

@yorrd yorrd added the feature New user visible feature label Feb 28, 2021
@code-asher
Copy link
Member

code-asher commented Mar 1, 2021

We have an issue to add an environment variable that extensions could use to get the URL: #1510 (comment)

One workaround is to add a query variable to the URL. Query variables are stored in [XDG data dir]/coder.json file so you can read that from your extension.

So for example you could make the URLmycodeserver.com?name=test then in your extension you can get that name with something like this:

require(path.join(dataPath, "coder.json")).query.name

@yorrd
Copy link
Author

yorrd commented Mar 1, 2021

thanks! Will do. Another option that came up in a recent discussion is to use the hostname. They should be set correctly for our containers, so that would also work. Thanks for the input. If you dont need the issue anymore, feel free to close. Not sure how to proceed here.

@code-asher
Copy link
Member

Ah yeah hostname sounds like a great idea! I'll go ahead and close since we have the other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New user visible feature
Projects
None yet
Development

No branches or pull requests

2 participants