utils

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupPostgres

func CleanupPostgres(_ *testing.T)

func CleanupSqlite

func CleanupSqlite(t *testing.T)

func CreateDefaultOrgAndTenant added in v1.7.0

func CreateDefaultOrgAndTenant(t *testing.T, ctx context.Context)

CreateDefaultOrgAndTenant creates the default org/tenant, or loads them if a prior test run against the same (persistent) database already created them.

func CreateHost

func CreateHost(t *testing.T, ctx context.Context, name string) *schema.Host

func CreateIPv4Network

func CreateIPv4Network(t *testing.T, ctx context.Context, name string) *schema.Network

func CreateIPv6Network

func CreateIPv6Network(t *testing.T, ctx context.Context, name string) *schema.Network

func CreateIPv10Network

func CreateIPv10Network(t *testing.T, ctx context.Context, name string) *schema.Network

func CreateTag

func CreateTag(t *testing.T, ctx context.Context, tagID, network string) *models.Tag

func DeleteHost

func DeleteHost(t *testing.T, ctx context.Context, host *schema.Host)

func DeleteNetwork

func DeleteNetwork(t *testing.T, ctx context.Context, network *schema.Network)

func DeleteNode

func DeleteNode(t *testing.T, ctx context.Context, node *schema.Node)

func DeleteTag

func DeleteTag(t *testing.T, ctx context.Context, tag *models.Tag)

func InitPostgres

func InitPostgres(t *testing.T)

func InitSqlite

func InitSqlite(t *testing.T)

func RandomIPInCIDR

func RandomIPInCIDR(network *net.IPNet) (net.IP, error)

RandomIPInCIDR returns a random host address within the given network. It works for both IPv4 and IPv6 CIDRs.

For IPv4 /31 and /32 (and IPv6 /127, /128) all addresses are returned as-is without filtering network/broadcast addresses, which is consistent with modern point-to-point link behaviour (RFC 3021).

func RandomPrivateCIDRv4

func RandomPrivateCIDRv4(prefixLen int) (*net.IPNet, error)

RandomPrivateCIDRv4 returns a random prefix within the RFC 6598 shared address space 100.64.0.0/10, with given prefix length.

func RandomPrivateCIDRv6

func RandomPrivateCIDRv6(prefixLen int) (*net.IPNet, error)

RandomPrivateCIDRv6 returns a random prefix within the RFC 4193 unique-local range fd00::/8 (the locally-assigned half of fc00::/7), with given prefix length.

func RandomPublicIPv4

func RandomPublicIPv4() (net.IP, error)

RandomPublicIPv4 returns a random, globally-routable IPv4 address. It rejects any address that falls in a reserved/private range.

func RandomPublicIPv6

func RandomPublicIPv6() (net.IP, error)

RandomPublicIPv6 returns a random, globally-routable IPv6 address. It rejects any address that falls in a reserved/private range.

Types

This section is empty.

Jump to

Keyboard shortcuts

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