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

Commit

Permalink
Rename --code-server-path to --upload-code-server
Browse files Browse the repository at this point in the history
  • Loading branch information
deansheather committed Sep 6, 2019
1 parent 1985f23 commit c8e4017
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type rootCmd struct {
noReuseConnection bool
bindAddr string
sshFlags string
codeServerPath string
uploadCodeServer string
}

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

func (c *rootCmd) Run(fl *pflag.FlagSet) {
Expand All @@ -81,12 +81,12 @@ func (c *rootCmd) Run(fl *pflag.FlagSet) {
}

err := sshCode(host, dir, options{
skipSync: c.skipSync,
sshFlags: c.sshFlags,
bindAddr: c.bindAddr,
syncBack: c.syncBack,
reuseConnection: !c.noReuseConnection,
codeServerPath: c.codeServerPath,
skipSync: c.skipSync,
sshFlags: c.sshFlags,
bindAddr: c.bindAddr,
syncBack: c.syncBack,
reuseConnection: !c.noReuseConnection,
uploadCodeServer: c.uploadCodeServer,
})

if err != nil {
Expand Down
26 changes: 13 additions & 13 deletions sshcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ const (
)

type options struct {
skipSync bool
syncBack bool
noOpen bool
reuseConnection bool
bindAddr string
remotePort string
sshFlags string
codeServerPath string
skipSync bool
syncBack bool
noOpen bool
reuseConnection bool
bindAddr string
remotePort string
sshFlags string
uploadCodeServer string
}

func sshCode(host, dir string, o options) error {
Expand Down Expand Up @@ -78,9 +78,9 @@ func sshCode(host, dir string, o options) error {
}

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

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

Expand Down Expand Up @@ -558,8 +558,8 @@ func ensureDir(path string) error {
return nil
}

// ensureFile tries to stat the specified path and ensure it's a file.
func ensureFile(path string) error {
// validateIsFile tries to stat the specified path and ensure it's a file.
func validateIsFile(path string) error {
info, err := os.Stat(path)
if err != nil {
return err
Expand Down

0 comments on commit c8e4017

Please sign in to comment.