db

package
v0.0.0-...-c3677c5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllBranchENIsByAccountRegion

func GetAllBranchENIsByAccountRegion(ctx context.Context, tx *sql.Tx, accountID, region string) ([]string, error)

func GetAndLockAssignmentByID

func GetAndLockAssignmentByID(ctx context.Context, tx *sql.Tx, id int) (*data.Assignment, error)

Get the assignment and lock

func GetAndLockAssignmentByTaskID

func GetAndLockAssignmentByTaskID(ctx context.Context, tx *sql.Tx, taskID string) (*data.Assignment, bool, error)

Returns (Assignment, completed, error) and lock the assignment row until the

func GetAssignedStaticIPAddressByTaskID

func GetAssignedStaticIPAddressByTaskID(ctx context.Context, tx *sql.Tx, taskID string) (*data.StaticIPAddress, error)

Given a task ID, get the static IP assigned to the task

func GetAvailableElasticAddressByAllocationIDsAndLock

func GetAvailableElasticAddressByAllocationIDsAndLock(
	ctx context.Context,
	tx *sql.Tx,
	accountID string,
	borderGroup string,
	allocationIDs []string) (*api.ElasticAddress, error)

Get one available elastic IP from the given allocationID list Also lock the IP until the end of given transaction.

func GetAvailableElasticAddressByGroupAndLock

func GetAvailableElasticAddressByGroupAndLock(
	ctx context.Context,
	tx *sql.Tx,
	accountID string,
	borderGroup string,
	groupName string) (*api.ElasticAddress, error)

Get one available elastic IP from the given group Also lock the IP until the end of given transaction.

func GetBorderGroupByAzAndAccount

func GetBorderGroupByAzAndAccount(
	ctx context.Context,
	tx *sql.Tx,
	az string,
	accountID string) (string, error)

func GetBranchENI

func GetBranchENI(ctx context.Context, tx *sql.Tx, branchENI string) (*api.NetworkInterface, error)

func GetCIDRBySubnet

func GetCIDRBySubnet(ctx context.Context, tx *sql.Tx, subnetID string) (net.IP, *net.IPNet, error)

func GetClassIDByAssignmentID

func GetClassIDByAssignmentID(ctx context.Context, tx *sql.Tx, assignmentID int) (uint32, error)

func GetElasticAddressByTaskID

func GetElasticAddressByTaskID(ctx context.Context, tx *sql.Tx, taskID string) (*api.ElasticAddress, error)

func GetElasticIPAttachmentByTaskID

func GetElasticIPAttachmentByTaskID(ctx context.Context, tx *sql.Tx, taskID string) (*data.ElasticIPAttachment, error)

func GetLeastUsedSubnet

func GetLeastUsedSubnet(ctx context.Context, tx *sql.Tx, az, accountID string, subnetIDs []string) (*data.Subnet, error)

Get the least used subnet (i.e. subnet with the least number of IPs) in the given subnetIDs. If the given subnetIDs is empty, then get the least used subnet by the given accountID

func GetOldestAvailableIPv4

func GetOldestAvailableIPv4(ctx context.Context, tx *sql.Tx, ips []string, vpcID string) (string, error)

For the given list of IPs, find an available one with the oldest last_seen value

func GetSecurityGroupsAndLockBranchENI

func GetSecurityGroupsAndLockBranchENI(ctx context.Context, tx *sql.Tx, branchENI string) ([]string, error)

Get security groups of the given branch ENI and lock the row

func GetStaticAllocationByID

func GetStaticAllocationByID(ctx context.Context, tx *sql.Tx, id string) (*data.StaticAllocation, error)

func GetStaticAllocationByIDAndLock

func GetStaticAllocationByIDAndLock(ctx context.Context, tx *sql.Tx, id string) (*data.StaticAllocation, error)

Get the static allocation by ID and lock the row until the end of the given transaction

func GetStaticIPv4Addresses

func GetStaticIPv4Addresses(
	ctx context.Context,
	tx *sql.Tx, ips []string, subnetID string) ([]string, error)

For the given IPv4 addresses, find those are static IPs and return

func GetTrunkENI

func GetTrunkENI(ctx context.Context, tx *sql.Tx, trunkENI string) (*api.NetworkInterface, error)

func GetUnassignedBranchENI

func GetUnassignedBranchENI(ctx context.Context, tx *sql.Tx, subnet, trunkENI string, random bool) (*data.BranchENI, error)

Get one branch ENI that is not assigned to any container random: If true, select a random unassigned branch ENI. Otherwise, select the oldest one.

func GetUsedIPv4AddressesByENIAssociation

func GetUsedIPv4AddressesByENIAssociation(
	ctx context.Context,
	tx *sql.Tx,
	branchENIAssociationID string) (sets.String, error)

Get all IPv4 addresses of the given ENI assocation that are already assigned to continers.

func GetVpcIDAndBranchENIByAssociationID

func GetVpcIDAndBranchENIByAssociationID(ctx context.Context, tx *sql.Tx, associationID string) (string, string, error)

Returns (vpcID, branchENI, error)

func Migrate

func Migrate(ctx context.Context, db *sql.DB) error

func MigrateTo

func MigrateTo(ctx context.Context, db *sql.DB, to uint, check bool) error

func NeedsMigration

func NeedsMigration(ctx context.Context, db *sql.DB) (bool, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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