Documentation
¶
Index ¶
- type AppWatchOpts
- type ExecInterface
- type HookExecOpts
- type HookExecutor
- type HookExecutorDefaultProtocol
- type HookExecutorMessageBoundaryProtocol
- type HookScript
- type ManifestWatchOpts
- type MockCommand
- func (c *MockCommand) CombinedOutput() ([]byte, error)
- func (c *MockCommand) GetProcess() *os.Process
- func (c *MockCommand) Run() error
- func (c *MockCommand) Start() error
- func (c *MockCommand) StderrPipe() (io.ReadCloser, error)
- func (c *MockCommand) StdoutPipe() (io.ReadCloser, error)
- func (c *MockCommand) Wait() error
- type MockExec
- type MockHookExecutor
- type Protocol
- type ProtocolVersions
- type SDKCLIConfig
- type ShellCommand
- type ShellExec
- type WatchOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppWatchOpts ¶
type AppWatchOpts struct {
FilterRegex string `json:"filter-regex,omitempty"`
Paths []string `json:"paths,omitempty"`
}
AppWatchOpts configures watching for app/code changes for server restart
func (AppWatchOpts) String ¶
func (a AppWatchOpts) String() string
String formats AppWatchOpts for debug outputs
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 HookExecOpts struct {
Directory string
Hook HookScript
Args map[string]string
Env map[string]string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Exec ExecInterface
}
func (HookExecOpts) ShellEnv ¶
func (opts HookExecOpts) ShellEnv(ctx context.Context, fs afero.Fs, io iostreams.IOStreamer) []string
ShellEnv builds the environment variables for a hook command.
type HookExecutor ¶
type HookExecutor interface {
Execute(ctx context.Context, opts HookExecOpts) (response string, err error)
}
func GetHookExecutor ¶
func GetHookExecutor(ios iostreams.IOStreamer, fs afero.Fs, cfg SDKCLIConfig) HookExecutor
type HookExecutorDefaultProtocol ¶
type HookExecutorDefaultProtocol struct {
IO iostreams.IOStreamer
Fs afero.Fs
}
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
Fs afero.Fs
}
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 ManifestWatchOpts ¶
type ManifestWatchOpts struct {
FilterRegex string `json:"filter-regex,omitempty"`
Paths []string `json:"paths,omitempty"`
}
ManifestWatchOpts configures watching for manifest changes for reinstall
func (ManifestWatchOpts) String ¶
func (m ManifestWatchOpts) String() string
String formats ManifestWatchOpts for debug outputs
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) GetProcess ¶
func (c *MockCommand) GetProcess() *os.Process
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
type ShellCommand ¶
type WatchOpts ¶
type WatchOpts struct {
Manifest *ManifestWatchOpts `json:"manifest,omitempty"`
App *AppWatchOpts `json:"app,omitempty"`
FilterRegex string `json:"filter-regex,omitempty"` // Legacy for manifest watching
Paths []string `json:"paths,omitempty"` // Legacy for manifest watching
}
WatchOpts contains details of file watcher configurations
func (*WatchOpts) GetAppWatchConfig ¶
GetAppWatchConfig returns app watch config
func (*WatchOpts) GetManifestWatchConfig ¶
GetManifestWatchConfig returns manifest watch config
func (*WatchOpts) IsAvailable ¶
IsAvailable returns if watch options exist