Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultGetHostname() (string, error)
- func DefaultGetUserHomeDir() (string, error)
- func DefaultGetUsername() (string, error)
- func DirectoryExists(dirname string) bool
- func FileExists(filename string) bool
- func GCSCopy(gcsSource string, localDest string) (string, error)
- func GCSFileExists(gcsPath string) (string, error)
- type DeviceConfig
- type FuchsiaDevice
- type GCSImage
- type SDKProperties
- func (sdk SDKProperties) GetAvailableImages(version string, bucket string) ([]GCSImage, error)
- func (sdk SDKProperties) GetDefaultDevice(deviceName string) (DeviceConfig, error)
- func (sdk SDKProperties) GetDeviceConfiguration(name string) (DeviceConfig, error)
- func (sdk SDKProperties) GetDeviceConfigurations() ([]DeviceConfig, error)
- func (sdk SDKProperties) GetFuchsiaProperty(device string, property string) (string, error)
- func (sdk SDKProperties) GetPackageSourcePath(version string, bucket string, image string) string
- func (sdk SDKProperties) GetSDKDataPath() string
- func (sdk SDKProperties) GetSDKVersion() string
- func (sdk SDKProperties) GetToolsDir() (string, error)
- func (sdk SDKProperties) GetValidPropertyNames() []string
- func (sdk SDKProperties) IsValidProperty(property string) bool
- func (sdk SDKProperties) RemoveDeviceConfiguration(deviceName string) error
- func (sdk SDKProperties) ResolveTargetAddress(deviceIP string, deviceName string) (DeviceConfig, error)
- func (sdk SDKProperties) RunFFX(args []string, interactive bool) (string, error)
- func (sdk SDKProperties) RunFFXDoctor() (string, error)
- func (sdk SDKProperties) RunSFTPCommand(targetAddress string, customSSHConfig string, privateKey string, ...) error
- func (sdk SDKProperties) RunSSHCommand(targetAddress string, customSSHConfig string, privateKey string, ...) (string, error)
- func (sdk SDKProperties) RunSSHShell(targetAddress string, customSSHConfig string, privateKey string, ...) error
- func (sdk SDKProperties) SaveDeviceConfiguration(newConfig DeviceConfig) error
- func (sdk SDKProperties) SetDeviceIP(deviceIP, sshPort string) error
Constants ¶
const ( DeviceNameKey string = "device-name" BucketKey string = "bucket" ImageKey string = "image" DeviceIPKey string = "device-ip" SSHPortKey string = "ssh-port" PackageRepoKey string = "package-repo" PackagePortKey string = "package-port" DefaultKey string = "default" FFXIsolatedEnvKey = "FFX_ISOLATED_CONFIG" )
Property keys used to get and set device configuration
const (
DefaultSSHPort string = "22"
)
Variables ¶
var ( // ExecCommand exports exec.Command as a variable so it can be mocked. ExecCommand = exec.Command // ExecLookPath exported to support mocking. ExecLookPath = exec.LookPath )
var GetHostname = DefaultGetHostname
GetHostname to allow mocking.
var GetUserHomeDir = DefaultGetUserHomeDir
GetUserHomeDir to allow mocking.
var GetUsername = DefaultGetUsername
GetUsername to allow mocking.
Functions ¶
func DefaultGetHostname ¶
DefaultGetHostname is the default implementation of GetHostname() to allow mocking of user.Current()
func DefaultGetUserHomeDir ¶
DefaultGetUserHomeDir is the default implementation of GetUserHomeDir() to allow mocking of user.Current()
func DefaultGetUsername ¶
DefaultGetUsername is the default implementation of GetUsername() to allow mocking of user.Current()
func DirectoryExists ¶
DirectoryExists returns true if dirname exists.
func GCSFileExists ¶
Types ¶
type DeviceConfig ¶
type DeviceConfig struct { DeviceName string `json:"device-name"` Bucket string `json:"bucket"` Image string `json:"image"` DeviceIP string `json:"device-ip"` SSHPort string `json:"ssh-port"` PackageRepo string `json:"package-repo"` PackagePort string `json:"package-port"` IsDefault bool `json:"default"` Discoverable bool `json:"discoverable"` }
DeviceConfig holds all the properties that are configured for a given device.
type FuchsiaDevice ¶
type FuchsiaDevice struct { // SSH address of the Fuchsia device. SSHAddr string // Nodename of the Fuchsia device. Name string }
FuchsiaDevice represent a Fuchsia device.
func (*FuchsiaDevice) String ¶
func (f *FuchsiaDevice) String() string
type SDKProperties ¶
type SDKProperties struct {
// contains filtered or unexported fields
}
SDKProperties holds the common data for SDK tools. These values should be set or initialized by calling New().
func New ¶
func New() (SDKProperties, error)
New creates an initialized SDKProperties using the default location for the data directory.
func NewWithDataPath ¶
func NewWithDataPath(dataPath string) (SDKProperties, error)
func (SDKProperties) GetAvailableImages ¶
func (sdk SDKProperties) GetAvailableImages(version string, bucket string) ([]GCSImage, error)
GetAvailableImages returns the images available for the given version and bucket. If bucket is not the default bucket, the images in the default bucket are also returned.
func (SDKProperties) GetDefaultDevice ¶
func (sdk SDKProperties) GetDefaultDevice(deviceName string) (DeviceConfig, error)
GetDefaultDevice gets the default device to use by default.
func (SDKProperties) GetDeviceConfiguration ¶
func (sdk SDKProperties) GetDeviceConfiguration(name string) (DeviceConfig, error)
GetDeviceConfiguration returns the configuration for the device with the given name.
func (SDKProperties) GetDeviceConfigurations ¶
func (sdk SDKProperties) GetDeviceConfigurations() ([]DeviceConfig, error)
GetDeviceConfigurations returns a list of all device configurations.
func (SDKProperties) GetFuchsiaProperty ¶
func (sdk SDKProperties) GetFuchsiaProperty(device string, property string) (string, error)
GetFuchsiaProperty returns the value for the given property for the given device. If the device name is empty, the default device is used via GetDefaultDevice(). It is an error if the property cannot be found.
func (SDKProperties) GetPackageSourcePath ¶
func (sdk SDKProperties) GetPackageSourcePath(version string, bucket string, image string) string
GetPackageSourcePath returns the GCS path for the given values.
func (SDKProperties) GetSDKDataPath ¶
func (sdk SDKProperties) GetSDKDataPath() string
GetSDKDataPath returns the path to the directory for storing SDK related data,
or empty if not set.
Use sdkcommon.New() to create an initialized SDKProperties struct.
func (SDKProperties) GetSDKVersion ¶
func (sdk SDKProperties) GetSDKVersion() string
GetSDKVersion returns the version of the SDK or empty if not set. Use sdkcommon.New() to create an initialized SDKProperties struct.
func (SDKProperties) GetToolsDir ¶
func (sdk SDKProperties) GetToolsDir() (string, error)
GetToolsDir returns the path to the SDK tools for the current CPU architecture. This is implemented by default of getting the directory of the currently exeecuting binary.
func (SDKProperties) GetValidPropertyNames ¶
func (sdk SDKProperties) GetValidPropertyNames() []string
GetValidPropertyNames returns the list of valid properties for a device configuration.
func (SDKProperties) IsValidProperty ¶
func (sdk SDKProperties) IsValidProperty(property string) bool
IsValidProperty returns true if the property is a valid property name.
func (SDKProperties) RemoveDeviceConfiguration ¶
func (sdk SDKProperties) RemoveDeviceConfiguration(deviceName string) error
RemoveDeviceConfiguration removes the device settings for the given name.
func (SDKProperties) ResolveTargetAddress ¶
func (sdk SDKProperties) ResolveTargetAddress(deviceIP string, deviceName string) (DeviceConfig, error)
ResolveTargetAddress evaluates the deviceIP and deviceName passed in to determine the target IP address. This include consulting the configuration information set via `fconfig`.
func (SDKProperties) RunFFX ¶
func (sdk SDKProperties) RunFFX(args []string, interactive bool) (string, error)
RunFFX executes ffx with the given args, returning stdout. If there is an error, the error will usually be of type *ExitError.
func (SDKProperties) RunFFXDoctor ¶
func (sdk SDKProperties) RunFFXDoctor() (string, error)
RunFFXDoctor runs common checks for the ffx tool and host environment and returns the stdout.
func (SDKProperties) RunSFTPCommand ¶
func (sdk SDKProperties) RunSFTPCommand(targetAddress string, customSSHConfig string, privateKey string, sshPort string, toTarget bool, src string, dst string) error
RunSFTPCommand runs sftp (one of SSH's file copy tools). Setting toTarget to true will copy file SRC from host to DST on the target. Otherwise it will copy file from SRC from target to DST on the host. sshPort if non-empty will use this port to connect to the device. The return value is the error if any.
func (SDKProperties) RunSSHCommand ¶
func (sdk SDKProperties) RunSSHCommand(targetAddress string, customSSHConfig string, privateKey string, sshPort string, verbose bool, args []string) (string, error)
RunSSHCommand runs the command provided in args on the given target device. The customSSHconfig is optional and overrides the SSH configuration defined by the SDK. privateKey is optional to specify a private key to use to access the device. verbose adds the -v flag to ssh. sshPort if non-empty is used as the custom ssh port on the commandline. The return value is the stdout.
func (SDKProperties) RunSSHShell ¶
func (sdk SDKProperties) RunSSHShell(targetAddress string, customSSHConfig string, privateKey string, sshPort string, verbose bool, args []string) error
RunSSHShell runs the command provided in args on the given target device and uses the system stdin, stdout, stderr. Returns when the ssh process exits. The customSSHconfig is optional and overrides the SSH configuration defined by the SDK. privateKey is optional to specify a private key to use to access the device. sshPort if non-empty is used as the custom ssh port on the commandline. verbose adds the -v flag to ssh. The return value is the stdout.
func (SDKProperties) SaveDeviceConfiguration ¶
func (sdk SDKProperties) SaveDeviceConfiguration(newConfig DeviceConfig) error
SaveDeviceConfiguration persists the given device configuration properties.
func (SDKProperties) SetDeviceIP ¶
func (sdk SDKProperties) SetDeviceIP(deviceIP, sshPort string) error
SetDeviceIP manually adds a target via `ffx target add`.