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

chore: move Garden Cloud utils to own module #5435

Merged
merged 6 commits into from
Nov 23, 2023

Conversation

vvagaytsev
Copy link
Collaborator

What this PR does / why we need it:
This is the continuation of the util-refactoring PR series started in #5431.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@vvagaytsev vvagaytsev requested review from mkhq, eysi09 and a team November 17, 2023 14:03
expect(getCloudDistributionName("https://backend.app.garden")).to.eql("Garden Cloud")
})

// TODO: should we care about http/https here? Do we always get only https:// urls?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mkhq @eysi09 any ideas here? Should we consider introducing a type for domains? (Maybe it's an overkill.) Can we get it as a template variable at some point?

Now we also accept garbage strings like "aaabbbcc", for such ones this function will return "Garden Enterprise".

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use the URL library to construct a URL from the string and just read the hostname so that we don't need to worry about the protocol.

It could just throw if the name isn't a valid hostname. It'd be a runtime error but we'd have runtime issues anyway if the hostname is bad.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@eysi09 thanks for the suggestion, sounds good!

I made a quickfix in d0e32f5. That minimizes the semantic changes made in this PR.

Let's make a separate PR with improved URL validation and examination.

@vvagaytsev vvagaytsev changed the title chore: restructuring util/util.ts (part 1) chore: restructuring util/util.ts (part 2) Nov 17, 2023
@vvagaytsev vvagaytsev changed the title chore: restructuring util/util.ts (part 2) chore: move Garden Cloud utils to own module Nov 17, 2023
core/src/util/garden-cloud.ts Outdated Show resolved Hide resolved
expect(getCloudDistributionName("https://backend.app.garden")).to.eql("Garden Cloud")
})

// TODO: should we care about http/https here? Do we always get only https:// urls?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use the URL library to construct a URL from the string and just read the hostname so that we don't need to worry about the protocol.

It could just throw if the name isn't a valid hostname. It'd be a runtime error but we'd have runtime issues anyway if the hostname is bad.

@vvagaytsev vvagaytsev requested a review from eysi09 November 17, 2023 16:41
@vvagaytsev vvagaytsev force-pushed the refactor/util-refactoring-2 branch from d0e32f5 to ae0a261 Compare November 20, 2023 12:30
eysi09
eysi09 previously approved these changes Nov 20, 2023
@vvagaytsev vvagaytsev added this pull request to the merge queue Nov 23, 2023
Merged via the queue into main with commit a7c7816 Nov 23, 2023
3 checks passed
@vvagaytsev vvagaytsev deleted the refactor/util-refactoring-2 branch November 23, 2023 18:05
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