Documentation
¶
Overview ¶
Package vpcinfo provides APIs to extract VPC information from DNS resolvers.
The library abstract parsing and caching of VPC information resolved from TXT records, as configured by the terraform modules in this repository.
Index ¶
Constants ¶
const ( // DefaultDomain is the default domain used when initializing the default // resolver. DefaultDomain = "vpcinfo.local" )
Variables ¶
var DefaultRegistry = &Registry{ Resolver: ResolverWithDomain(DefaultDomain, net.DefaultResolver), Timeout: 2 * time.Second, TTL: 1 * time.Minute, }
DefaultRegistry is the default registry used by top-level functions of this package.
Functions ¶
This section is empty.
Types ¶
type Platform ¶ added in v0.1.4
type Platform interface { // Returns the name of the platform. String() string // Returns the zone that the program is running in. LookupZone(context.Context) (Zone, error) }
Platform is an interface representing the VPC platform that the program is running.
func LookupPlatform ¶ added in v0.1.3
LookupPlatform returns the name of the VPC platform.
type Registry ¶
type Registry struct { // The resolver used by this registry. // // If nil, net.DefaultResolver is used instead. Resolver Resolver // Time limit for blocking operations ran by this registry. // // Zero means to apply no limit. Timeout time.Duration // Limits how long cached entries are retained before attempting to refresh // them from the resolver. // // Defaults to 1 minute. TTL time.Duration // contains filtered or unexported fields }
Registry exposes VPC information to the program.
Registry values are intended to be long-lived, they cache the results they observe from the resolver.
Registry values are safe to use concurrently from multiple goroutines.
func (*Registry) LookupPlatform ¶ added in v0.1.3
LookupPlatform returns the name of the VPC platform, which will be either "aws" or "unknown".
func (*Registry) LookupSubnets ¶
LookupSubnets returns the list of subnets in the VPC.
Multiple calls to this method may return the same Subnets value, programs should treat it as a read-only value and avoid modifying it to prevent race conditions.
type Resolver ¶
Resolver is the interface implemented by *net.Resolver, or other resolvers used to lookup VPC information.
func ResolverWithDomain ¶
ResolverWithDomain wraps the resolver passed as argument to append the given domain to all name lookups.
type Subnet ¶
type Subnet struct { ID string `name:"subnet"` Zone string `name:"zone"` CIDR *net.IPNet `name:"cidr"` }
Subnet values represent subnets.
type Subnets ¶
type Subnets []Subnet
Subnets is a slice type which represents a list of subnets.
func LookupSubnets ¶
LookupSubnets returns the list of subnets in the VPC.
func (Subnets) Format ¶ added in v0.1.9
Format writes subnets to w using the formatting verb v.
The following formats are supported:
s formats a human-readable summary of the subnets v formats the subnet list as a slice of strings
func (Subnets) LookupAddr ¶ added in v0.1.2
LookupAddr returns the subnet that addr belongs to.
type Zone ¶ added in v0.1.4
type Zone string
Zone is a string type representing infrastructure zones.
func LookupZone ¶ added in v0.1.3
LookupZone returns the name of the current VPC zone.