Skip to content

[gp-cli] add command to change ports visibility #13253

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

Merged
merged 1 commit into from
Sep 29, 2022
Merged

Conversation

mustard-mh
Copy link
Contributor

@mustard-mh mustard-mh commented Sep 23, 2022

Description

Add new gp-cli command to allow users to change ports visibility

Related Issue(s)

Fixes #10835

How to test

Open workspace in preview env, check with portsView to see if port is locked(private) or unlocked(public)

Public

  • Run curl lama.sh | sh to open port 8080
  • Run gp ports visibility 8080:public to make it public
  • Check PortsView / Visit URL of 8080 in another browser to check if it's visitable

Private

  • Run gp ports visibility 8080:private to make it private
  • Check PortsView / Visit URL of 8080 in another browser to check if it's not visitable

Release Notes

[gp-cli] add command to change ports visibility

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-hw-cmd-port-visibility.1 because the annotations in the pull request description changed
(with .werft/ from main)

@mustard-mh
Copy link
Contributor Author

mustard-mh commented Sep 23, 2022

/werft run

👍 started the job as gitpod-build-hw-cmd-port-visibility.2
(with .werft/ from main)

@mustard-mh
Copy link
Contributor Author

mustard-mh commented Sep 27, 2022

/werft run

👍 started the job as gitpod-build-hw-cmd-port-visibility.3
(with .werft/ from main)

@mustard-mh mustard-mh marked this pull request as ready for review September 27, 2022 08:11
@mustard-mh mustard-mh requested review from a team September 27, 2022 08:11
@github-actions github-actions bot added team: IDE team: webapp Issue belongs to the WebApp team labels Sep 27, 2022
@andrew-farries
Copy link
Contributor

andrew-farries commented Sep 27, 2022

/werft run

👍 started the job as gitpod-build-hw-cmd-port-visibility.4
(with .werft/ from main)

Copy link
Contributor

@andreafalzetti andreafalzetti left a comment

Choose a reason for hiding this comment

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

Tested and works as expected 💯

/hold

@mustard-mh
Copy link
Contributor Author

Updated

Copy link
Member

@filiptronicek filiptronicek left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this, @mustard-mh 🙏. It's a really great feature I cannot wait to use!

portVisibility := args[0]
s := strings.Split(portVisibility, ":")
if len(s) != 2 {
log.Fatal("cannot parse args, should be something like `3000:public` or `3000:private`")
Copy link
Member

Choose a reason for hiding this comment

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

nit(non-blocking): I wonder why we ended up with this format of PORT:VISIBILITY. It reminds me of port bindings in Docker or SSH port-forwarding, but what I expected would be just delimited with a space, like

gp ports visibility 3000 public

what I would find handy and would love to have an alias to this visibility command (maybe even rename it altogether 😝) is to make the syntax as follows:

gp ports make 3000 public

Why?

  • the command reads well and if someone were to dictate it to you over the phone, it'd be hard to "mess it up"
  • it's 6 characters shorter
  • doesn't use any special characters

Copy link
Member

Choose a reason for hiding this comment

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

Tagging @akosyakov as you were the first I could find to propose this format 👀 [1]

Copy link
Contributor

Choose a reason for hiding this comment

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

"make port 3000 public" is very readable however, make is also quite generic and less intuitive at a glance that it's related to setting the port's visibility.

I am happy with the current approach, but happy if we discuss alternatives. My thoughts so far have been:

We could consider set-visibility but I am not fully convinced because:

  1. makes the cmd longer to type (which is not a deal breaker if the name makes sense)
  2. it's not consistent with other cmds (such as gp timeout). For the timeout subcommand we've used the verbs extend and show which at the same time, would make me wonder if the command introduced by this PR, should be gp ports visibility set (although we'd be back at point 1 --> longer cmd).

I then wondered how codespaces named this command and found the same approach so I think @mustard-mh could have used that as inspiration?

gp ports visibility 3000:public is good enough in a way because is short and clear.

The bit that I am not 100% convinced with it either, is that I feel that it's missing the "set" semantic and joining port + visibility feels a bit hacky.

If I had to provide an alternative that I both like and think it's very flexible and clear, it would be: gp ports set-visibility --port 3000 --visibility public - however it's way longer and harder to remember probably.

I am curious to see what other people think.

Copy link
Contributor

@andreafalzetti andreafalzetti Sep 27, 2022

Choose a reason for hiding this comment

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

To recap, we need to agree on the name of the command and how to provide the values.

For the name, our options are:

1️⃣ gp ports visibility
2️⃣ gp ports visibility set
3️⃣ gp ports set-visibility
4️⃣ gp ports publish and gp ports hide

For providing values:

1️⃣ 3000:public
2️⃣ 3000 public
3️⃣ --port 3000 --visibility public

Any other options or suggestions? Please add or express your preferred way 🙏

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for sharing, Andrea! Agreed make is very generic in commands, so may not be the best option. Just had another idea: gp ports publish 3000 and gp ports private/hide 3000 i.e. - make the publish states verbs.

Copy link
Contributor

@andreafalzetti andreafalzetti Sep 27, 2022

Choose a reason for hiding this comment

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

I've updated my comment above with publish/hide 👍

Naming is always hard but I am sure we will agree as a team on a good name. I think finding the best name for a command is important as much as creating a nice UI on the IDE plugin. Thanks for caring and sparking the discussion :)

Copy link
Member

Choose a reason for hiding this comment

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

Codespaces uses the colon format gh codespace ports visibility codespace-port:private|org|public -c codespace-name so maybe it makes sense
I was thinking of something like gp ports update 3000 --visibility=public if we want to change more attributes for a port in the future like adding a label to it you can set that in vscode

Copy link
Contributor Author

@mustard-mh mustard-mh Sep 29, 2022

Choose a reason for hiding this comment

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

I'd like to unhold this PR, created an issue for our discussion. #13443 (update its description if you want)

🙏 Thanks folks for your thoughts

@mustard-mh mustard-mh force-pushed the hw/cmd-port-visibility branch from 307748f to f0ae586 Compare September 29, 2022 09:36
@mustard-mh
Copy link
Contributor Author

Updated help message (see diff)

/unhold

@roboquat roboquat merged commit 0d416fb into main Sep 29, 2022
@roboquat roboquat deleted the hw/cmd-port-visibility branch September 29, 2022 09:42
@roboquat roboquat added the deployed: webapp Meta team change is running in production label Sep 29, 2022
@akosyakov
Copy link
Member

akosyakov commented Sep 29, 2022

@mustard-mh Why don't you use supervisor API? I think we should to manage load in one place. Could you open a follow up PR please. 🙏

@akosyakov
Copy link
Member

Actually I see we do the same in VS Code.

@roboquat roboquat added deployed: IDE IDE change is running in production deployed Change is completely running in production labels Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: gp cli deployed: IDE IDE change is running in production deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note size/M team: IDE team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GP CLI command to control port visibility
7 participants