-
Notifications
You must be signed in to change notification settings - Fork 101
Open
Description
/kind feature
Currently, the ssh client used by caph does not use the Context.
This means, when the ctx times out, the ssh client does not notice that.
Current code:
type Factory interface {
NewClient(Input) Client
}
type Input struct {
IP string
PrivateKey string
Port int
}We could add Context to Input.
Using the ctx is not straight forward, because the ssh package was created before context was added to Go.
But it is not difficult either:
- create conn with
net.Dialer.DialContext(ctx, ...) - pass that conn into
ssh.NewClientConn(...) - in a goroutine:
select { case <-ctx.Done(): conn.Close() }
Additional benefit: We could get the logger from the context.
Alternative:
Currently:
type Client interface {
GetHostName() Output
GetHardwareDetailsRAM() Output
GetHardwareDetailsNics() Output
...We add the ctx to each function of the interface:
type Client interface {
GetHostName(ctx context.Context) Output
...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels