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:
Julian Tölle 2024-05-09 18:16:37 +02:00 committed by GitHub
parent 8e070f04ab
commit fcea3e3c6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 63 additions and 24 deletions

View file

@ -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)
}