Documentation
¶
Overview ¶
Package fake provides an in-memory cloud.Client used by unit and envtest tests. It supports failure injection so callers can exercise error paths.
Index ¶
- type Client
- func (c *Client) CreateServer(_ context.Context, input cloud.CreateServerInput) (*cloud.Server, error)
- func (c *Client) DeleteAPIServerLoadBalancer(_ context.Context, id string) error
- func (c *Client) DeleteAPIServerLoadBalancerTarget(_ context.Context, input cloud.LoadBalancerTargetInput) error
- func (c *Client) DeleteBastion(_ context.Context, input cloud.BastionInput, status cloud.Bastion) error
- func (c *Client) DeleteNodeSSHAccess(_ context.Context, tags map[string]string) error
- func (c *Client) DeleteServer(_ context.Context, id string) error
- func (c *Client) EnsureAPIServerLoadBalancer(_ context.Context, input cloud.LoadBalancerInput) (*cloud.LoadBalancer, error)
- func (c *Client) EnsureAPIServerLoadBalancerTarget(_ context.Context, input cloud.LoadBalancerTargetInput) error
- func (c *Client) EnsureBastion(_ context.Context, input cloud.BastionInput) (*cloud.Bastion, error)
- func (c *Client) EnsureNodeSSHAccess(_ context.Context, input cloud.NodeSSHAccessInput) (*cloud.SecurityGroup, error)
- func (c *Client) FindServerByTags(_ context.Context, tags map[string]string) (*cloud.Server, error)
- func (c *Client) GetNetwork(_ context.Context, id string) (*cloud.Network, error)
- func (c *Client) GetServer(_ context.Context, id string) (*cloud.Server, error)
- func (c *Client) ListAPIServerLoadBalancersByTags(_ context.Context, tags map[string]string) ([]*cloud.LoadBalancer, error)
- func (c *Client) ListPublicIPsByTags(_ context.Context, tags map[string]string) ([]*cloud.PublicIP, error)
- func (c *Client) ListSecurityGroupsByTags(_ context.Context, tags map[string]string) ([]*cloud.SecurityGroup, error)
- func (c *Client) ListServersByTags(_ context.Context, tags map[string]string) ([]*cloud.Server, error)
- func (c *Client) LoadBalancerCount() int
- func (c *Client) LoadBalancerTargetCount(id string) int
- func (c *Client) PublicIPCount() int
- func (c *Client) SecurityGroupCount() int
- func (c *Client) SecurityGroupRemoteSources(securityGroupID string) []string
- func (c *Client) ServerCount() int
- func (c *Client) ServerHasSecurityGroup(serverID, securityGroupID string) bool
- func (c *Client) ServerUserData(serverID string) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// failure injection: if non-nil, the next call returns this error and the
// field is cleared.
FailNextCreateServer error
FailNextDeleteServer error
FailNextGetServer error
FailNextFindServer error
FailNextEnsureLB error
FailNextDeleteLB error
FailNextEnsureTarget error
FailNextDeleteTarget error
FailNextGetNetwork error
FailNextEnsureBastion error
FailNextDeleteBastion error
FailNextEnsureNodeSSH error
FailNextDeleteNodeSSH error
// Before* hooks, if non-nil, run before the call they belong to. They let a
// test observe API server state at the exact moment a cloud call would
// happen. Unlike FailNext*, they are not consumed.
BeforeCreateServer func()
BeforeGetNetwork func()
// CreateServerCalls counts successful CreateServer calls (for idempotency
// assertions).
CreateServerCalls int
EnsureBastionCalls int
EnsureNodeSSHCalls int
// contains filtered or unexported fields
}
Client is an in-memory implementation of cloud.Client.
func (*Client) CreateServer ¶
func (c *Client) CreateServer(_ context.Context, input cloud.CreateServerInput) (*cloud.Server, error)
CreateServer creates a server. To satisfy spec section 20 (idempotency), it returns the existing server if one with matching tags already exists.
func (*Client) DeleteAPIServerLoadBalancer ¶
func (*Client) DeleteAPIServerLoadBalancerTarget ¶
func (*Client) DeleteBastion ¶
func (*Client) DeleteNodeSSHAccess ¶
func (*Client) DeleteServer ¶
DeleteServer removes a server. It returns nil if the server is already gone.
func (*Client) EnsureAPIServerLoadBalancer ¶
func (c *Client) EnsureAPIServerLoadBalancer( _ context.Context, input cloud.LoadBalancerInput, ) (*cloud.LoadBalancer, error)
func (*Client) EnsureAPIServerLoadBalancerTarget ¶
func (*Client) EnsureBastion ¶
func (*Client) EnsureNodeSSHAccess ¶
func (c *Client) EnsureNodeSSHAccess(_ context.Context, input cloud.NodeSSHAccessInput) (*cloud.SecurityGroup, error)
func (*Client) FindServerByTags ¶
func (*Client) GetNetwork ¶
func (*Client) ListAPIServerLoadBalancersByTags ¶
func (*Client) ListPublicIPsByTags ¶
func (*Client) ListSecurityGroupsByTags ¶
func (*Client) ListServersByTags ¶
func (*Client) LoadBalancerCount ¶
LoadBalancerCount returns the number of currently tracked load balancers (test helper).
func (*Client) LoadBalancerTargetCount ¶
LoadBalancerTargetCount returns the number of targets in one load balancer target pool (test helper).
func (*Client) PublicIPCount ¶
PublicIPCount returns the number of currently tracked public IPs.
func (*Client) SecurityGroupCount ¶
SecurityGroupCount returns the number of currently tracked security groups.
func (*Client) SecurityGroupRemoteSources ¶
SecurityGroupRemoteSources returns the remote security groups allowed by the fake security group rules.
func (*Client) ServerCount ¶
ServerCount returns the number of currently tracked servers (test helper).
func (*Client) ServerHasSecurityGroup ¶
ServerHasSecurityGroup reports whether the server has the security group attached.
func (*Client) ServerUserData ¶
ServerUserData returns the user-data stored for a fake server.