Skip to content

Commit 93c3e4b

Browse files
committed
small auto feedback
1 parent 9805fb9 commit 93c3e4b

3 files changed

Lines changed: 13 additions & 16 deletions

File tree

pkg/cmd/copy/copy.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func runCopyCommand(t *terminal.Terminal, cstore CopyStore, source, dest string,
8585
return copyExternalNode(t, cstore, target.Node, localPath, remotePath, isUpload)
8686
}
8787

88-
workspace, err := prepareWorkspace(t, cstore, workspaceNameOrID)
88+
workspace, err := prepareWorkspace(t, cstore, target.Workspace)
8989
if err != nil {
9090
return breverrors.WrapAndTrace(err)
9191
}
@@ -126,26 +126,22 @@ func parseCopyArguments(source, dest string) (workspaceNameOrID, remotePath, loc
126126
return destWorkspace, destPath, source, true, nil
127127
}
128128

129-
func prepareWorkspace(t *terminal.Terminal, cstore CopyStore, workspaceNameOrID string) (*entity.Workspace, error) {
129+
func prepareWorkspace(t *terminal.Terminal, cstore CopyStore, workspace *entity.Workspace) (*entity.Workspace, error) {
130130
s := t.NewSpinner()
131-
workspace, err := util.GetUserWorkspaceByNameOrIDErr(cstore, workspaceNameOrID)
132-
if err != nil {
133-
return nil, breverrors.WrapAndTrace(err)
134-
}
135131

136132
if workspace.Status == "STOPPED" {
137-
err = startWorkspaceIfStopped(t, s, cstore, workspaceNameOrID, workspace)
133+
err := startWorkspaceIfStopped(t, s, cstore, workspace.Name, workspace)
138134
if err != nil {
139135
return nil, breverrors.WrapAndTrace(err)
140136
}
141137
}
142138

143-
err = pollUntil(s, workspace.ID, "RUNNING", cstore, " waiting for instance to be ready...")
139+
err := pollUntil(s, workspace.ID, "RUNNING", cstore, " waiting for instance to be ready...")
144140
if err != nil {
145141
return nil, breverrors.WrapAndTrace(err)
146142
}
147143

148-
workspace, err = util.GetUserWorkspaceByNameOrIDErr(cstore, workspaceNameOrID)
144+
workspace, err = util.GetUserWorkspaceByNameOrIDErr(cstore, workspace.Name)
149145
if err != nil {
150146
return nil, breverrors.WrapAndTrace(err)
151147
}

pkg/cmd/portforward/portforward.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,8 @@ func portForwardExternalNode(t *terminal.Terminal, pfStore PortforwardStore, res
151151
return breverrors.WrapAndTrace(err)
152152
}
153153

154-
// The SSH tunnel forwards local traffic through the SSH connection to the
155-
// actual port on the box. Ctrl+C stops the local forward but not the
156-
// remote port binding.
154+
// The SSH tunnel forwards local traffic through the SSH connection to the actual port on the box.
155+
// TODO there isn't support for killing the port forward in either case, and no ClosePort for external node
157156
alias := info.SSHAlias()
158157
t.Vprintf("Setting up local forward: localhost:%s -> %s:%s\n", localPort, alias, remotePort)
159158
_, err = RunSSHPortForward("-L", localPort, remotePort, alias)

pkg/cmd/util/externalnode.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ type ExternalNodeStore interface {
2222
GetCurrentUser() (*entity.User, error)
2323
}
2424

25+
type WorkspaceOrNodeResolver interface {
26+
GetWorkspaceByNameOrIDErrStore
27+
ExternalNodeStore
28+
}
29+
2530
// WorkspaceOrNode is returned by ResolveWorkspaceOrNode. Exactly one field is non-nil.
2631
type WorkspaceOrNode struct {
2732
Workspace *entity.Workspace
@@ -30,10 +35,7 @@ type WorkspaceOrNode struct {
3035

3136
// ResolveWorkspaceOrNode looks up a workspace first; if not found, falls back to external nodes.
3237
// The store must satisfy both GetWorkspaceByNameOrIDErrStore and ExternalNodeStore.
33-
func ResolveWorkspaceOrNode(store interface {
34-
GetWorkspaceByNameOrIDErrStore
35-
ExternalNodeStore
36-
}, nameOrID string,
38+
func ResolveWorkspaceOrNode(store WorkspaceOrNodeResolver, nameOrID string,
3739
) (*WorkspaceOrNode, error) {
3840
workspace, wsErr := GetUserWorkspaceByNameOrIDErr(store, nameOrID)
3941
if wsErr == nil {

0 commit comments

Comments
 (0)