executing test command
This commit is contained in:
parent
a3e1ca6b2b
commit
659c9de867
3
main.go
3
main.go
@ -10,6 +10,9 @@ func main() {
|
||||
config := initializeConfig("config.yaml")
|
||||
sshConn, sshConfig := initializeConnection(config)
|
||||
clientConns := sshConn.dialConnection(sshConfig)
|
||||
fmt.Println(clientConns)
|
||||
clientSessions := sshConn.openSession(clientConns)
|
||||
fmt.Println(clientSessions)
|
||||
success := sshConn.executeTarFile(clientSessions)
|
||||
fmt.Println(success)
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello from the remote side!")
|
||||
}
|
5
remote/ssh_remote.go
Normal file
5
remote/ssh_remote.go
Normal file
@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
// this file is to ssh back to the master machine to send back the tarball
|
||||
// still planning this piece out. stay tuned for more!
|
||||
// handsomely, Wyatt J. Miller, the guy who doesn't know what socket is headed where
|
@ -0,0 +1 @@
|
||||
package main
|
26
ssh.go
26
ssh.go
@ -21,8 +21,15 @@ type SSHConnection struct {
|
||||
|
||||
type SSHCleints []*ssh.Client
|
||||
|
||||
// TODO: I've got two slices of the same type. To take one slice out, some refactoring is needed
|
||||
type SSHSessions []*ssh.Session
|
||||
|
||||
type SSHTarFile []*ssh.Session
|
||||
|
||||
type SSHPush []*ssh.Client
|
||||
|
||||
type SSHSuccess []error
|
||||
|
||||
func initializeConnection(config Configuration) (SSHConnection, *ssh.ClientConfig) {
|
||||
var sshConn SSHConnection
|
||||
sshConn.Username = config.Username
|
||||
@ -63,7 +70,6 @@ func (s SSHConnection) dialConnection(sshConfig *ssh.ClientConfig) SSHCleints {
|
||||
}
|
||||
|
||||
func (s SSHConnection) openSession(client SSHCleints) SSHSessions {
|
||||
// don't forget there's a return type here
|
||||
clientSessions := SSHSessions{}
|
||||
|
||||
for _, j := range client {
|
||||
@ -78,3 +84,21 @@ func (s SSHConnection) openSession(client SSHCleints) SSHSessions {
|
||||
|
||||
return clientSessions
|
||||
}
|
||||
|
||||
func (s SSHConnection) executeTarFile(execute SSHSessions) SSHSuccess {
|
||||
// execute order 66 lol
|
||||
success := SSHSuccess{}
|
||||
|
||||
for _, j := range execute {
|
||||
// this is just a placeholder, change to the actual tarring executable
|
||||
err := j.Run("echo 'hello world'! > test.txt")
|
||||
|
||||
if err != nil {
|
||||
fmt.Errorf("Can't execute program", err)
|
||||
}
|
||||
|
||||
success = append(success, err)
|
||||
}
|
||||
|
||||
return success
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user