target

package module
v0.0.0-...-6e72573 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package target provides a way to interact with local and remote systems.

  • Copyright (C) 2023 Intel Corporation
  • SPDX-License-Identifier: MIT

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunLocalCommand

func RunLocalCommand(cmd *exec.Cmd) (stdout string, stderr string, exitCode int, err error)

func RunLocalCommandWithInput

func RunLocalCommandWithInput(cmd *exec.Cmd, input string) (stdout string, stderr string, exitCode int, err error)

func RunLocalCommandWithInputWithTimeout

func RunLocalCommandWithInputWithTimeout(cmd *exec.Cmd, input string, timeout int) (stdout string, stderr string, exitCode int, err error)

func RunLocalCommandWithTimeout

func RunLocalCommandWithTimeout(cmd *exec.Cmd, timeout int) (stdout string, stderr string, exitCode int, err error)

Types

type LocalTarget

type LocalTarget struct {
	// contains filtered or unexported fields
}

func NewLocalTarget

func NewLocalTarget(host string, sudo string) *LocalTarget

func (*LocalTarget) CanConnect

func (t *LocalTarget) CanConnect() bool

func (*LocalTarget) CanElevatePrivileges

func (t *LocalTarget) CanElevatePrivileges() bool

func (*LocalTarget) CreateDirectory

func (t *LocalTarget) CreateDirectory(baseDir string, targetDir string) (dir string, err error)

func (*LocalTarget) CreateTempDirectory

func (t *LocalTarget) CreateTempDirectory(rootDir string) (tempDir string, err error)

CreateTempDirectory creates a temporary directory on the local target in the directory specified by rootDir. If rootDir is an empty string, the temporary directory will be created in the system's default directory for temporary files, e.g. /tmp. The full path to the temporary directory is returned.

func (*LocalTarget) GetArchitecture

func (t *LocalTarget) GetArchitecture() (arch string, err error)

func (*LocalTarget) GetName

func (t *LocalTarget) GetName() (host string)

func (*LocalTarget) GetSudo

func (t *LocalTarget) GetSudo() (sudo string)

func (*LocalTarget) PullFile

func (t *LocalTarget) PullFile(srcPath string, dstDir string) (err error)

func (*LocalTarget) PushFile

func (t *LocalTarget) PushFile(srcPath string, dstPath string) (err error)

PushFile copies file from src to dst

srcPath: full path to source file
dstPath: destination directory or full path to destination file

func (*LocalTarget) RemoveDirectory

func (t *LocalTarget) RemoveDirectory(targetDir string) (err error)

func (*LocalTarget) RunCommand

func (t *LocalTarget) RunCommand(cmd *exec.Cmd) (stdout string, stderr string, exitCode int, err error)

func (*LocalTarget) RunCommandWithTimeout

func (t *LocalTarget) RunCommandWithTimeout(cmd *exec.Cmd, timeout int) (stdout string, stderr string, exitCode int, err error)

func (*LocalTarget) SetSudo

func (t *LocalTarget) SetSudo(sudo string)

type RemoteTarget

type RemoteTarget struct {
	// contains filtered or unexported fields
}

func NewRemoteTarget

func NewRemoteTarget(name string, host string, port string, user string, key string, pass string, sshpassPath string, sudo string) *RemoteTarget

func (*RemoteTarget) CanConnect

func (t *RemoteTarget) CanConnect() bool

func (*RemoteTarget) CreateDirectory

func (t *RemoteTarget) CreateDirectory(baseDir string, targetDir string) (dir string, err error)

func (*RemoteTarget) CreateTempDirectory

func (t *RemoteTarget) CreateTempDirectory(rootDir string) (tempDir string, err error)

CreateTempDirectory creates a temporary directory on the remote target in the directory specified by rootDir. If rootDir is an empty string, the temporary directory will be created in the system's default directory for temporary files, e.g. /tmp. The full path to the temporary directory is returned.

func (*RemoteTarget) GetArchitecture

func (t *RemoteTarget) GetArchitecture() (arch string, err error)

func (*RemoteTarget) GetName

func (t *RemoteTarget) GetName() (host string)

func (*RemoteTarget) GetSudo

func (t *RemoteTarget) GetSudo() (sudo string)

func (*RemoteTarget) PullFile

func (t *RemoteTarget) PullFile(srcPath string, dstDir string) (err error)

func (*RemoteTarget) PushFile

func (t *RemoteTarget) PushFile(srcPath string, dstDir string) (err error)

func (*RemoteTarget) RemoveDirectory

func (t *RemoteTarget) RemoveDirectory(targetDir string) (err error)

func (*RemoteTarget) RunCommand

func (t *RemoteTarget) RunCommand(cmd *exec.Cmd) (stdout string, stderr string, exitCode int, err error)

func (*RemoteTarget) RunCommandWithTimeout

func (t *RemoteTarget) RunCommandWithTimeout(cmd *exec.Cmd, timeout int) (stdout string, stderr string, exitCode int, err error)

func (*RemoteTarget) SetSudo

func (t *RemoteTarget) SetSudo(sudo string)

type Target

type Target interface {
	RunCommand(*exec.Cmd) (string, string, int, error)
	RunCommandWithTimeout(*exec.Cmd, int) (string, string, int, error)
	CreateTempDirectory(string) (string, error)
	GetArchitecture() (string, error)
	PushFile(string, string) error
	PullFile(string, string) error
	CreateDirectory(string, string) (string, error)
	RemoveDirectory(string) error
	GetName() string
	CanConnect() bool
	GetSudo() string
	SetSudo(string)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL