Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Commit 9f2f843

Browse files
committed
Rename --code-server-path to --upload-code-server
1 parent a6c3b5d commit 9f2f843

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

main.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type rootCmd struct {
4040
noReuseConnection bool
4141
bindAddr string
4242
sshFlags string
43-
codeServerPath string
43+
uploadCodeServer string
4444
}
4545

4646
func (c *rootCmd) Spec() cli.CommandSpec {
@@ -58,7 +58,7 @@ func (c *rootCmd) RegisterFlags(fl *flag.FlagSet) {
5858
fl.BoolVar(&c.noReuseConnection, "no-reuse-connection", false, "do not reuse SSH connection via control socket")
5959
fl.StringVar(&c.bindAddr, "bind", "", "local bind address for SSH tunnel, in [HOST][:PORT] syntax (default: 127.0.0.1)")
6060
fl.StringVar(&c.sshFlags, "ssh-flags", "", "custom SSH flags")
61-
fl.StringVar(&c.codeServerPath, "code-server-path", "", "custom code-server binary to upload")
61+
fl.StringVar(&c.uploadCodeServer, "upload-code-server", "", "custom code-server binary to upload to the remote host")
6262
}
6363

6464
func (c *rootCmd) Run(fl *flag.FlagSet) {
@@ -80,12 +80,12 @@ func (c *rootCmd) Run(fl *flag.FlagSet) {
8080
}
8181

8282
err := sshCode(host, dir, options{
83-
skipSync: c.skipSync,
84-
sshFlags: c.sshFlags,
85-
bindAddr: c.bindAddr,
86-
syncBack: c.syncBack,
87-
reuseConnection: !c.noReuseConnection,
88-
codeServerPath: c.codeServerPath,
83+
skipSync: c.skipSync,
84+
sshFlags: c.sshFlags,
85+
bindAddr: c.bindAddr,
86+
syncBack: c.syncBack,
87+
reuseConnection: !c.noReuseConnection,
88+
uploadCodeServer: c.uploadCodeServer,
8989
})
9090

9191
if err != nil {

sshcode.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ const (
2929
)
3030

3131
type options struct {
32-
skipSync bool
33-
syncBack bool
34-
noOpen bool
35-
reuseConnection bool
36-
bindAddr string
37-
remotePort string
38-
sshFlags string
39-
codeServerPath string
32+
skipSync bool
33+
syncBack bool
34+
noOpen bool
35+
reuseConnection bool
36+
bindAddr string
37+
remotePort string
38+
sshFlags string
39+
uploadCodeServer string
4040
}
4141

4242
func sshCode(host, dir string, o options) error {
@@ -78,9 +78,9 @@ func sshCode(host, dir string, o options) error {
7878
}
7979

8080
// Upload local code-server or download code-server from CI server.
81-
if o.codeServerPath != "" {
81+
if o.uploadCodeServer != "" {
8282
flog.Info("uploading local code-server binary...")
83-
err = copyCodeServerBinary(o.sshFlags, host, o.codeServerPath, codeServerPath)
83+
err = copyCodeServerBinary(o.sshFlags, host, o.uploadCodeServer, codeServerPath)
8484
if err != nil {
8585
return xerrors.Errorf("failed to upload local code-server binary to remote server: %w", err)
8686
}
@@ -428,7 +428,7 @@ func checkSSHMaster(sshMasterCmd *exec.Cmd, sshFlags string, host string) error
428428

429429
// copyCodeServerBinary copies a code-server binary from local to remote.
430430
func copyCodeServerBinary(sshFlags string, host string, localPath string, remotePath string) error {
431-
if err := ensureFile(localPath); err != nil {
431+
if err := validateIsFile(localPath); err != nil {
432432
return err
433433
}
434434

@@ -558,8 +558,8 @@ func ensureDir(path string) error {
558558
return nil
559559
}
560560

561-
// ensureFile tries to stat the specified path and ensure it's a file.
562-
func ensureFile(path string) error {
561+
// validateIsFile tries to stat the specified path and ensure it's a file.
562+
func validateIsFile(path string) error {
563563
info, err := os.Stat(path)
564564
if err != nil {
565565
return err

0 commit comments

Comments
 (0)