-
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
[local-preview] Warn and Confirm from user before proceeding #13123
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,14 @@ | |
package main | ||
|
||
import ( | ||
"bufio" | ||
"errors" | ||
"fmt" | ||
"io" | ||
"log" | ||
"os" | ||
"strings" | ||
|
||
"github.com/hpcloud/tail" | ||
"github.com/pterm/pterm" | ||
"gopkg.in/segmentio/analytics-go.v3" | ||
) | ||
|
@@ -38,21 +39,31 @@ var ( | |
) | ||
|
||
func main() { | ||
dmp, err := os.OpenFile("logs.txt", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) | ||
if err != nil { | ||
panic(err) | ||
// Warn and wait for user approval | ||
pterm.FgLightCyan.Println(` | ||
Welcome to the local preview of Gitpod. Please note the following limitations: | ||
- Performance is limited by the capabilities of your machine - a minimum of 4 cores and 6GB of RAM are required | ||
- ARM CPUs including Macs with Apple Silicon (e.g. M1) are currently not supported | ||
For more information about these limitation, please visit the local preview documentation: https://www.gitpod.io/docs/self-hosted/latest/local-preview`) | ||
|
||
result, _ := pterm.DefaultInteractiveConfirm.WithDefaultText("Continue?").WithDefaultValue(true).Show() | ||
if !result { | ||
// send telemetry for user exit | ||
send_telemetry("user exit") | ||
return | ||
} | ||
defer dmp.Close() | ||
|
||
r := io.TeeReader(os.Stdin, dmp) | ||
file, err := tail.TailFile("logs.txt", tail.Config{Follow: true}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mrsimonemms Like we discussed in our call. This was because while Instead we need a way to continuously read There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was also able to test that this works as expected! |
||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
scan := bufio.NewScanner(r) | ||
var msgIdx int | ||
lastSpinner, _ := pterm.DefaultSpinner.Start(msgs[msgIdx].Msg) | ||
// send Telemetry update for the first phase | ||
send_telemetry(msgs[msgIdx].Status) | ||
for scan.Scan() { | ||
line := scan.Text() | ||
for tailLine := range file.Lines { | ||
line := tailLine.Text | ||
msg := msgs[msgIdx] | ||
var next bool | ||
switch { | ||
|
@@ -77,7 +88,7 @@ func main() { | |
send_telemetry(msgs[msgIdx].Status) | ||
|
||
} | ||
err = scan.Err() | ||
err = file.Err() | ||
if errors.Is(err, io.EOF) { | ||
err = nil | ||
} | ||
|
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.
I'd suggest we change this to:
--> This adds a link & removes the periods at the end of the bullet points.
--> I am assuming we can do links in the CLI output here, but not sure how / if this works.
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.
It is rendered like this, with the http link being clickable (depends on the shell too). WDYT?
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.
In that case we should likely not try to make the http link a clickable link (with the ... ) like on the web but instead have the link as full text:
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.
Updated. Will mark it ready once I test the final command out!
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.
While the input works with
go run .
, It does not seem to work as expected when we run it inside docker. So, Trying to make that work now!