Documentation
¶
Index ¶
- Constants
- Variables
- func Must[T any](result T, err error) T
- func NewRateLimiter(burst uint32, rechargePeriod time.Duration, startFull bool, ...) *rateLimiter
- func NewVault() (*vaultProxy, error)
- func PrependShellScriptToUserData(originalUserData, script string) (string, error)
- func RetryOnTransientError(ctx context.Context, logger hclog.Logger, ...) error
- func Sleep(ctx context.Context, duration time.Duration) error
- func Unarg[S any, T any](f func(context.Context, S, *godo.ListOptions) ([]T, *godo.Response, error), ...) func(context.Context, *godo.ListOptions) ([]T, *godo.Response, error)
- func Unpaginate[T any](ctx context.Context, ...) iter.Seq2[T, error]
- func WithClient(reservedIPs ReservedIPs, reservedIPActions ReservedIPActions, ...) reservedAddressesPoolOption
- func WithClock(c quartz.Clock) reservedAddressesPoolOption
- func WithDigitalOceanWrapper(wrapper DigitalOceanWrapper) reservedAddressesPoolOption
- func WithMockClock(m *quartz.Mock) rateLimiterOption
- func WithRateLimiterOption(o rateLimiterOption) reservedAddressesPoolOption
- type CloudConfigArchive
- type CloudConfigPart
- type DigitalOceanWrapper
- type DropletActions
- type DropletIDs
- type Droplets
- type GodoWrapper
- func (g *GodoWrapper) DropletActions() DropletActions
- func (g *GodoWrapper) Droplets() Droplets
- func (g *GodoWrapper) ReservedIPActions() ReservedIPActions
- func (g *GodoWrapper) ReservedIPV6Actions() ReservedIPV6Actions
- func (g *GodoWrapper) ReservedIPV6s() ReservedIPV6s
- func (g *GodoWrapper) ReservedIPs() ReservedIPs
- func (g *GodoWrapper) Tags() Tags
- type PrereservedIP
- type PrereservedIPV6
- type ReservedAddressesPool
- func (r *ReservedAddressesPool) AssignIPv4(ctx context.Context, dropletID int, ipv4 string) error
- func (r *ReservedAddressesPool) AssignIPv6(ctx context.Context, dropletID int, ipv6 string) error
- func (r *ReservedAddressesPool) PrereserveIPV6s(ctx context.Context, count int, region string, createIfRequired bool, ...) ([]string, error)
- func (r *ReservedAddressesPool) PrereserveIPs(ctx context.Context, count int, region string, createIfRequired bool, ...) ([]string, error)
- type ReservedIPActions
- type ReservedIPV6Actions
- type ReservedIPV6s
- type ReservedIPs
- type Tags
- type TargetPlugin
- type VaultProxy
Constants ¶
const ( // the LRU reduces the number of times the nomad server is queried to get detailed // information on each nomad client (which is required to identify the associated // droplet ID). In rare cases a droplet could become orphaned despite having registered // as a nomad client earlier. In such cases it won't be detected until the LRU evicts it. DropletMappingLRUSize = 1024 DropletMappingLRUExpiry = 6 * time.Hour )
Variables ¶
var ( PluginConfig = &plugins.InternalPluginConfig{ Factory: func(l hclog.Logger) interface{} { return NewDODropletsPlugin(context.Background(), l, Must(NewVault())) }, } )
Functions ¶
func Must ¶ added in v0.0.5
Must panics if it is given a non-nil error. Otherwise, it returns the first argument
func NewRateLimiter ¶ added in v0.0.5
func PrependShellScriptToUserData ¶ added in v0.0.5
PrependShellScriptToUserData will prepend a cloud-boothook section to the existing user data, which may be empty, a bare shell command, or using the cloud-config-archive format
func RetryOnTransientError ¶ added in v0.0.6
func RetryOnTransientError( ctx context.Context, logger hclog.Logger, f func(ctx context.Context, cancel context.CancelCauseFunc) error, extraCodes ...int, ) error
RetryOnTransientError will retry the provided callable if the error is one which is likely to indicate a transient error, which might just require some time to resolve. godo already handles rate-limiting, but HTTP 422s have been observed when trying to do things like conccurently assign multiple reserved IP addresses. If an unrecognise error is returned, this will exit as normal, immediately.
func Unarg ¶ added in v0.0.26
func Unarg[S any, T any](f func(context.Context, S, *godo.ListOptions) ([]T, *godo.Response, error), arg S) func(context.Context, *godo.ListOptions) ([]T, *godo.Response, error)
Unarg is passed a godo List* function which takes an argument prior to the ListOptions, along with the argument's value. It allows the Unpaginate generic function to be used. e.g.: Unpaginate(ctx, Unarg(dropletsService.ListByTag, template.name), godo.ListOptions{})
func Unpaginate ¶ added in v0.0.24
func Unpaginate[T any](ctx context.Context, f func(ctx context.Context, opt *godo.ListOptions) ([]T, *godo.Response, error), opt godo.ListOptions) iter.Seq2[T, error]
Unpaginate repeatedly calls a paginated List* function, returning an iterable of the returned object type.
func WithClient ¶ added in v0.0.5
func WithClient( reservedIPs ReservedIPs, reservedIPActions ReservedIPActions, reservedIPV6s ReservedIPV6s, reservedIPV6Actions ReservedIPV6Actions, ) reservedAddressesPoolOption
func WithDigitalOceanWrapper ¶ added in v0.0.5
func WithDigitalOceanWrapper(wrapper DigitalOceanWrapper) reservedAddressesPoolOption
func WithMockClock ¶ added in v0.0.5
func WithRateLimiterOption ¶ added in v0.0.5
func WithRateLimiterOption(o rateLimiterOption) reservedAddressesPoolOption
Types ¶
type CloudConfigArchive ¶ added in v0.0.16
type CloudConfigArchive struct {
Parts []CloudConfigPart `json:"cloud-config-archive"`
}
func NewCloudConfigArchive ¶ added in v0.0.16
func NewCloudConfigArchive(parts ...CloudConfigPart) *CloudConfigArchive
func ParseCloudConfigArchive ¶ added in v0.0.16
func ParseCloudConfigArchive(data string) (*CloudConfigArchive, error)
func (*CloudConfigArchive) String ¶ added in v0.0.16
func (c *CloudConfigArchive) String() string
type CloudConfigPart ¶ added in v0.0.16
type DigitalOceanWrapper ¶ added in v0.0.5
type DigitalOceanWrapper interface { ReservedIPs() ReservedIPs ReservedIPV6s() ReservedIPV6s ReservedIPActions() ReservedIPActions ReservedIPV6Actions() ReservedIPV6Actions Droplets() Droplets DropletActions() DropletActions Tags() Tags }
type DropletActions ¶ added in v0.0.5
type DropletIDs ¶ added in v0.0.26
type DropletIDs map[int]struct{}
type Droplets ¶ added in v0.0.5
type Droplets interface { ListByTag(context.Context, string, *godo.ListOptions) ([]godo.Droplet, *godo.Response, error) Create(context.Context, *godo.DropletCreateRequest) (*godo.Droplet, *godo.Response, error) Get(context.Context, int) (*godo.Droplet, *godo.Response, error) Delete(context.Context, int) (*godo.Response, error) }
type GodoWrapper ¶ added in v0.0.5
func (*GodoWrapper) DropletActions ¶ added in v0.0.5
func (g *GodoWrapper) DropletActions() DropletActions
func (*GodoWrapper) Droplets ¶ added in v0.0.5
func (g *GodoWrapper) Droplets() Droplets
func (*GodoWrapper) ReservedIPActions ¶ added in v0.0.5
func (g *GodoWrapper) ReservedIPActions() ReservedIPActions
func (*GodoWrapper) ReservedIPV6Actions ¶ added in v0.0.5
func (g *GodoWrapper) ReservedIPV6Actions() ReservedIPV6Actions
func (*GodoWrapper) ReservedIPV6s ¶ added in v0.0.5
func (g *GodoWrapper) ReservedIPV6s() ReservedIPV6s
func (*GodoWrapper) ReservedIPs ¶ added in v0.0.5
func (g *GodoWrapper) ReservedIPs() ReservedIPs
func (*GodoWrapper) Tags ¶ added in v0.0.5
func (g *GodoWrapper) Tags() Tags
type PrereservedIP ¶ added in v0.0.5
type PrereservedIP struct {
// contains filtered or unexported fields
}
func (*PrereservedIP) String ¶ added in v0.0.5
func (p *PrereservedIP) String() string
type PrereservedIPV6 ¶ added in v0.0.5
type PrereservedIPV6 struct {
// contains filtered or unexported fields
}
type ReservedAddressesPool ¶ added in v0.0.5
type ReservedAddressesPool struct {
// contains filtered or unexported fields
}
func CreateReservedAddressesPool ¶ added in v0.0.5
func CreateReservedAddressesPool( logger hclog.Logger, options ...reservedAddressesPoolOption, ) *ReservedAddressesPool
func (*ReservedAddressesPool) AssignIPv4 ¶ added in v0.0.5
func (*ReservedAddressesPool) AssignIPv6 ¶ added in v0.0.5
func (*ReservedAddressesPool) PrereserveIPV6s ¶ added in v0.0.5
func (r *ReservedAddressesPool) PrereserveIPV6s( ctx context.Context, count int, region string, createIfRequired bool, expiry time.Duration, ) ([]string, error)
PrereserveIPV6s will find and return the specified number of reserved IP addresses. They will be provisionally reserved, meaning subsequent calls to this function will not return the same addresses until the expiry period has elapsed
func (*ReservedAddressesPool) PrereserveIPs ¶ added in v0.0.5
func (r *ReservedAddressesPool) PrereserveIPs( ctx context.Context, count int, region string, createIfRequired bool, expiry time.Duration, ) ([]string, error)
PrereserveIPs will find and return the specified number of reserved IP addresses. They will be provisionally reserved, meaning subsequent calls to this function will not return the same addresses until the expiry period has elapsed
type ReservedIPActions ¶ added in v0.0.5
type ReservedIPV6Actions ¶ added in v0.0.5
type ReservedIPV6s ¶ added in v0.0.5
type ReservedIPV6s interface { List(context.Context, *godo.ListOptions) ([]godo.ReservedIPV6, *godo.Response, error) Create( context.Context, *godo.ReservedIPV6CreateRequest, ) (*godo.ReservedIPV6, *godo.Response, error) }
type ReservedIPs ¶ added in v0.0.5
type ReservedIPs interface { List(context.Context, *godo.ListOptions) ([]godo.ReservedIP, *godo.Response, error) Create( context.Context, *godo.ReservedIPCreateRequest, ) (*godo.ReservedIP, *godo.Response, error) }
type Tags ¶ added in v0.0.5
type Tags interface { UntagResources(context.Context, string, *godo.UntagResourcesRequest) (*godo.Response, error) TagResources(context.Context, string, *godo.TagResourcesRequest) (*godo.Response, error) Create(context.Context, *godo.TagCreateRequest) (*godo.Tag, *godo.Response, error) List(context.Context, *godo.ListOptions) ([]godo.Tag, *godo.Response, error) Delete(context.Context, string) (*godo.Response, error) }
type TargetPlugin ¶
type TargetPlugin struct {
// contains filtered or unexported fields
}
TargetPlugin is the DigitalOcean implementation of the target.Target interface.
func NewDODropletsPlugin ¶
func NewDODropletsPlugin(ctx context.Context, log hclog.Logger, vault VaultProxy) *TargetPlugin
NewDODropletsPlugin returns the DO Droplets implementation of the target.Target interface.
func (*TargetPlugin) PluginInfo ¶
func (t *TargetPlugin) PluginInfo() (*base.PluginInfo, error)
PluginInfo satisfies the PluginInfo function on the base.Base interface.
func (*TargetPlugin) Scale ¶
func (t *TargetPlugin) Scale(action sdk.ScalingAction, config map[string]string) error
Scale satisfies the Scale function on the target.Target interface.
func (*TargetPlugin) SetConfig ¶
func (t *TargetPlugin) SetConfig(config map[string]string) error
SetConfig satisfies the SetConfig function on the base.Base interface.
func (*TargetPlugin) Status ¶
func (t *TargetPlugin) Status(config map[string]string) (*sdk.TargetStatus, error)
Status satisfies the Status function on the target.Target interface.
type VaultProxy ¶ added in v0.0.5
type VaultProxy interface { // GenerateSecretId creates a new vault secretID for the approle which can only be accessed from the specified IP addresses. // Returns the wrapping token to be used to retrieve the SecretID GenerateSecretId( ctx context.Context, appRole string, allowedIPv4, allowedIPv6 string, secretValidity, wrapperValidity time.Duration, ) (string, error) }