vm_port_repo

package
v0.0.0-...-e71a76f Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPortNotFound is returned when a port is not found.
	ErrPortNotFound = errors.New("port not found")
	// ErrNoPortsAvailable is returned when no ports are available.
	// This is likely due to the port range being full.
	ErrNoPortsAvailable = errors.New("port not found")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Collection *mongo.Collection

	base_clients.ResourceClient[model.VmPort]
}

Client is the client for VM ports.

func New

func New() *Client

New creates a new VM port client.

func (*Client) CreateIfNotExists

func (client *Client) CreateIfNotExists(publicPortStart, publicPortEnd int, zone string) (int, error)

CreateIfNotExists creates the given port range if it does not already exist.

func (*Client) Erase

func (client *Client) Erase(publicPort int, zone string) error

Erase erases a port. This removes the port from the database entirely.

func (*Client) ExcludePortRange

func (client *Client) ExcludePortRange(start, end int) *Client

ExcludePortRange adds a filter to the client to exclude VM ports in the given range.

func (*Client) GetOrLeaseAny

func (client *Client) GetOrLeaseAny(privatePort int, vmID, zone string) (*model.VmPort, error)

GetOrLeaseAny gets a port that is not leased, or leases a port for the given VM.

func (*Client) IncludePortRange

func (client *Client) IncludePortRange(start, end int) *Client

IncludePortRange adds a filter to the client to only return VM ports in the given range.

func (*Client) Lease

func (client *Client) Lease(publicPort, privatePort int, vmID, zone string) (*model.VmPort, error)

Lease leases a port for the given VM.

func (*Client) ReleaseAll

func (client *Client) ReleaseAll(vmID string) error

ReleaseAll releases all ports leased by the given VM.

func (*Client) WithPagination

func (client *Client) WithPagination(page, pageSize int) *Client

WithPagination sets the pagination for the client.

func (*Client) WithVmID

func (client *Client) WithVmID(vmID string) *Client

WithVmID adds a filter to the client to only return VM ports for the given VM.

func (*Client) WithZone

func (client *Client) WithZone(zone string) *Client

WithZone adds a filter to the client to only return VM ports in the given zone.

Jump to

Keyboard shortcuts

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