-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upload local disk images (#15)
The new options/flag enables users to use a local file as the image, instead of a publicly available file from a web server.
- Loading branch information
Showing
3 changed files
with
63 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
package sshsession | ||
|
||
import "golang.org/x/crypto/ssh" | ||
import ( | ||
"io" | ||
|
||
func Run(client *ssh.Client, cmd string) ([]byte, error) { | ||
"golang.org/x/crypto/ssh" | ||
) | ||
|
||
func Run(client *ssh.Client, cmd string, stdin io.Reader) ([]byte, error) { | ||
sess, err := client.NewSession() | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
defer sess.Close() | ||
|
||
if stdin != nil { | ||
sess.Stdin = stdin | ||
} | ||
return sess.CombinedOutput(cmd) | ||
} |