Documentation ¶
Overview ¶
Package landscapemockservice implements a mock Landscape service DO NOT USE IN PRODUCTION
Index ¶
- type HostInfo
- type InstanceInfo
- type Option
- type Service
- func (s *Service) Connect(stream landscapeapi.LandscapeHostAgent_ConnectServer) (err error)
- func (s *Service) Disconnect(uid string) error
- func (s *Service) Hosts() (hosts map[string]HostInfo)
- func (s *Service) IsConnected(uid string) bool
- func (s *Service) MessageLog() (log []HostInfo)
- func (s *Service) SendCommand(ctx context.Context, uid string, command *landscapeapi.Command) error
- func (s *Service) WaitDisconnection(uid string) <-chan struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HostInfo ¶
type HostInfo struct { UID string Hostname string Token string AccountName string RegistrationKey string Instances []InstanceInfo DefaultInstanceID string }
HostInfo is the same as landscapeapi.HostAgentInfo, but without the mutexes and all grpc implementation details (so it can be safely copied).
type InstanceInfo ¶
type InstanceInfo struct { ID string Name string VersionID string InstanceState landscapeapi.InstanceState }
InstanceInfo is the same as landscapeapi.InstanceInfo, but without the mutexes and all grpc implementation details (so it can be safely copied).
type Option ¶
type Option func(*opts)
Option is an optional argument for New.
func WithLogger ¶
WithLogger overrides the default logger for the Landscape mock service.
type Service ¶
type Service struct { landscapeapi.UnimplementedLandscapeHostAgentServer // contains filtered or unexported fields }
Service is a minimalistic server for the landscape API.
func (*Service) Connect ¶
func (s *Service) Connect(stream landscapeapi.LandscapeHostAgent_ConnectServer) (err error)
Connect implements the Connect API call. Upon first contact ever, a UID is randombly assigned to the host and sent to it. In subsequent contacts, this UID will be its unique identifier.
func (*Service) Disconnect ¶
Disconnect kills the connection with the host assigned to the specified UID.
func (*Service) Hosts ¶
Hosts returns a map of all hosts that have had a UID assigned in the past, and their most recently received data.
func (*Service) IsConnected ¶
IsConnected checks if a client with the specified hostname has an active connection.
func (*Service) MessageLog ¶
MessageLog allows looking into the history of messages received by the server.
func (*Service) SendCommand ¶
SendCommand instructs the server to send a command to the target machine with matching hostname.
func (*Service) WaitDisconnection ¶
WaitDisconnection returns a channel that will be closed when the connection with the host assigned to the specified UID is terminated.
If the UID is not registered, the second return value will be false.