Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit a69901c

Browse files
committed
Merge branch 'master' into specify-folder
2 parents 457b112 + 93844eb commit a69901c

37 files changed

+262
-77
lines changed

.sail/Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | b
88

99
LABEL project_root "~/go/src/go.coder.com"
1010

11-
# Modules break much of Go's tooling.
12-
ENV GO111MODULE=off
13-
1411
# Install the latest version of Hugo.
1512
RUN wget -O /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.55.4/hugo_extended_0.55.4_Linux-64bit.deb && \
1613
sudo dpkg -i /tmp/hugo.deb && \

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[!["Open Issues"](https://img.shields.io/github/issues-raw/cdr/sail.svg)](https://github.com/cdr/sail/issues)
44
[![MIT license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/cdr/sail/blob/master/LICENSE)
5+
[![AUR version](https://img.shields.io/aur/version/sail.svg)](https://aur.archlinux.org/packages/sail/)
56
[![Discord](https://img.shields.io/discord/463752820026376202.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/zxSwN8Z)
67

78
`sail` is a universal workflow for reproducible, project-defined development environments.
@@ -57,6 +58,8 @@ in your [$PATH](https://superuser.com/questions/284342/what-are-path-and-other-e
5758
curl https://sail.dev/install.sh | bash
5859
```
5960

61+
For Arch users, there is an official [AUR package](https://aur.archlinux.org/packages/sail).
62+
6063
### Verify the Installation
6164

6265
To verify Sail is properly installed, run `sail --help` on your system. If everything is installed correctly, you should see Sail's help text.
@@ -73,3 +76,4 @@ To open GitHub or GitLab projects in a Sail environment with a single click, see
7376
### Learn More
7477

7578
Additional docs covering concepts and configuration can be found at [https://sail.dev/docs](https://sail.dev/docs/introduction/).
79+

autocomplete.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"unicode/utf8"
77

88
"github.com/posener/complete"
9+
910
"go.coder.com/cli"
1011
)
1112

chrome.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ import (
1515
"time"
1616
"unsafe"
1717

18-
"go.coder.com/cli"
19-
"go.coder.com/flog"
2018
"golang.org/x/xerrors"
2119
"nhooyr.io/websocket"
2220
"nhooyr.io/websocket/wsjson"
21+
22+
"go.coder.com/cli"
23+
"go.coder.com/flog"
2324
)
2425

2526
func runNativeMsgHost() {
@@ -108,6 +109,10 @@ func (c *chromeExtInstall) Run(fl *flag.FlagSet) {
108109
}
109110

110111
for _, dir := range nativeHostDirs {
112+
if dir == "" {
113+
continue
114+
}
115+
111116
err = os.MkdirAll(dir, 0755)
112117
if err != nil {
113118
flog.Fatal("failed to ensure manifest directory exists: %v", err)
@@ -146,14 +151,20 @@ func nativeMessageHostManifestDirectories() ([]string, error) {
146151
}
147152

148153
var chromeDir string
154+
var chromeBetaDir string
155+
var chromeDevDir string
156+
var chromeCanaryDir string
149157
var chromiumDir string
150158

151159
switch runtime.GOOS {
152160
case "linux":
153161
chromeDir = path.Join(homeDir, ".config", "google-chrome", "NativeMessagingHosts")
162+
chromeBetaDir = path.Join(homeDir, ".config", "google-chrome-beta", "NativeMessagingHosts")
163+
chromeDevDir = path.Join(homeDir, ".config", "google-chrome-unstable", "NativeMessagingHosts")
154164
chromiumDir = path.Join(homeDir, ".config", "chromium", "NativeMessagingHosts")
155165
case "darwin":
156166
chromeDir = path.Join(homeDir, "Library", "Application Support", "Google", "Chrome", "NativeMessagingHosts")
167+
chromeCanaryDir = path.Join(homeDir, "Library", "Application Support", "Google", "Chrome Canary", "NativeMessagingHosts")
157168
chromiumDir = path.Join(homeDir, "Library", "Application Support", "Chromium", "NativeMessagingHosts")
158169
default:
159170
return nil, xerrors.Errorf("unsupported os %q", runtime.GOOS)
@@ -162,5 +173,8 @@ func nativeMessageHostManifestDirectories() ([]string, error) {
162173
return []string{
163174
chromeDir,
164175
chromiumDir,
176+
chromeBetaDir,
177+
chromeDevDir,
178+
chromeCanaryDir,
165179
}, nil
166180
}

ci/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ build(){
1010
go build -ldflags "-X main.version=${tag}" -o $tmpdir/sail
1111

1212
pushd $tmpdir
13-
tarname=sail-$GOOS-$GOARCH.tar
14-
tar -cf $tarname sail
13+
tarname=sail-$GOOS-$GOARCH.tar.gz
14+
tar -czf $tarname sail
1515
popd
1616
cp $tmpdir/$tarname bin
1717
rm -rf $tmpdir
1818
}
1919

2020
GOOS=darwin build
21-
GOOS=linux build
21+
GOOS=linux build

codeserver.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,31 @@ import (
1414
"strings"
1515
"time"
1616

17+
"golang.org/x/xerrors"
18+
1719
"go.coder.com/flog"
1820
"go.coder.com/sail/internal/codeserver"
19-
"golang.org/x/xerrors"
2021
)
2122

2223
// loadCodeServer produces a path containing the code-server binary.
2324
// It will attempt to cache the binary.
2425
func loadCodeServer(ctx context.Context) (string, error) {
2526
start := time.Now()
2627

27-
const cachePath = "/tmp/sail-code-server-cache/code-server"
28+
var cachePath string
29+
const codeServerPathSuffix = "sail-code-server-cache/code-server"
30+
// MacOS maps os.TempDir() to `/var/folders/...`, which isn't shared with the docker
31+
// system since docker tries to comply with Apple's filesystem sandbox guidelines, so
32+
// default to `/tmp` when on MacOS.
33+
//
34+
// See:
35+
// https://stackoverflow.com/questions/45122459/docker-mounts-denied-the-paths-are-not-shared-from-os-x-and-are-not-known
36+
switch runtime.GOOS {
37+
case "darwin":
38+
cachePath = filepath.Join("/tmp", codeServerPathSuffix)
39+
default:
40+
cachePath = filepath.Join(os.TempDir(), codeServerPathSuffix)
41+
}
2842

2943
// downloadURLPath stores the download URL, so we know whether we should update
3044
// the binary.

config.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88

99
"github.com/BurntSushi/toml"
10+
1011
"go.coder.com/flog"
1112
)
1213

@@ -18,27 +19,28 @@ func resolvePath(homedir string, path string) string {
1819
return path
1920
}
2021

21-
list := strings.Split(path, string(filepath.Separator))
22-
23-
for i, seg := range list {
24-
if seg == "~" {
25-
list[i] = homedir
26-
}
22+
// Replace tilde notation in path with homedir.
23+
if path == "~" {
24+
path = homedir
25+
} else if strings.HasPrefix(path, "~/") {
26+
path = filepath.Join(homedir, path[2:])
2727
}
2828

29-
return filepath.Join(list...)
29+
return filepath.Clean(path)
3030
}
3131

3232
// config describes the config.toml.
3333
// Changes to this should be accompanied by changes to DefaultConfig.
3434
type config struct {
35-
DefaultImage string `toml:"default_image"`
36-
ProjectRoot string `toml:"project_root"`
37-
DefaultHat string `toml:"default_hat"`
38-
DefaultSchema string `toml:"default_schema"`
39-
DefaultHost string `toml:"default_host"`
35+
DefaultImage string `toml:"default_image"`
36+
ProjectRoot string `toml:"project_root"`
37+
DefaultHat string `toml:"default_hat"`
38+
DefaultSchema string `toml:"default_schema"`
39+
DefaultHost string `toml:"default_host"`
40+
DefaultOrganization string `toml:"default_organization"`
4041
}
4142

43+
// DefaultConfig is the default configuration file string.
4244
const DefaultConfig = `# sail configuration.
4345
# default_image is the default Docker image to use if the repository provides none.
4446
default_image = "codercom/ubuntu-dev"
@@ -55,6 +57,10 @@ default_schema = "ssh"
5557
5658
# default host used to clone repo in sail run if none given
5759
default_host = "github.com"
60+
61+
# default_oranization lets you configure which username to use on default_host
62+
# when cloning a repo.
63+
# default_organization = ""
5864
`
5965

6066
// metaRoot returns the root path of all metadata stored on the host.

editcmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
"time"
1010

1111
"github.com/docker/docker/api/types"
12+
"golang.org/x/xerrors"
1213

1314
"go.coder.com/cli"
1415
"go.coder.com/flog"
1516
"go.coder.com/sail/internal/dockutil"
1617
"go.coder.com/sail/internal/editor"
1718
"go.coder.com/sail/internal/randstr"
1819
"go.coder.com/sail/internal/xexec"
19-
"golang.org/x/xerrors"
2020
)
2121

2222
type editcmd struct {

extension/logo128.png

1.23 KB
Loading

extension/manifest.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33

44
"name": "Sail",
5-
"version": "1.0.5",
5+
"version": "1.0.9",
66
"author": "Coder",
77
"description": "Work in immutable, pre-configured development environments.",
88

@@ -15,7 +15,8 @@
1515
"content_scripts": [
1616
{
1717
"matches": [
18-
"https://*/*"
18+
"https://github.com/*",
19+
"https://gitlab.com/*"
1920
],
2021
"js": [
2122
"out/content.js"
@@ -25,8 +26,11 @@
2526
"permissions": [
2627
"nativeMessaging"
2728
],
29+
"icons": {
30+
"128": "logo128.png"
31+
},
2832
"browser_action": {
2933
"default_title": "Sail",
3034
"default_popup": "out/popup.html"
3135
}
32-
}
36+
}

extension/pack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
zip -R extension manifest.json out/*
3+
zip -R extension manifest.json out/* logo128.png

extension/src/content.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const doConnection = (socketUrl: string, projectUrl: string, onMessage: (data: {
2323
return;
2424
}
2525
const type = data.type;
26-
const content = atob(data.v);
26+
const content = type === "data" ? atob(data.v) : data.v;
2727

2828
switch (type) {
2929
case "data":
@@ -39,7 +39,7 @@ const doConnection = (socketUrl: string, projectUrl: string, onMessage: (data: {
3939

4040
const ensureButton = (): void | HTMLElement => {
4141
const buttonId = "openinsail";
42-
const btn = document.querySelector(buttonId) as HTMLElement;
42+
const btn = document.querySelector("#" + buttonId) as HTMLElement;
4343
if (btn) {
4444
return btn;
4545
}
@@ -121,6 +121,14 @@ const ensureButton = (): void | HTMLElement => {
121121
if (data.type === "data") {
122122
text.innerText += data.v;
123123
term.scrollTop = term.scrollHeight;
124+
} else if (data.type === "error") {
125+
text.innerText += data.v;
126+
term.scrollTop = term.scrollHeight;
127+
setTimeout(() => {
128+
btn.innerText = "Open in Sail";
129+
btn.classList.remove("disabled");
130+
term.remove();
131+
}, 5000);
124132
}
125133
});
126134
}).then((socket) => {
@@ -141,10 +149,8 @@ const ensureButton = (): void | HTMLElement => {
141149

142150
requestSail().then(() => (button as HTMLElement).classList.remove("disabled"))
143151
.catch((ex) => {
144-
if (ex.toString().indexOf("host not found") !== -1) {
145-
(button as HTMLElement).style.opacity = "0.5";
146-
(button as HTMLElement).title = "Setup Sail using the extension icon in the top-right!";
147-
}
152+
(button as HTMLElement).style.opacity = "0.5";
153+
(button as HTMLElement).title = "Setup Sail using the extension icon in the top-right!";
148154
});
149155
}
150156

extension/src/popup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ requestSail().then((url) => {
99
}).catch((ex) => {
1010
const has = (str: string) => ex.toString().indexOf(str) !== -1;
1111

12-
if (has("not found")) {
12+
if (has("not found") || has("forbidden")) {
1313
document.body.innerText = "After installing sail, run `sail install-for-chrome-ext`.";
1414
} else {
1515
document.body.innerText = ex.toString();

globalflags.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func requireRepo(conf config, prefs schemaPrefs, fl *flag.FlagSet) repo {
6767
// there's not currently way for us to figure out the host anyways
6868
r = repo{URL: &url.URL{Path: repoName}}
6969
} else {
70+
r, err = parseRepo(defaultSchema(conf, prefs), conf.DefaultHost, conf.DefaultOrganization, repoURI)
7071
r, err = parseRepo(defaultSchema(conf, prefs), conf.DefaultHost, repoURI)
7172
if err != nil {
7273
flog.Fatal("failed to parse repo %q: %v", repoURI, err)

hat_builder.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import (
1010
"strings"
1111

1212
"github.com/docker/docker/client"
13+
"golang.org/x/xerrors"
14+
1315
"go.coder.com/flog"
1416
"go.coder.com/sail/internal/hat"
1517
"go.coder.com/sail/internal/xexec"
16-
"golang.org/x/xerrors"
1718
)
1819

1920
// hatBuilder is responsible for applying a hat to a base image.
@@ -71,7 +72,10 @@ func (b *hatBuilder) applyHat() (string, error) {
7172
return "", xerrors.Errorf("failed to resolve hat path: %w", err)
7273
}
7374

74-
dockerFilePath := filepath.Join(hatPath, "Dockerfile")
75+
dockerFilePath := hatPath
76+
if base := filepath.Base(hatPath); strings.ToLower(base) != "dockerfile" {
77+
dockerFilePath = filepath.Join(hatPath, "Dockerfile")
78+
}
7579

7680
dockerFileByt, err := ioutil.ReadFile(dockerFilePath)
7781
if err != nil {

images/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,7 @@ extensions or tooling.
5858

5959
`buildpush.sh` - This script takes an image name, i.e. `ubuntu-dev-go1.12`, changes into the specified directory,
6060
and calls `buildlang.sh` and `push.sh` to build the language image and push the finalized image to the codercom
61-
docker hub.
61+
docker hub.
62+
63+
`buildbase.sh` - This script builds both of the base images and is run via `main.sh` or should be run before
64+
doing a `buildpush.sh` for a specific language.

images/buildbase.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
BASE_IMAGE=ubuntu-dev
5+
6+
# Build the base for all images.
7+
pushd base
8+
docker build -t sail-base --label com.coder.sail.base_image=sail-base .
9+
popd
10+
11+
# Build our base ubuntu-dev image for non language specific environments.
12+
pushd $BASE_IMAGE
13+
./buildpush.sh
14+
popd

0 commit comments

Comments
 (0)