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

Add support to localhost urls while debugging #3664

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sergiolms
Copy link
Contributor

@sergiolms sergiolms commented Oct 10, 2024

Description

These changes will allow testing local development on APIs and backend services of gk-dev. With this, you can now set the following settings in settings.json (made up urls for the example):

{
	"gitkraken.env": "local",
	"gitkraken.url": {
		"api": "http://localhost:1314/api",
		"gkdev": {
			"base": "http://localhost:1314",
			"api": "http://localhost:1314/gkdev/api"
		}
	}
}

NOTE: URLs will only be applied when gitkraken.env is set to local. Also, the local environment has the same restrictions as dev and staging (only available if it's pre-release or debugging).

Checklist

  • I have followed the guidelines in the Contributing document
  • My changes follow the coding style of this project
  • My changes build without any errors or warnings
  • My changes have been formatted and linted
  • My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

@sergiolms sergiolms self-assigned this Oct 10, 2024
@sergiolms sergiolms changed the title [POC] Add support to localhost env and custom urls Add support to localhost env and custom urls Oct 10, 2024
@sergiolms sergiolms force-pushed the poc_add_localhost_to_env branch from 8905af3 to 260cd12 Compare October 10, 2024 10:36
@sergiolms sergiolms changed the title Add support to localhost env and custom urls Add support to localhost urls while debugging Oct 10, 2024
@@ -919,6 +919,11 @@ export class Container {

@memoize()
private get baseGkDevUri(): Uri {
if (this.prereleaseOrDebugging) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest instead of this.prereleaseOrDebugging, to allow the value local for gitkraken.env and then checking that here.

And if it is local and this url is not provided, we should throw because we don't want someone targeting prod and thinking they were on a local setup.

Same with the other cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with that local value for env, but if I do that and you only want to overwrite 1 URL, you still have to manually put the other ones because env won't tell you anymore if you're on dev, staging or prod. Which is totally okay if we want to do that and make the developer aware they have to manually set all URLs in config. In fact, my first commit does that, and I could retake it if we want to go down this path and throw instead of setting a default URL, as you said.

However, I found it unconvenient that you had to manually set all URLs if you wanted to overwrite just one, so I switched to a useLocal boolean that would "enable" the use of URLs, but again it seemed like setting an URL should be enough to specify that it should use it. With that, you would overwrite the desired URL, and leave all the rest up to env to decide where to point at.

Again, I'm totally up for both options so I appreciate the point of view

@sergiolms sergiolms marked this pull request as draft October 11, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants