mirror of
https://github.com/apricote/hcloud-upload-image.git
synced 2026-01-13 21:31:03 +00:00
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.
This commit is contained in:
parent
8e070f04ab
commit
fcea3e3c6e
3 changed files with 63 additions and 24 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue