Skip to content

Commit 2344fa9

Browse files
committed
[local-app] Make part of the regular build
1 parent b32c123 commit 2344fa9

File tree

5 files changed

+106
-44
lines changed

5 files changed

+106
-44
lines changed

components/BUILD.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ packages:
1919
- components/ide/code:docker
2020
- components/ide/theia:docker
2121
- components/image-builder:docker
22+
- components/local-app:docker
2223
- components/proxy:docker
2324
- components/registry-facade:docker
2425
- components/server:docker
2526
- components/service-waiter:docker
2627
- components/supervisor-api/typescript-grpc:publish
2728
- components/supervisor:docker
29+
- components/ws-daemon:docker
2830
- components/ws-daemon/seccomp-profile-installer:docker
2931
- components/ws-daemon/shiftfs-module-loader:docker
30-
- components/ws-daemon:docker
3132
- components/ws-manager-bridge:docker
3233
- components/ws-manager:docker
3334
- components/ws-proxy:docker

components/local-app/BUILD.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
packages:
22
- name: app
3+
type: generic
4+
config:
5+
commands: [["echo"]]
6+
deps:
7+
- :app-linux
8+
- :app-darwin
9+
- :app-windows
10+
- name: app-linux
11+
type: go
12+
srcs:
13+
- go.mod
14+
- go.sum
15+
- "**/*.go"
16+
deps:
17+
- components/supervisor-api/go:lib
18+
- components/gitpod-protocol/go:lib
19+
env:
20+
- CGO_ENABLED=0
21+
- GOOS=linux
22+
config:
23+
packaging: app
24+
- name: app-darwin
325
type: go
426
srcs:
527
- go.mod
@@ -8,5 +30,32 @@ packages:
830
deps:
931
- components/supervisor-api/go:lib
1032
- components/gitpod-protocol/go:lib
33+
env:
34+
- CGO_ENABLED=0
35+
- GOOS=darwin
1136
config:
1237
packaging: app
38+
- name: app-windows
39+
type: go
40+
srcs:
41+
- go.mod
42+
- go.sum
43+
- "**/*.go"
44+
deps:
45+
- components/supervisor-api/go:lib
46+
- components/gitpod-protocol/go:lib
47+
env:
48+
- CGO_ENABLED=0
49+
- GOOS=windows
50+
config:
51+
packaging: app
52+
- name: docker
53+
type: docker
54+
deps:
55+
- :app
56+
argdeps:
57+
- imageRepoBase
58+
config:
59+
dockerfile: leeway.Dockerfile
60+
image:
61+
- ${imageRepoBase}/local-app:${version}

components/local-app/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# local-app
2+
3+
**Beware**: this is very much work in progress and will likely break things.
4+
5+
## How to install
6+
```
7+
docker run --rm -it -v /tmp/dest:/out eu.gcr.io/gitpod-core-dev/build/local-app:<version>
8+
```
9+
10+
## How to run
11+
```
12+
./local-app
13+
```
14+
15+
## How to run in Gitpod against a dev-staging environment
16+
```
17+
cd components/local-app
18+
BROWSER= GITPOD_HOST=<URL-of-your-preview-env> go run main.go --mock-keyring run
19+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2+
# Licensed under the GNU Affero General Public License (AGPL).
3+
# See License-AGPL.txt in the project root for license information.
4+
5+
FROM alpine:3.13
6+
7+
WORKDIR /app
8+
COPY components-local-app--app/components-local-app--app-linux/local-app local-app-linux
9+
COPY components-local-app--app/components-local-app--app-darwin/local-app local-app-darwin
10+
COPY components-local-app--app/components-local-app--app-windows/local-app.exe local-app-windows.exe
11+
12+
CMD ["/bin/sh", "-c", "cp /app/* /out"]

components/local-app/cmd/debug/main.go renamed to components/local-app/main.go

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package main
77
import (
88
"context"
99
"errors"
10-
"fmt"
1110
"log"
1211
"os"
1312
"strings"
@@ -22,56 +21,36 @@ import (
2221

2322
func main() {
2423
app := cli.App{
25-
Name: "local-app-debug",
26-
Commands: []*cli.Command{
27-
{
28-
Name: "login",
29-
Action: func(c *cli.Context) error {
30-
keyring.MockInit()
31-
_, err := auth.Login(context.Background(), auth.LoginOpts{
32-
GitpodURL: c.String("gitpod-host"),
33-
})
34-
if err != nil {
35-
return err
36-
}
37-
fmt.Println("login successful")
38-
return nil
39-
},
40-
Flags: []cli.Flag{
41-
&cli.StringFlag{
42-
EnvVars: []string{
43-
"GITPOD_HOST",
44-
},
45-
Name: "gitpod-host",
46-
},
24+
Name: "gitpod",
25+
Action: DefaultCommand("run"),
26+
EnableBashCompletion: true,
27+
Flags: []cli.Flag{
28+
&cli.StringFlag{
29+
Name: "gitpod-host",
30+
Usage: "URL of the Gitpod installation to connect to",
31+
EnvVars: []string{
32+
"GITPOD_HOST",
4733
},
4834
},
35+
&cli.BoolFlag{
36+
Name: "mock-keyring",
37+
Usage: "Don't use system native keyring, but store Gitpod token in memory",
38+
},
39+
},
40+
Commands: []*cli.Command{
4941
{
5042
Name: "run",
5143
Action: func(c *cli.Context) error {
5244
if c.Bool("mock-keyring") {
5345
keyring.MockInit()
5446
}
55-
return run(c.String("gitpod-host"), c.String("token"), c.String("ssh_config"))
47+
return run(c.String("gitpod-host"), c.String("ssh_config"))
5648
},
5749
Flags: []cli.Flag{
58-
&cli.StringFlag{
59-
EnvVars: []string{
60-
"GITPOD_HOST",
61-
},
62-
Name: "gitpod-host",
63-
},
64-
&cli.StringFlag{
65-
Name: "token",
66-
EnvVars: []string{
67-
"GITPOD_TOKEN",
68-
},
69-
},
7050
&cli.PathFlag{
71-
Name: "ssh_config",
72-
},
73-
&cli.BoolFlag{
74-
Name: "mock-keyring",
51+
Name: "ssh_config",
52+
Usage: "produce and update an OpenSSH compatible ssh_config file",
53+
Value: "/tmp/gitpod_ssh_config",
7554
},
7655
},
7756
},
@@ -83,11 +62,13 @@ func main() {
8362
}
8463
}
8564

86-
func run(host, token, sshConfig string) error {
87-
if token != "" {
88-
auth.SetToken(host, token)
65+
func DefaultCommand(name string) cli.ActionFunc {
66+
return func(ctx *cli.Context) error {
67+
return ctx.App.Command(name).Run(ctx)
8968
}
69+
}
9070

71+
func run(host, sshConfig string) error {
9172
tkn, err := auth.GetToken(host)
9273
if errors.Is(err, keyring.ErrNotFound) {
9374
tkn, err = auth.Login(context.Background(), auth.LoginOpts{GitpodURL: host})

0 commit comments

Comments
 (0)