-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Respond PortsStatus with sorted ports #13788
Conversation
started the job as gitpod-build-hw-port-responsive.6 because the annotations in the pull request description changed |
/hold @mustard-mh we should respect order configured in .gitpod.yml #7764 (comment) that a user can control it I think the order should be like:
You need to create a test project with all these cases. I don't think just sorting numerically is good idea. |
36ab232
to
76c6b74
Compare
76c6b74
to
a79c2ca
Compare
8af84aa
to
ba6af3e
Compare
173680d
to
54f0678
Compare
/werft run 👍 started the job as gitpod-build-hw-port-responsive.16 |
/werft run 👍 started the job as gitpod-build-hw-port-responsive.18 |
Is this PR need to document / change on website? @loujaybee |
@@ -184,7 +186,7 @@ func parseWorkspaceConfigs(ports []*gitpod.PortConfig) (portConfigs map[uint32]* | |||
} | |||
|
|||
func parseInstanceConfigs(ports []*gitpod.PortsItems) (portConfigs map[uint32]*gitpod.PortConfig, rangeConfigs []*RangeConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we instead return an ordered list and avoid specifying the sort order as a property on a map of items?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we instead return an ordered list and avoid specifying the sort order as a property on a map of items?
I want to do it too (my first implement), but we have ranged ports (i.e. 3000-5000
), if someone defined it with large range, the array will be very large too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a concern around the number of bytes needed to store or some other size? I'd expect that the resulting size in bytes would be nearly identical, we're storing n items in both cases.
The extra property of Index probably costs us more as its repeated on each item as opposed to have the sorting implicit which is what a list would do.
Anyhow, just to wanted to flag this up as it felt odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# user can define ranged port like this, and ignore if this num of port is validate or not
ports:
- port: 100001
- port: 1-100000
With Sort
property defined, we don't need anything.
But if we use a new variable like SortedPorts
array, it will contain 100001
items. Or, you need to check if this port number is inside this range or not everytime, it makes code harder to read and wastes resources while getting the ports list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could store it as
ports: [{range: {from: 1, to: 10000}, ...}, {range: {from: 10001, to: 10001}, ...}
Which would give us the same result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, you need to check if this port number is inside this range or not everytime
It's this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it open, and make it a follow-up PR if we are going to change it.
/hold To drop debug commit before merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iQQBot Thanks, I will file an issue to track it 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise, changes look good. I think it's awkward API-wise to put the sort index on the resulting Port object and using a sorted list would be cleaner but the port logic is in your domain ownership so feel free to go with this approach.
/unhold |
@@ -1756,6 +1756,7 @@ type PortConfig struct { | |||
Visibility string `json:"visibility,omitempty"` | |||
Description string `json:"description,omitempty"` | |||
Name string `json:"name,omitempty"` | |||
Sort uint32 `json:"sort,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it something only for internal usage of supervisor? I don’t think we should have such property here then. These are types for gitpod config.
cc @mustard-mh could you remove it to avoid confusion please
@mustard-mh did we consider ports which are not served and not configured but public? We need to show them always as well. Maybe even with higher priority then served but not configured. |
Yes, we did, but if we consider So, for me, I think we have only two choices:
PS. change visibility of ports should not adjust their sort, in case users click so fast (prefer to change them in the same position cc @akosyakov |
@akosyakov I created a follow-up PR, to move |
Description
Related PR gitpod-io/openvscode-server#444
Related Issue(s)
How to test
gp-cli
.gitpod.yml
ports order should change order in portsView too (if file change is detect, you can change name after order change to see if it is detect or not)Rules of order
.gitpod.yml
's ports definegitpod.yml
Release Notes
Documentation
Werft options:
If enabled this will build
install/preview
Valid options are
all
,workspace
,webapp
,ide