fake

package
v0.1.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

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

	// 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 New

func New(networks ...cloud.Network) *Client

New returns a Client preconfigured with the given networks.

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 (c *Client) DeleteAPIServerLoadBalancer(_ context.Context, id string) error

func (*Client) DeleteAPIServerLoadBalancerTarget

func (c *Client) DeleteAPIServerLoadBalancerTarget(_ context.Context, input cloud.LoadBalancerTargetInput) error

func (*Client) DeleteBastion

func (c *Client) DeleteBastion(_ context.Context, input cloud.BastionInput, status cloud.Bastion) error

func (*Client) DeleteNodeSSHAccess

func (c *Client) DeleteNodeSSHAccess(_ context.Context, tags map[string]string) error

func (*Client) DeleteServer

func (c *Client) DeleteServer(_ context.Context, id string) error

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 (c *Client) EnsureAPIServerLoadBalancerTarget(_ context.Context, input cloud.LoadBalancerTargetInput) error

func (*Client) EnsureBastion

func (c *Client) EnsureBastion(_ context.Context, input cloud.BastionInput) (*cloud.Bastion, error)

func (*Client) EnsureNodeSSHAccess

func (c *Client) EnsureNodeSSHAccess(_ context.Context, input cloud.NodeSSHAccessInput) (*cloud.SecurityGroup, error)

func (*Client) FindServerByTags

func (c *Client) FindServerByTags(_ context.Context, tags map[string]string) (*cloud.Server, error)

func (*Client) GetNetwork

func (c *Client) GetNetwork(_ context.Context, id string) (*cloud.Network, error)

func (*Client) GetServer

func (c *Client) GetServer(_ context.Context, id string) (*cloud.Server, error)

func (*Client) ListAPIServerLoadBalancersByTags

func (c *Client) ListAPIServerLoadBalancersByTags(
	_ context.Context,
	tags map[string]string,
) ([]*cloud.LoadBalancer, error)

func (*Client) ListPublicIPsByTags

func (c *Client) ListPublicIPsByTags(_ context.Context, tags map[string]string) ([]*cloud.PublicIP, error)

func (*Client) ListSecurityGroupsByTags

func (c *Client) ListSecurityGroupsByTags(_ context.Context, tags map[string]string) ([]*cloud.SecurityGroup, error)

func (*Client) ListServersByTags

func (c *Client) ListServersByTags(_ context.Context, tags map[string]string) ([]*cloud.Server, error)

func (*Client) LoadBalancerCount

func (c *Client) LoadBalancerCount() int

LoadBalancerCount returns the number of currently tracked load balancers (test helper).

func (*Client) LoadBalancerTargetCount

func (c *Client) LoadBalancerTargetCount(id string) int

LoadBalancerTargetCount returns the number of targets in one load balancer target pool (test helper).

func (*Client) PublicIPCount

func (c *Client) PublicIPCount() int

PublicIPCount returns the number of currently tracked public IPs.

func (*Client) SecurityGroupCount

func (c *Client) SecurityGroupCount() int

SecurityGroupCount returns the number of currently tracked security groups.

func (*Client) SecurityGroupRemoteSources

func (c *Client) SecurityGroupRemoteSources(securityGroupID string) []string

SecurityGroupRemoteSources returns the remote security groups allowed by the fake security group rules.

func (*Client) ServerCount

func (c *Client) ServerCount() int

ServerCount returns the number of currently tracked servers (test helper).

func (*Client) ServerHasSecurityGroup

func (c *Client) ServerHasSecurityGroup(serverID, securityGroupID string) bool

ServerHasSecurityGroup reports whether the server has the security group attached.

func (*Client) ServerUserData

func (c *Client) ServerUserData(serverID string) []byte

ServerUserData returns the user-data stored for a fake server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL