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

Commit c8e4017

Browse files
committed
Rename --code-server-path to --upload-code-server
1 parent 1985f23 commit c8e4017

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
@@ -41,7 +41,7 @@ type rootCmd struct {
4141
noReuseConnection bool
4242
bindAddr string
4343
sshFlags string
44-
codeServerPath string
44+
uploadCodeServer string
4545
}
4646

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

6565
func (c *rootCmd) Run(fl *pflag.FlagSet) {
@@ -81,12 +81,12 @@ func (c *rootCmd) Run(fl *pflag.FlagSet) {
8181
}
8282

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

9292
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)