Skip to content
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

Detecting which URL was used to spin-up the Gitpod Environment #14923

Closed
Kwok-he-Chu opened this issue Nov 24, 2022 · 9 comments · Fixed by #16096
Closed

Detecting which URL was used to spin-up the Gitpod Environment #14923

Kwok-he-Chu opened this issue Nov 24, 2022 · 9 comments · Fixed by #16096
Assignees
Labels
feature: gitpod yml All things related to the gitpod.yml team: IDE type: feature request New feature or request

Comments

@Kwok-he-Chu
Copy link
Contributor

Is your feature request related to a problem? Please describe

I have multiple applications that can be spun up within the same repository.

Describe the behaviour you'd like

I would like gitpod to run a specific application on-startup. If there are multiple applications, it should be based off where the user came from (see example below). Ideally: Gitpod is aware from which subfolder it spun-up its environment (through URL parameters perhaps?).

Describe alternatives you've considered

  • Having multiple gitpod files support that can be placed within subfolders (gitpod only looks at the /root for the .gitpod.yml file)
    Tried placing the .gitpod.yml file in multiple subfolders.

  • Detecting which URL was used to spin-up the environment (I couldn't find anything about this in the documentation)
    For example: gitpod.io#https://github.com/gitpod-io/gitpod/tree/main/dev would know it came from the subfolder: /main/dev/.
    I can then write a gitpod script/command that checks the origin url and run the application automatically.

  • Current solution:
    Foreach application within the subfolder, I tell the user to execute a specific command in the Terminal

@axonasif
Copy link
Member

Hi @Kwok-he-Chu, what you're trying to do here is possible (maybe it's not just obvious to a new user).

See: https://github.com/gitpod-io/template-dynamic-workspace-location-and-tasks

@axonasif axonasif added type: feature request New feature or request feature: gitpod yml All things related to the gitpod.yml team: IDE labels Nov 24, 2022
@Kwok-he-Chu
Copy link
Contributor Author

Thanks for the swift response @axonasif, I'll take a look!

@axonasif
Copy link
Member

Not sure if this falls under IDE team, but put it to your inbox (IDE team). Possibly related issue:

@Kwok-he-Chu
Copy link
Contributor Author

The solution above worked flawlessly, thank you for providing a clear example @axonasif Are there any future plans of including this information in (for example) an Gitpod environmental variable?

@axonasif
Copy link
Member

Great to hear! That's something @loujaybee could help with I think 🙏

@akosyakov
Copy link
Member

Env vars are subject to change. There are 2 primary means of getting info supervisor API and gp cli.

It is already possible to fetch via supervisor API: curl -s $SUPERVISOR_ADDR/_supervisor/v1/info/workspace | jq .workspaceContextUrl

Adding it to gp info --json | jq .workspaceContextUrl would make sense as well.

@axonasif
Copy link
Member

Nice! Thanks for sharing, something new I learned 😁

@Kwok-he-Chu
Copy link
Contributor Author

@axonasif I've made a PR to add this specific property. Would you mind to take look? :) A nice-to-have would be to include the (most) relevant properties of the supervisor api in gp info.

@axonasif
Copy link
Member

Thank you for the efforts on this @Kwok-he-Chu! I see that the the IDE team was requested a review, so I'll leave it to them 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: gitpod yml All things related to the gitpod.yml team: IDE type: feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants