Documentation ¶
Index ¶
- Variables
- func CountAvailable[T AvailabilityMarker](resources []T) int
- func CountOlder(duration time.Duration, accounts []Resource) (int, error)
- func CountToCleanup[T AvailabilityMarker](resources []T) int
- func CountUsed[T AvailabilityMarker](resources []T) int
- func DeletePlacementByServiceUuid(dbpool *pgxpool.Pool, accountProvider AwsAccountProvider, serviceUuid string) error
- func Sort[T Sortable](accounts []T, by string) []T
- func Used[T AvailabilityMarker](resources []T) []T
- type Account
- type AvailabilityMarker
- type AwsAccount
- type AwsAccountProvider
- type AwsAccountWithCreds
- type AwsIamKey
- type Model
- type Placement
- type PlacementWithCreds
- type Placements
- type Resource
- type ResourceWithCreds
- type Sortable
- type Token
- type Tokens
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAccountNotFound = errors.New("account not found")
View Source
var ErrNoEnoughAccountsAvailable = errors.New("no enough accounts available")
Functions ¶
func CountAvailable ¶
func CountAvailable[T AvailabilityMarker](resources []T) int
CountAvailable return the number of resources not in use
func CountOlder ¶
CountOlder returns the number of accounts in use for more than N day
func CountToCleanup ¶
func CountToCleanup[T AvailabilityMarker](resources []T) int
CountToCleanup return the number of accounts to cleanup
func CountUsed ¶
func CountUsed[T AvailabilityMarker](resources []T) int
CountUsed return the number of resources in use
func DeletePlacementByServiceUuid ¶
func DeletePlacementByServiceUuid(dbpool *pgxpool.Pool, accountProvider AwsAccountProvider, serviceUuid string) error
DeletePlacementByServiceUuid deletes a placement by ServiceUuid
Types ¶
type AvailabilityMarker ¶
type AvailabilityMarker interface {
// contains filtered or unexported methods
}
type AwsAccount ¶
type AwsAccount struct { Account Kind string `json:"kind"` // "aws_account" Name string `json:"name"` AccountID string `json:"account_id"` Zone string `json:"zone"` HostedZoneID string `json:"hosted_zone_id"` ConanStatus string `json:"conan_status,omitempty"` ConanTimestamp time.Time `json:"conan_timestamp,omitempty"` ConanHostname string `json:"conan_hostname,omitempty"` }
func (AwsAccount) GetUpdatedAt ¶
func (a AwsAccount) GetUpdatedAt() time.Time
func (AwsAccount) NameInt ¶
func (a AwsAccount) NameInt() int
type AwsAccountProvider ¶
type AwsAccountProvider interface { FetchByName(name string) (AwsAccount, error) FetchAll() ([]AwsAccount, error) FetchAllToCleanup() ([]AwsAccount, error) FetchAllSorted(by string) ([]AwsAccount, error) FetchAllByServiceUuid(serviceUuid string) ([]AwsAccount, error) Request(service_uuid string, count int, annotations map[string]string) ([]AwsAccountWithCreds, error) MarkForCleanup(name string) error MarkForCleanupByServiceUuid(serviceUuid string) error DecryptSecret(encrypted string) (string, error) }
AwsAccountProvider interface to interact with different databases: dynamodb and postgresql
type AwsAccountWithCreds ¶
type AwsAccountWithCreds struct { AwsAccount Credentials []any `json:"credentials"` }
type Placement ¶
type Placement struct { Model ServiceUuid string `json:"service_uuid"` Resources []any `json:"resources,omitempty"` Annotations map[string]string `json:"annotations"` Request any `json:"request"` }
func GetPlacement ¶
GetPlacement returns a placement by ID
func GetPlacementByServiceUuid ¶
GetPlacementByServiceUuid returns a placement by service_uuid
func (*Placement) Delete ¶
func (p *Placement) Delete(dbpool *pgxpool.Pool, accountProvider AwsAccountProvider) error
func (*Placement) LoadResources ¶
func (p *Placement) LoadResources(accountProvider AwsAccountProvider) error
type PlacementWithCreds ¶
type Placements ¶
type Placements []Placement
func GetAllPlacements ¶
func GetAllPlacements(dbpool *pgxpool.Pool) (Placements, error)
func (Placements) Render ¶
func (p Placements) Render(w http.ResponseWriter, r *http.Request) error
type ResourceWithCreds ¶
Click to show internal directories.
Click to hide internal directories.