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) FindDeviceByIP(ipAddr string) (*FuchsiaDevice, error)
- func (sdk SDKProperties) FindDeviceByName(deviceName string) (*FuchsiaDevice, error)
- func (sdk SDKProperties) GetAddressByName(deviceName string) (string, error)
- func (sdk SDKProperties) GetAvailableImages(version string, bucket string) ([]GCSImage, error)
- func (sdk SDKProperties) GetDefaultDeviceName() (string, 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) ListDevices() ([]*FuchsiaDevice, error)
- func (sdk SDKProperties) RemoveDeviceConfiguration(deviceName string) error
- func (sdk SDKProperties) ResolveTargetAddress(deviceIP string, deviceName string) (string, error)
- func (sdk SDKProperties) RunSSHCommand(targetAddress string, customSSHConfig string, privateKey string, verbose bool, ...) (string, error)
- func (sdk SDKProperties) RunSSHShell(targetAddress string, customSSHConfig string, privateKey string, verbose bool, ...) error
- func (sdk SDKProperties) SaveDeviceConfiguration(newConfig DeviceConfig) 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" )
Property keys used to get and set device configuration
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 implmentation of GetHostname() to allow mocking of user.Current()
func DefaultGetUserHomeDir ¶
DefaultGetUserHomeDir is the default implmentation of GetUserHomeDir() to allow mocking of user.Current()
func DefaultGetUsername ¶
DefaultGetUsername is the default implmentation 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"` }
DeviceConfig holds all the properties that are configured for a given devce.
type FuchsiaDevice ¶
type FuchsiaDevice struct { // IPv4 or IPv6 of the Fuchsia device. IpAddr 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 (sdk *SDKProperties) Init().
func (SDKProperties) FindDeviceByIP ¶
func (sdk SDKProperties) FindDeviceByIP(ipAddr string) (*FuchsiaDevice, error)
FindDeviceByIP returns a fuchsia device matching a specific ip address.
func (SDKProperties) FindDeviceByName ¶
func (sdk SDKProperties) FindDeviceByName(deviceName string) (*FuchsiaDevice, error)
FindDeviceByName returns a fuchsia device matching a specific device name.
func (SDKProperties) GetAddressByName ¶
func (sdk SDKProperties) GetAddressByName(deviceName string) (string, error)
GetAddressByName returns the IPv6 address of the device.
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) GetDefaultDeviceName ¶
func (sdk SDKProperties) GetDefaultDeviceName() (string, error)
GetDefaultDeviceName returns the name of the target 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 GetDefaultDeviceName(). 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 initalized 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 initalized 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) ListDevices ¶
func (sdk SDKProperties) ListDevices() ([]*FuchsiaDevice, error)
ListDevices returns all available fuchsia devices.
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) (string, error)
ResolveTargetAddress evaulates the deviceIP and deviceName passed in to determine the target IP address. This include consulting the configuration information set via `fconfig`.
func (SDKProperties) RunSSHCommand ¶
func (sdk SDKProperties) RunSSHCommand(targetAddress string, customSSHConfig string, privateKey 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. The return value is the stdout.
func (SDKProperties) RunSSHShell ¶
func (sdk SDKProperties) RunSSHShell(targetAddress string, customSSHConfig string, privateKey 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. 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.