Skip to content

Commit

Permalink
[supervisor] Include gitpod-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
csweichel committed Aug 3, 2021
1 parent b27445f commit c5a7b32
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/supervisor/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ packages:
- components/supervisor/frontend:app
- components/workspacekit:app
- components/workspacekit:fuse-overlayfs
- components/gitpod-cli:app
argdeps:
- imageRepoBase
config:
Expand Down
1 change: 1 addition & 0 deletions components/supervisor/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COPY components-supervisor--app/supervisor \
supervisor-config.json \
components-workspacekit--app/workspacekit \
components-workspacekit--fuse-overlayfs/fuse-overlayfs \
components-gitpod-cli--app/gitpod-cli \
./
WORKDIR "/.supervisor/dropbear"
COPY components-supervisor--dropbear/dropbear \
Expand Down
27 changes: 26 additions & 1 deletion components/supervisor/pkg/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func Run(options ...RunOption) {
if err != nil {
log.WithError(err).Fatal("cannot ensure Gitpod user exists")
}

symlinkBinaries(cfg)
configureGit(cfg)

tokenService := NewInMemoryTokenService()
Expand Down Expand Up @@ -329,6 +329,31 @@ func createExposedPortsImpl(cfg *Config, gitpodService *gitpod.APIoverJSONRPC) p
return ports.NewGitpodExposedPorts(cfg.WorkspaceID, cfg.WorkspaceInstanceID, gitpodService)
}

// supervisor ships some binaries we want in the PATH. We could just add some directory to the path, but
// instead of producing a strange path setup, we symlink the binary to /usr/bin.
func symlinkBinaries(cfg *Config) {
bin, err := os.Executable()
if err != nil {
log.WithError(err).Error("cannot get executable path - hence cannot symlink binaries")
return
}
base := filepath.Dir(bin)

binaries := map[string]string{
"gitpod-cli": "gp",
}
for k, v := range binaries {
var (
from = filepath.Join(base, k)
to = filepath.Join("/usr/bin", v)
)
err = os.Symlink(from, to)
if err != nil {
log.WithError(err).WithField("from", from).WithField("to", to).Warn("cannot create symlink")
}
}
}

func configureGit(cfg *Config) {
settings := [][]string{
{"push.default", "simple"},
Expand Down

0 comments on commit c5a7b32

Please sign in to comment.