Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecInterface ¶
type ExecInterface interface {
Command(env []string, stdout io.Writer, stderr io.Writer, stdin io.Reader, name string, arg ...string) ShellCommand
}
ExecInterface is an interface for running shell commands in the OS
type HookExecOpts ¶
type HookExecutor ¶
type HookExecutor interface {
Execute(ctx context.Context, opts HookExecOpts) (response string, err error)
}
func GetHookExecutor ¶
func GetHookExecutor(ios iostreams.IOStreamer, cfg SDKCLIConfig) HookExecutor
type HookExecutorDefaultProtocol ¶
type HookExecutorDefaultProtocol struct {
IO iostreams.IOStreamer
}
HookExecutorDefaultProtocol uses the original protocol between the CLI and the SDK where diagnostic info and hook responses come in via stdout. Data outside the expected JSON payload is ignored, with the exception of the 'start' hook, for which it is printed.
func (*HookExecutorDefaultProtocol) Execute ¶
func (e *HookExecutorDefaultProtocol) Execute(ctx context.Context, opts HookExecOpts) (string, error)
Execute processes the data received by the SDK.
type HookExecutorMessageBoundaryProtocol ¶
type HookExecutorMessageBoundaryProtocol struct {
IO iostreams.IOStreamer
}
HookExecutorMessageBoundaryProtocol uses a protocol between the CLI and the SDK where diagnostic info and hook responses come in via stdout, and hook responses are wrapped in a string denoting the message boundary. Only one message payload can be received.
func (*HookExecutorMessageBoundaryProtocol) Execute ¶
func (e *HookExecutorMessageBoundaryProtocol) Execute(ctx context.Context, opts HookExecOpts) (string, error)
Execute processes the data received by the SDK.
type HookScript ¶
HookScript maps to specific hook commands listed out in hooks.json
func (HookScript) Get ¶
func (s HookScript) Get() (string, error)
Get checks if the hook command has been initialised and returns the command string
func (HookScript) IsAvailable ¶
func (s HookScript) IsAvailable() bool
IsAvailable returns true when the HookScript.Command exists
func (*HookScript) UnmarshalJSON ¶
func (s *HookScript) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaller interface so that HookScript objects can decode themselves.
The Name field should be dynamically overwritten at SDK Config initialization time.
Read more: https://pkg.go.dev/encoding/json#Unmarshaler
type MockCommand ¶
type MockCommand struct {
MockStdout []byte
MockStderr []byte
Err error
Env []string
Args map[string]string
StdoutIO io.ReadCloser
StderrIO io.ReadCloser
// contains filtered or unexported fields
}
func (*MockCommand) CombinedOutput ¶
func (c *MockCommand) CombinedOutput() ([]byte, error)
func (*MockCommand) Run ¶
func (c *MockCommand) Run() error
func (*MockCommand) Start ¶
func (c *MockCommand) Start() error
func (*MockCommand) StderrPipe ¶
func (c *MockCommand) StderrPipe() (io.ReadCloser, error)
func (*MockCommand) StdoutPipe ¶
func (c *MockCommand) StdoutPipe() (io.ReadCloser, error)
func (*MockCommand) Wait ¶
func (c *MockCommand) Wait() error
type MockExec ¶
type MockExec struct {
// contains filtered or unexported fields
}
Mock that implements ExecInterface for testing
type MockHookExecutor ¶
func (*MockHookExecutor) Execute ¶
func (m *MockHookExecutor) Execute(ctx context.Context, opts HookExecOpts) (string, error)
type ProtocolVersions ¶
type ProtocolVersions []Protocol
func (ProtocolVersions) Preferred ¶
func (pv ProtocolVersions) Preferred() Protocol
Preferred returns the first valid protocol present in the SDK config. Lower indices in the array of protocols received from the SDK config are interpreted as more recent or preferred protocol versions.
type SDKCLIConfig ¶
type SDKCLIConfig struct {
Runtime string `json:"runtime,omitempty"` // Optional, runtime version e.g. deno, deno1.x
Hooks struct {
BuildProject HookScript `json:"build,omitempty"`
CheckUpdate HookScript `json:"check-update,omitempty"`
Deploy HookScript `json:"deploy,omitempty"`
Doctor HookScript `json:"doctor,omitempty"`
GetHooks HookScript `json:"get-hooks,omitempty"`
GetManifest HookScript `json:"get-manifest,omitempty"`
GetTrigger HookScript `json:"get-trigger,omitempty"`
InstallUpdate HookScript `json:"install-update,omitempty"`
Start HookScript `json:"start,omitempty"`
} `json:"hooks,omitempty"`
Config struct {
Watch WatchOpts `json:"watch,omitempty"`
SDKManagedConnection bool `json:"sdk-managed-connection-enabled,omitempty"`
TriggerPaths []string `json:"trigger-paths,omitempty"`
SupportedProtocols ProtocolVersions `json:"protocol-version,omitempty"`
} `json:"config,omitempty"`
WorkingDirectory string
}
SDKCLIConfig contains configuration for communication between the CLI and the SDK. It is set by merging the app's local hooks.json and the response from the `get-hooks` hook.
func NewSDKConfigMock ¶
func NewSDKConfigMock() SDKCLIConfig
NewSDKConfigMock returns a mock of the SDKCLIConfig struct
func (*SDKCLIConfig) Exists ¶
func (s *SDKCLIConfig) Exists() (bool, error)
Exists returns true when the SDKCLIConfig was successfully loaded, otherwise false with an error