Skip to content

Commit 02ef87e

Browse files
committed
[local-preview] Warn and Confirm from user before proceeding
Currently, For Users with ARM CPU's, `local-preview` does not really work and its hard for the script to know as it runs inside docker (which could be a x86 VM). This Updates the script to warn the users on the requirements before starting and running `local-preview`. Signed-off-by: Tarun Pothulapati <tarun@gitpod.io>
1 parent 0acc0b3 commit 02ef87e

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed

install/preview/prettylog/go.mod

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ module github.com/gitpod-io/gitpod/install/preview/prettylog
33
go 1.18
44

55
require (
6-
github.com/atomicgo/cursor v0.0.1 // indirect
76
github.com/gookit/color v1.5.0 // indirect
87
github.com/mattn/go-runewidth v0.0.13 // indirect
9-
github.com/pterm/pterm v0.12.41
8+
github.com/pterm/pterm v0.12.42
109
github.com/rivo/uniseg v0.2.0 // indirect
1110
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
1211
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
@@ -15,7 +14,12 @@ require (
1514
)
1615

1716
require (
17+
atomicgo.dev/cursor v0.1.1 // indirect
18+
atomicgo.dev/keyboard v0.2.8 // indirect
1819
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
20+
github.com/containerd/console v1.0.3 // indirect
21+
github.com/lithammer/fuzzysearch v1.1.5 // indirect
1922
github.com/segmentio/backo-go v1.0.1 // indirect
2023
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
24+
golang.org/x/text v0.3.7 // indirect
2125
)

install/preview/prettylog/go.sum

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/preview/prettylog/main.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,33 @@ var (
3737
}
3838
)
3939

40+
// confirm from the user to continue
41+
func confirm() bool {
42+
scanner := bufio.NewScanner(os.Stdin)
43+
fmt.Print("Continue? [y|n]: ")
44+
scanner.Scan()
45+
input := strings.ToLower(scanner.Text())
46+
// yes by default
47+
if input == "y" || input == "yes" || input == "" {
48+
return true
49+
}
50+
return false
51+
}
52+
4053
func main() {
54+
// Warn and wait for user approval
55+
pterm.FgLightCyan.Println(`
56+
Welcome to the local preview of Gitpod. Please note the following limitations:
57+
- Performance is limited by the capabilities of your machine - a minimum of 4 cores and 6GB of RAM are required
58+
- ARM CPUs including Macs with Apple Silicon (e.g. M1) are currently not supported
59+
For more information about these limitation, please visit the local preview documentation: https://www.gitpod.io/docs/self-hosted/latest/local-preview`)
60+
if !confirm() {
61+
// send telemetry for user exit
62+
fmt.Println("Exit")
63+
send_telemetry("user exit")
64+
return
65+
}
66+
4167
dmp, err := os.OpenFile("logs.txt", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
4268
if err != nil {
4369
panic(err)

0 commit comments

Comments
 (0)