fleet

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fleet is the CLI's client of the manager's IAM-authorized API: the lookup of the API by name, the SigV4-signed calls, and what the routers and workloads commands build on them. The estimate never imports it (importguard_test.go).

Index

Constants

This section is empty.

Variables

View Source
var CandidateStatuses = []string{"pending-onboarding", "pending-offboarding", "managed", "ineligible", "dismissed", "excluded", "out-of-scope", "gone"}

CandidateStatuses are the statuses a candidate has, in the order the dashboard shows them.

View Source
var ErrNoAPI = errors.New("no manager API found")

ErrNoAPI is the lookup's answer when no API has the manager's name in the region.

View Source
var ErrNotSent = errors.New("not started")

ErrNotSent marks an error from before the request left: the credentials or the signature failed, nothing reached the manager.

View Source
var Permissions = []string{"read", "wake", "nap"}

Permissions are what a grant gives on the workloads its tags match.

View Source
var Roles = []string{"member", "viewer", "operator", "admin"}

Roles are the built-in roles a user holds.

Functions

func Age added in v0.6.0

func Age(at string, now time.Time) string

Age is the time from the RFC 3339 instant to now, in its largest whole unit; "—" when unknown.

func AuditTable added in v0.6.0

func AuditTable(entries []AuditEntry, loc *time.Location) string

AuditTable is the entries as a table in the order given: time (in loc), who and target (ARNs shortened), action and result. "no audit entries" when there are none.

func CheckDescription added in v0.6.0

func CheckDescription(s string) error

CheckDescription refuses a group description over 200 characters.

func CheckGroupName added in v0.6.0

func CheckGroupName(s string) error

CheckGroupName refuses a name the manager would not accept for a new group.

func CheckRole added in v0.6.0

func CheckRole(s string) error

CheckRole refuses what is not a built-in role.

func DaysText added in v0.6.0

func DaysText(days []string) string

DaysText writes days in week order, three or more in a row as a range: mon–fri, sat,sun.

func DiscountsText added in v0.6.0

func DiscountsText(d Discounts) string

DiscountsText is the discounts in a few words: compute 10%, databases 0%.

func ExclusionsText added in v0.6.0

func ExclusionsText(es []Exclusion, loc *time.Location) string

ExclusionsText is the exclusions as a table: target, reason, who, until, the workloads it paused (by name) and its state; times in loc. "no exclusions" when there are none.

func GetOperation added in v0.6.0

func GetOperation(c *Client) func(context.Context, string) (Operation, error)

GetOperation reads an operation by its id: GET /operations/{id}.

func GroupText added in v0.6.0

func GroupText(g Group, loc *time.Location) string

GroupText is one group in full: its description, last change and a line per grant.

func GroupsText added in v0.6.0

func GroupsText(gs []Group, now time.Time) string

GroupsText is the groups as a table: name, description, grants and the age of the last change.

func IsLoadBalancerARN added in v0.6.0

func IsLoadBalancerARN(s string) bool

func IsNotFound added in v0.6.0

func IsNotFound(err error) bool

IsNotFound tells whether err is a 404 answer: a route, or a service, this manager does not have.

func IsTargetGroupARN added in v0.6.0

func IsTargetGroupARN(s string) bool

IsTargetGroupARN and IsLoadBalancerARN tell whether s is the ARN of an application target group or load balancer, as the manager accepts one to exclude.

func Labelled added in v0.6.0

func Labelled(rows [][2]string) string

Labelled is a line per row, "label value", the labels padded to the longest; a row with an empty value is left out, and the lines of a value on several lines are aligned with its first.

func LintText added in v0.6.0

func LintText(fs []LintFinding) string

LintText is a line per finding, "warning: <message> (filter <name>, include <n>)"; "no lint findings" for none.

func ListedOperation added in v0.6.0

func ListedOperation(c *Client) func(context.Context, string) (Operation, error)

ListedOperation reads an operation in GET /operations: the only route that brings the manager's updates up to date.

func MayHaveStarted added in v0.6.0

func MayHaveStarted(err error) bool

MayHaveStarted tells whether a failed start leaves the operation possibly created in the manager: a 5xx, a transport error, or a 2xx answer that cannot be read (a 4xx refusal, or an error before the request is sent, did not start it).

func NormalEmail added in v0.6.0

func NormalEmail(s string) (string, error)

NormalEmail is the email as the manager keeps it (trimmed, lower-cased), or an error when it is not an address.

func OperationText added in v0.6.0

func OperationText(op Operation, loc *time.Location) string

OperationText is one operation: labelled lines (times in loc), then its steps with their status, how long each took and what it says.

func OperationsTable added in v0.6.0

func OperationsTable(ops []Operation, now time.Time) string

OperationsTable is the operations as a table, in the order given: id, type, target, status, current step, who (an ARN shortened) and the age of its creation. "no operations" when there are none.

func ParseTags

func ParseTags(values []string) (map[string]string, error)

ParseTags reads --tag values, key=value: the value may hold "=" but no comma (API Gateway joins repeated parameters with commas and the manager splits them there), and a key is given once.

func Plural

func Plural(n int, word string) string

Plural is word, in the plural unless n is 1.

func PrintNext added in v0.6.0

func PrintNext(w io.Writer, loc *time.Location, next []NextEvent, due string)

PrintNext prints the next events and the maintenance wake due, in the zone.

func PutDiscounts added in v0.6.0

func PutDiscounts(ctx context.Context, c *Client, d Discounts) (json.RawMessage, error)

PutDiscounts sets the discounts: PUT /savings/settings, the answer as the API sent it.

func RoutersSummary

func RoutersSummary(rs []Router, available string) string

RoutersSummary is the line under the table: the version available and how many of rs are below it.

func RoutersTable

func RoutersTable(rs []Router, available string) string

RoutersTable is the routers list: the version as "from → to" when below the one available, "upgrading" while an upgrade runs, "?" when unknown; the workloads as their total and their count per state.

func Seconds added in v0.6.0

func Seconds(s int) string

Seconds is a duration as the dashboard writes it: 45 s, 3 min 5 s, 2 h 10 min.

func ShortARN added in v0.6.0

func ShortARN(s string) string

ShortARN is who an ARN names: its last two path parts (arn:aws:sts::1:assumed-role/Ci/run-42 is Ci/run-42, a user's ARN its name); anything that is not an ARN, or has no path, as it is.

func StatesShare added in v0.6.0

func StatesShare(totals map[string]int) string

StatesShare is the seconds per state as shares of the total, in whole percent: "ASLEEP 71%, AWAKE 24%".

func Table added in v0.6.0

func Table(rows [][]string) string

Table aligns rows (the first is the header) in columns two spaces apart.

func TagsProblem added in v0.6.0

func TagsProblem(tags map[string]string) string

TagsProblem says why the manager refuses these tags as a workload's (at most 50; key 1 to 128 and value up to 256 characters; letters, digits, spaces and _ . : / = + - @; no dormeto: key prefix), or "" when it accepts them.

func TargetGroupName added in v0.6.0

func TargetGroupName(arn string) string

TargetGroupName is the name in a target group's ARN (…:targetgroup/<name>/<id>), the ARN itself when it has none.

func Transient added in v0.6.0

func Transient(err error) bool

Transient tells whether err is worth waiting out: a network error, 429 or 5xx. Any other error (the credentials, an answer that cannot be read, a 4xx refusal) will not pass by itself.

func USD added in v0.6.0

func USD(v float64) string

USD is dollars with thousands grouped and cents: $1,234.50.

func UsersText added in v0.6.0

func UsersText(us []User, now time.Time) string

UsersText is the users as a table: email, role, groups, status (disabled when it is), MFA and the age of the account. "no users" when there are none.

func When added in v0.6.0

func When(at string, loc *time.Location) string

When is the RFC 3339 instant at as "2006-01-02 15:04 MST" in loc; "" for none, at itself when it is not a time.

func WindowText added in v0.6.0

func WindowText(kind, days, start, end, wake string) string

WindowText is "awake mon–fri 08:30–19:00" or "nap mon–fri 20:00–07:00 (next day), wake: header".

func WorkloadsSummary

func WorkloadsSummary(w Workloads) string

WorkloadsSummary is the line under the table: the total, with the count per state of the rows listed when they are all there. The manager's byState counts every workload the caller sees, whatever the filters, so it is not used.

func WorkloadsTable

func WorkloadsTable(ws []Workload, now time.Time) string

WorkloadsTable is the workloads list: tags as k=v sorted by key, CHANGED the time since the state began (else the last update), as 5m, 3h or 2d.

func ZoneOf added in v0.6.0

func ZoneOf(name string) (*time.Location, string)

ZoneOf is the schedule's zone for display; when it cannot be loaded, UTC and the sentence that says so.

Types

type APIError

type APIError struct {
	Status        int
	Code, Message string
	Gateway       bool
	OperationID   string
	Errors        []string
}

APIError is a refusal from API Gateway (Gateway) or from the manager (Code and Message; OperationID, the operation that holds the target, of a 409; Errors, the problems a 400 lists).

func (*APIError) Error

func (e *APIError) Error() string

type AccessReport added in v0.6.0

type AccessReport struct {
	Counts struct {
		Ready            int `json:"ready"`
		DiscoveryMissing int `json:"discoveryMissing"`
		CommandMissing   int `json:"commandMissing"`
		DiscoveryOnly    int `json:"discoveryOnly"`
		Unchecked        int `json:"unchecked"`
	} `json:"counts"`
	Accounts   []AccessRow `json:"accounts"`
	Cursor     *string     `json:"cursor,omitempty"` // the next page's, read here, never printed
	Delegation string      `json:"delegation"`
	CheckedAt  string      `json:"checkedAt"`
	Forwarders *struct {
		Connected  int `json:"connected"`
		Connecting int `json:"connecting"`
		Impossible []struct {
			Account string `json:"account"`
			Name    string `json:"name"`
			Reason  string `json:"reason"`
		} `json:"impossible"`
		Failed []struct {
			Account string `json:"account"`
			Name    string `json:"name"`
			Reason  string `json:"reason"`
		} `json:"failed"`
	} `json:"forwarders"`
	// contains filtered or unexported fields
}

AccessReport is the organization access of the last run: GET /iam/discovery/access, its accounts the ones read so far (every page). The first page's answer is kept, with the accounts as read, so --json prints every field.

func ReadAccess added in v0.6.0

func ReadAccess(ctx context.Context, c *Client, limit int) (AccessReport, error)

ReadAccess reads the access report page by page and stops at limit accounts when it is above zero.

func (AccessReport) MarshalJSON added in v0.6.0

func (r AccessReport) MarshalJSON() ([]byte, error)

MarshalJSON is the first page's answer with the accounts of every page read, and no page's cursor.

func (AccessReport) Text added in v0.6.0

func (r AccessReport) Text(loc *time.Location) string

Text is the counts, the delegation and forwarders, then a table of the accounts not ready, times in loc.

func (*AccessReport) UnmarshalJSON added in v0.6.0

func (r *AccessReport) UnmarshalJSON(data []byte) error

type AccessRow added in v0.6.0

type AccessRow struct {
	Account   string      `json:"account"`
	Name      string      `json:"name"`
	Discovery AccessState `json:"discovery"`
	Command   AccessState `json:"command"`
	Forwarder string      `json:"forwarder"`
	Reason    string      `json:"reason"`
}

AccessRow is an account of the perimeter whose access is not complete.

type AccessState added in v0.6.0

type AccessState struct {
	OK            bool   `json:"ok"`
	Reason        string `json:"reason"`
	DiscoveryOnly bool   `json:"discoveryOnly"`
}

AccessState is whether a role of an account works, and why not.

type Alarm added in v0.6.0

type Alarm struct {
	ID         string `json:"id"`
	Kind       string `json:"kind"` // router, list or workload
	Name       string `json:"name"`
	Account    string `json:"account,omitempty"`
	Region     string `json:"region,omitempty"`
	Router     string `json:"router,omitempty"`
	WorkloadID string `json:"workloadId,omitempty"`
	Level      string `json:"level"` // warning or error
	Since      string `json:"since"`
	Problems   []struct {
		Code string `json:"code"`
		Text string `json:"text"`
	} `json:"problems"`
}

Alarm is an open health alarm of GET /alerts: its subject's fields beside its level and problems.

type AlertsAnswer added in v0.6.0

type AlertsAnswer struct {
	Alarms        []Alarm        `json:"alarms"`
	Notifications *Notifications `json:"notifications"`
	// contains filtered or unexported fields
}

AlertsAnswer is the answer of GET /alerts; Notifications is nil when alerts are not configured (or for a member).

func GetAlerts added in v0.6.0

func GetAlerts(ctx context.Context, c *Client) (AlertsAnswer, error)

GetAlerts reads GET /alerts.

func (AlertsAnswer) MarshalJSON added in v0.6.0

func (a AlertsAnswer) MarshalJSON() ([]byte, error)

MarshalJSON is the answer as the API sent it.

func (AlertsAnswer) Text added in v0.6.0

func (a AlertsAnswer) Text(now time.Time) string

Text is the open alarms as a table (level, kind, name, age, problems), then the notification subscriptions; "no alerts configured" when the manager has none.

func (*AlertsAnswer) UnmarshalJSON added in v0.6.0

func (a *AlertsAnswer) UnmarshalJSON(data []byte) error

type AppliedVersion added in v0.6.0

type AppliedVersion struct {
	Version string `json:"version"`
	Build   string `json:"build"`
	At      string `json:"at"`
}

AppliedVersion is the version the install last applied, by its build.

type AuditEntry added in v0.6.0

type AuditEntry struct {
	ID     string `json:"id"`
	At     string `json:"at"`
	Who    string `json:"who"`
	Role   string `json:"role"`
	Action string `json:"action"`
	Target string `json:"target"`
	Result string `json:"result"`
	Reason string `json:"reason,omitempty"`
	// contains filtered or unexported fields
}

AuditEntry is a row of GET /audit; the row as the API sent it is kept.

func FilterAudit added in v0.6.0

func FilterAudit(entries []AuditEntry, f AuditFilter, limit int) (out []AuditEntry, total int)

FilterAudit keeps what f lets through, newest first, at most limit entries (all when limit is not positive); total is how many matched before the cut.

func ListAudit added in v0.6.0

func ListAudit(ctx context.Context, c *Client) ([]AuditEntry, error)

ListAudit reads GET /audit: the whole log, unpaged.

func (AuditEntry) MarshalJSON added in v0.6.0

func (e AuditEntry) MarshalJSON() ([]byte, error)

MarshalJSON is the row as the API sent it, or the fields known when it was built here.

func (*AuditEntry) UnmarshalJSON added in v0.6.0

func (e *AuditEntry) UnmarshalJSON(data []byte) error

type AuditFilter added in v0.6.0

type AuditFilter struct {
	Since       time.Time
	Actions     []string
	Who, Target string
}

AuditFilter narrows the log: entries since a time (zero for any), of one of the actions (none for any), whose who and target contain the texts, whatever their case.

type Candidate added in v0.6.0

type Candidate struct {
	ID             string   `json:"id"`
	Account        string   `json:"account"`
	AccountName    string   `json:"accountName,omitempty"`
	Region         string   `json:"region"`
	LoadBalancer   string   `json:"loadBalancer,omitempty"`
	TargetGroup    string   `json:"targetGroup,omitempty"`
	TargetGroupARN string   `json:"targetGroupArn,omitempty"`
	Hosts          []string `json:"hosts,omitempty"`
	Status         string   `json:"status"`
	StatusReason   string   `json:"statusReason,omitempty"`
	WorkloadID     string   `json:"workloadId,omitempty"`
	IdleHours7d    *float64 `json:"idleHours7d,omitempty"`
	Requests7d     *float64 `json:"requests7d,omitempty"`
	Workload       *struct {
		Router     string `json:"router"`
		WorkloadID string `json:"workloadId"`
		Name       string `json:"name"`
	} `json:"workload,omitempty"`
	Operation *OpRef `json:"operation,omitempty"`
	Backend   *struct {
		Kind string `json:"kind"`
	} `json:"backend,omitempty"`
	Dismissed *struct {
		By   string `json:"by"`
		At   string `json:"at"`
		Note string `json:"note"`
	} `json:"dismissed,omitempty"`
	// contains filtered or unexported fields
}

Candidate is a row of GET /iam/discovery/candidates: what the CLI reads of it. The row as the API sent it is kept, so --json prints every field. Its id is the ARN of its target group (or of its rule), and only ever travels in a body.

func ListCandidates added in v0.6.0

func ListCandidates(ctx context.Context, c *Client, status, account, region string, limit int) ([]Candidate, error)

ListCandidates reads the candidates of a status (and of an account, and a region of it, when given) page by page, 200 at a time, and stops at limit when it is above zero.

func ResolveCandidates added in v0.6.0

func ResolveCandidates(cs []Candidate, refs []string) ([]Candidate, error)

ResolveCandidates finds what each ref names among cs: the candidate with that id, else the one whose target group has that name. A ref that names none, or the target groups of several accounts or regions, is an error (a usage error to the commands) and nothing is resolved; each candidate is given once.

func (Candidate) MarshalJSON added in v0.6.0

func (c Candidate) MarshalJSON() ([]byte, error)

MarshalJSON is the row as the API sent it, or the fields known when it was built here.

func (Candidate) Name added in v0.6.0

func (c Candidate) Name() string

Name is the candidate's target group name, or its id when it has no target group.

func (*Candidate) UnmarshalJSON added in v0.6.0

func (c *Candidate) UnmarshalJSON(data []byte) error

type CatalogList added in v0.6.0

type CatalogList struct {
	Name         string `json:"name"`
	URL          string `json:"url"`
	Action       string `json:"action"` // defer or ignore
	RefreshHours int    `json:"refreshHours"`
	Version      string `json:"version,omitempty"`
	Entries      *int   `json:"entries,omitempty"`
	Dropped      int    `json:"dropped,omitempty"`
	FetchedAt    string `json:"fetchedAt,omitempty"`
	Error        string `json:"error,omitempty"`
}

CatalogList is a list of the manager's IP lists catalog with what its download last did.

type Changes added in v0.6.0

type Changes struct {
	Sections []ReleaseNotes
	// contains filtered or unexported fields
}

Changes is the answer of GET /update/changes: the release notes of the versions up to the one asked, newest first.

func GetChanges added in v0.6.0

func GetChanges(ctx context.Context, c *Client, to string) (Changes, error)

GetChanges reads the release notes up to the version to: GET /update/changes?to=.

func (Changes) MarshalJSON added in v0.6.0

func (c Changes) MarshalJSON() ([]byte, error)

MarshalJSON is the answer as the API sent it.

func (Changes) Text added in v0.6.0

func (c Changes) Text() string

Text is the release notes, newest first, each with a note when its access change is not applied by the update.

func (*Changes) UnmarshalJSON added in v0.6.0

func (c *Changes) UnmarshalJSON(data []byte) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls the manager's /iam routes, signing each request with SigV4 for execute-api.

func New

func New(httpClient *http.Client, baseURL, region string, creds aws.CredentialsProvider, now func() time.Time) *Client

New is a Client of the API at baseURL (no trailing path), signing for region with creds; the timeout is httpClient's.

func (*Client) BaseURL added in v0.6.0

func (c *Client) BaseURL() string

BaseURL is the API's endpoint the client calls.

func (*Client) Delete added in v0.5.0

func (c *Client) Delete(ctx context.Context, path string, out any) error

Delete calls DELETE /iam<path> and decodes the answer into out (nil to ignore it); never retried.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, query url.Values, out any) error

Get calls GET /iam<path>?query and decodes the JSON answer into out (nil to ignore it).

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body, out any) error

Post calls POST /iam<path> with body as JSON (nil for none) and decodes the answer into out; never retried.

func (*Client) Put added in v0.5.0

func (c *Client) Put(ctx context.Context, path string, body, out any) error

Put calls PUT /iam<path> with body as JSON and decodes the answer into out; never retried.

func (*Client) Raw added in v0.6.0

func (c *Client) Raw(ctx context.Context, method, path string, query url.Values, body []byte) (status int, data []byte, err error)

Raw calls method /iam<path>?query with body as it is (nil for none, else sent as JSON) and gives the answer's status and body: a non-2xx is no error here. A GET is retried as Get is.

func (*Client) Region added in v0.6.0

func (c *Client) Region() string

Region is the region the client signs for: the API's.

type ClusterCheck added in v0.6.0

type ClusterCheck struct {
	Name      string   `json:"name"`
	Reachable bool     `json:"reachable"`
	Allowed   bool     `json:"allowed"`
	Missing   []string `json:"missing"`
	Reason    string   `json:"reason"`
	CheckedAt string   `json:"checkedAt"`
}

ClusterCheck is an EKS cluster of the router's account and region as its last check found it.

type Configured added in v0.6.0

type Configured[T any] struct {
	Value  T      `json:"value"`
	Source string `json:"source"`
}

Configured is a setting with where it is set: terraform (the router's module) or manager.

type Discounts added in v0.6.0

type Discounts struct {
	Compute   int `json:"compute"`
	Databases int `json:"databases"`
}

Discounts are the discounts for commitments, in percent, that the estimate prices with.

type DiscoveryConfig added in v0.6.0

type DiscoveryConfig struct {
	Config    json.RawMessage `json:"config"`
	UpdatedAt string          `json:"updatedAt"`
	UpdatedBy string          `json:"updatedBy"`
	Lint      []LintFinding   `json:"lint"`
	// contains filtered or unexported fields
}

DiscoveryConfig is the answer of GET and PUT /iam/discovery/config: the configuration (kept as it is, to be printed and edited), when and by whom it was last set, and what each of its filters matches.

func (DiscoveryConfig) MarshalJSON added in v0.6.0

func (d DiscoveryConfig) MarshalJSON() ([]byte, error)

MarshalJSON is the answer as the API sent it, or the fields known when it was built here.

func (DiscoveryConfig) Text added in v0.6.0

func (d DiscoveryConfig) Text() string

Text is the configuration as indented JSON alone: a file `config set` takes.

func (*DiscoveryConfig) UnmarshalJSON added in v0.6.0

func (d *DiscoveryConfig) UnmarshalJSON(data []byte) error

type DiscoveryStatus added in v0.6.0

type DiscoveryStatus struct {
	LastRun *RunRecord     `json:"lastRun"`
	Refused *RunRecord     `json:"refused"`
	Counts  map[string]int `json:"counts"`
	Access  *struct {
		DiscoveryRole string `json:"discoveryRole"`
		CommandRole   string `json:"commandRole"`
	} `json:"access"`
	// contains filtered or unexported fields
}

DiscoveryStatus is the answer of GET /iam/discovery: the last run, a Run now refused since, the candidates per status, and the roles set in the manager's Terraform. The answer as the API sent it is kept.

func (DiscoveryStatus) MarshalJSON added in v0.6.0

func (d DiscoveryStatus) MarshalJSON() ([]byte, error)

MarshalJSON is the answer as the API sent it, or the fields known when it was built here.

func (DiscoveryStatus) Text added in v0.6.0

func (d DiscoveryStatus) Text(loc *time.Location) string

Text is the last run (when, by whom, what it scanned and found wrong), the run refused since, the candidates per status, the roles and the lint of the run, times in loc.

func (*DiscoveryStatus) UnmarshalJSON added in v0.6.0

func (d *DiscoveryStatus) UnmarshalJSON(data []byte) error

type Event

type Event struct {
	Ended bool
	Outcome
}

Event is reported as an upgrade starts and as it ends.

type Exclusion added in v0.6.0

type Exclusion struct {
	ID        string          `json:"id"`
	Target    ExclusionTarget `json:"target"`
	Reason    string          `json:"reason"`
	By        string          `json:"by"`
	At        string          `json:"at"`
	ExpiresAt string          `json:"expiresAt,omitempty"`
	LiftedAt  string          `json:"liftedAt,omitempty"`
	LapsedAt  string          `json:"lapsedAt,omitempty"`
	Paused    []struct {
		Router     string `json:"router"`
		WorkloadID string `json:"workloadId"`
		Name       string `json:"name,omitempty"`
	} `json:"paused,omitempty"`
	Expired bool `json:"expired"`
	Lifting bool `json:"lifting"`
	// contains filtered or unexported fields
}

Exclusion is a row of GET /iam/exclusions: what the CLI reads of it. The row as the API sent it is kept, so --json prints every field.

func ListExclusions added in v0.6.0

func ListExclusions(ctx context.Context, c *Client) ([]Exclusion, error)

ListExclusions reads GET /exclusions.

func (Exclusion) MarshalJSON added in v0.6.0

func (e Exclusion) MarshalJSON() ([]byte, error)

MarshalJSON is the row as the API sent it, or the fields known when it was built here.

func (Exclusion) State added in v0.6.0

func (e Exclusion) State() string

State is "lifting" while a lift runs, "expired" once its date has passed, else "active".

func (*Exclusion) UnmarshalJSON added in v0.6.0

func (e *Exclusion) UnmarshalJSON(data []byte) error

type ExclusionTarget added in v0.6.0

type ExclusionTarget struct {
	Kind    string `json:"kind"` // target-group, load-balancer or account
	ARN     string `json:"arn,omitempty"`
	Account string `json:"account"`
	Region  string `json:"region,omitempty"`
	Name    string `json:"name"`
}

ExclusionTarget is what an exclusion leaves out of discovery: a target group, a load balancer or a whole account.

func (ExclusionTarget) Text added in v0.6.0

func (t ExclusionTarget) Text() string

Text is the target as the manager words it: "target group api", "account sandbox (123456789012)".

type FleetStates added in v0.6.0

type FleetStates struct {
	Workloads int `json:"workloads"`
	States7d  struct {
		Totals map[string]float64 `json:"totals"` // seconds per state
	} `json:"states7d"`
}

FleetStates is what GET /workloads/states says of the time in each state over 7 days.

func (FleetStates) Shares added in v0.6.0

func (s FleetStates) Shares() string

Shares are the states' shares of the 7 days, as "ASLEEP 62%, AWAKE 38%" (largest first); "" when no time is counted.

type FollowOptions added in v0.6.0

type FollowOptions struct {
	Poll     time.Duration
	Sleep    func(context.Context, time.Duration) error // ends with the context's error when it is done
	Progress func(Operation)                            // called with the record each time a step's status changes
	// WaitOut, when set, has every failed read waited out until the context ends, not only the transient ones (the
	// manager's update replaces the API: its routes may answer anything for a moment); it is told each error whose
	// message it was not told yet.
	WaitOut func(error)
}

FollowOptions are how Follow reads; Sleep is injected so that tests need no real time.

type Grant added in v0.6.0

type Grant struct {
	Tags        map[string]string `json:"tags"`
	Permissions []string          `json:"permissions"`
}

Grant is what a group allows: the permissions on the workloads that carry all of Tags (every workload when empty).

func ParseGrant added in v0.6.0

func ParseGrant(s string) (Grant, error)

ParseGrant reads a --grant value, <tags>:<permissions>, split at the last ":" (a tag may hold one). The tags are comma-separated key=value, none for every workload; the permissions a non-empty subset of read, wake and nap.

func ParseGrants added in v0.6.0

func ParseGrants(values []string) ([]Grant, error)

ParseGrants reads every --grant value: at most 20.

func (Grant) Text added in v0.6.0

func (g Grant) Text() string

Text is the grant as --grant spells it: "team=a,env=dev:read,wake"; "every workload" stands for no tags.

type Group added in v0.6.0

type Group struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Grants      []Grant `json:"grants"`
	UpdatedAt   string  `json:"updatedAt"`
	UpdatedBy   string  `json:"updatedBy"`
	// contains filtered or unexported fields
}

Group is a custom group of GET /iam/groups, its grants included; kept raw as User is.

func ListGroups added in v0.6.0

func ListGroups(ctx context.Context, c *Client) ([]Group, error)

ListGroups reads GET /groups.

func (Group) MarshalJSON added in v0.6.0

func (g Group) MarshalJSON() ([]byte, error)

MarshalJSON is the row as the API sent it, or the fields known when it was built here.

func (*Group) UnmarshalJSON added in v0.6.0

func (g *Group) UnmarshalJSON(data []byte) error

type Health

type Health struct {
	Status string `json:"status"`
}

Health is a router's health as the manager reports it ("" when unknown).

type HistoryEntry added in v0.6.0

type HistoryEntry struct {
	From       *string `json:"from"`
	To         string  `json:"to"`
	At         string  `json:"at"`
	Cause      string  `json:"cause"`
	By         string  `json:"by"`
	Inferred   bool    `json:"inferred"`
	DurationMs int     `json:"durationMs"`
	Failure    *struct {
		Message string `json:"message"`
	} `json:"failure"`
}

HistoryEntry is a change of state: what it was, what started it, how long a wake took.

type IPCatalog added in v0.6.0

type IPCatalog struct {
	URL   string   `json:"url"`
	Lists []IPList `json:"lists"`
}

IPCatalog is the manager's IP lists a router reads.

type IPList added in v0.6.0

type IPList struct {
	Name         string `json:"name"`
	URL          string `json:"url"`
	Action       string `json:"action"`
	RefreshHours int    `json:"refreshHours"`
}

IPList is a router's IP list as configured.

type IPListsAnswer added in v0.6.0

type IPListsAnswer struct {
	Catalog *string       `json:"catalog"`
	Lists   []CatalogList `json:"lists"`
	// contains filtered or unexported fields
}

IPListsAnswer is the answer of GET /ip-lists: the catalog's URL (nil when none is configured) and the lists.

func GetIPLists added in v0.6.0

func GetIPLists(ctx context.Context, c *Client) (IPListsAnswer, error)

GetIPLists reads GET /ip-lists.

func (IPListsAnswer) MarshalJSON added in v0.6.0

func (a IPListsAnswer) MarshalJSON() ([]byte, error)

MarshalJSON is the answer as the API sent it.

func (IPListsAnswer) Text added in v0.6.0

func (a IPListsAnswer) Text(now time.Time) string

Text is the lists as a table (name, action, entries, last download, status), then the catalog; "no IP lists configured" when the manager has no catalog.

func (*IPListsAnswer) UnmarshalJSON added in v0.6.0

func (a *IPListsAnswer) UnmarshalJSON(data []byte) error

type IdleWindowAdvice added in v0.6.0

type IdleWindowAdvice struct {
	ComputedAt  string   `json:"computedAt"`
	To          string   `json:"to"`
	Current     int      `json:"current"`
	Recommended int      `json:"recommended"`
	WakeSeconds *float64 `json:"wakeSeconds"`
	Priced      bool     `json:"priced"`
	Windows     []struct {
		Minutes           int      `json:"minutes"`
		AsleepHours       float64  `json:"asleepHours"`
		USDMonth          *float64 `json:"usdMonth"`
		WakesPerDay       float64  `json:"wakesPerDay"`
		WaitSecondsPerDay *float64 `json:"waitSecondsPerDay"`
	} `json:"windows"`
	Actual struct {
		Wakes         int  `json:"wakes"`
		ReplayedWakes int  `json:"replayedWakes"`
		Noisy         bool `json:"noisy"`
	} `json:"actual"`
	WakerTargetGroup bool `json:"wakerTargetGroup"`
}

IdleWindowAdvice is the answer of GET /iam/workloads/{router}/{id}/idle-window: the last 14 days of requests replayed against idle windows, priced as savings.

func (IdleWindowAdvice) Text added in v0.6.0

func (a IdleWindowAdvice) Text(loc *time.Location) string

Text is the sentence of the advice, the windows tried (savings a month, or hours asleep a day when nothing is priced, wakes and wait a day) and the notes the dashboard gives under them.

type LintFinding added in v0.6.0

type LintFinding struct {
	Code    string `json:"code"`
	Level   string `json:"level"`
	Filter  string `json:"filter"`
	Include int    `json:"include"`
	By      string `json:"by"`
	Message string `json:"message"`
}

LintFinding is something the discovery configuration's filters do that is probably not meant.

type Locator

type Locator interface {
	APIURL(ctx context.Context, env, region string) (string, error)
}

Locator finds the manager's API endpoint of an environment.

func NewLocator

func NewLocator(cfg aws.Config) Locator

NewLocator is the Locator over API Gateway in cfg's region, with the standard retryer (5 attempts).

type ManagerStatus added in v0.6.0

type ManagerStatus struct {
	Version string       `json:"version"`
	Update  UpdateState  `json:"update"`
	Check   *UpdateCheck `json:"check"`
}

ManagerStatus is what `dormeto manager status` reads: the version /health gives, the update's state and the daily check (nil when the manager has none).

func (ManagerStatus) Text added in v0.6.0

func (m ManagerStatus) Text(loc *time.Location) string

Text is the status as labelled lines, as the Update page shows it; times in loc.

type NextEvent added in v0.6.0

type NextEvent struct {
	At     string `json:"at"`
	Kind   string `json:"kind"`
	Window int    `json:"window"`
}

type NoWake added in v0.6.0

type NoWake struct {
	Name       string          `json:"name"`
	Invalid    string          `json:"invalid"`
	Conditions json.RawMessage `json:"conditions"`
}

NoWake is a no-wake rule: its conditions are kept as the router described them.

type Notifications added in v0.6.0

type Notifications struct {
	TopicARN  string `json:"topicArn"`
	Confirmed int    `json:"confirmed"`
	Pending   int    `json:"pending"`
	Endpoints []struct {
		Protocol string `json:"protocol"`
		Endpoint string `json:"endpoint"`
		Pending  bool   `json:"pending"`
	} `json:"endpoints,omitempty"`
}

Notifications are where the alerts go: the topic and its subscriptions (the endpoints only for an administrator, masked).

type OpRef

type OpRef struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

OpRef is the install, upgrade or uninstall running on a router.

type Operation

type Operation struct {
	ID         string          `json:"id"`
	Type       string          `json:"type"`
	Status     string          `json:"status"` // running, succeeded or failed
	Target     OperationTarget `json:"target"`
	Steps      []OperationStep `json:"steps"`
	Error      string          `json:"error,omitempty"`
	By         string          `json:"by,omitempty"`
	CreatedAt  string          `json:"createdAt,omitempty"`
	UpdatedAt  string          `json:"updatedAt,omitempty"`
	FinishedAt string          `json:"finishedAt,omitempty"`
	// contains filtered or unexported fields
}

Operation is a record of the manager's operations: what the CLI reads of it. The record as the API sent it is kept, so --json prints every field (input, context, holds), not only these.

func ApplyUpdate added in v0.6.0

func ApplyUpdate(ctx context.Context, c *Client, planBuild string) (Operation, error)

ApplyUpdate asks the manager to apply the plan of its build (POST /update/apply), as PlanUpdate does.

func Exclude added in v0.6.0

func Exclude(ctx context.Context, c *Client, body map[string]any) (Operation, error)

Exclude starts an exclusion: POST /exclusions with body ({target, reason, expiresAt?, workload?}), the operation that pauses its workloads.

func FilterOperations added in v0.6.0

func FilterOperations(ops []Operation, running bool, types []string, limit int) (kept []Operation, total int)

FilterOperations keeps the running operations when running is set, those of one of types when there are any, newest first by creation, at most limit of them (all when limit is not positive); total is how many matched before the cut.

func Follow added in v0.6.0

func Follow(ctx context.Context, get func(context.Context, string) (Operation, error), id string, o FollowOptions) (Operation, error)

Follow reads the operation id with get, at once then every Poll, until it is no longer running, and gives its last record. Progress is called when a step's status changes (a step not seen yet counts as pending). It ends with the error of the reads given up on (none with WaitOut), or with the context's error when it is done, the last record read returned with it.

func LiftExclusion added in v0.6.0

func LiftExclusion(ctx context.Context, c *Client, id string) (Operation, error)

LiftExclusion lifts an exclusion: DELETE /exclusions/{id}, the operation that resumes its workloads and deletes it.

func ListOperations added in v0.6.0

func ListOperations(ctx context.Context, c *Client) ([]Operation, error)

ListOperations reads GET /operations: every record the manager keeps, unpaged.

func PlanUpdate added in v0.6.0

func PlanUpdate(ctx context.Context, c *Client, version string) (Operation, error)

PlanUpdate asks the manager to plan its update to version (POST /update/plan): the update-manager operation its request is recorded as, running; none (no id) when the answer names no operation.

func StartOperation added in v0.6.0

func StartOperation(ctx context.Context, c *Client, body map[string]any) (Operation, error)

StartOperation starts an operation: POST /operations with body ({type, …}), the record it answers.

func (Operation) Current added in v0.6.0

func (o Operation) Current() *OperationStep

Current is the step the operation is at: the running one, else the failed one, else the last one done; nil when no step has begun.

func (Operation) InstallBuild added in v0.6.0

func (o Operation) InstallBuild() string

InstallBuild is the install build a manager update's record names in its context (once the manager knows it); "" when it names none.

func (Operation) MarshalJSON added in v0.6.0

func (o Operation) MarshalJSON() ([]byte, error)

MarshalJSON is the record as the API sent it, or the fields known when it was built here.

func (Operation) TargetText added in v0.6.0

func (o Operation) TargetText() string

TargetText is the target as the CLI names it: <router>/<workload>, the router, the candidate's target group name, <account>/<region>, the exclusion, or the account.

func (*Operation) UnmarshalJSON added in v0.6.0

func (o *Operation) UnmarshalJSON(data []byte) error

func (Operation) Workload added in v0.6.0

func (o Operation) Workload() (router, id string)

Workload is the workload an onboarding or an offboarding concerns, once known: the operation's target (what a member is shown), else its context (an onboarding's preview names it). The router is "" when the record does not name it.

type OperationStep

type OperationStep struct {
	Name       string `json:"name"`
	Status     string `json:"status"`
	Detail     string `json:"detail,omitempty"`
	StartedAt  string `json:"startedAt,omitempty"`
	FinishedAt string `json:"finishedAt,omitempty"`
}

OperationStep is one step of an operation: pending, running, done, skipped or failed.

type OperationTarget added in v0.6.0

type OperationTarget struct {
	Account         string `json:"account,omitempty"`
	Region          string `json:"region,omitempty"`
	Router          string `json:"router,omitempty"`
	WorkloadID      string `json:"workloadId,omitempty"`
	TargetGroupARN  string `json:"targetGroupArn,omitempty"`
	LoadBalancerARN string `json:"loadBalancerArn,omitempty"`
	ExclusionID     string `json:"exclusionId,omitempty"`
	Version         string `json:"version,omitempty"`
}

OperationTarget is what an operation acts on, as the manager records it: an account and region (a router's install, upgrade or uninstall; the manager's update, with its version), a workload (offboard: its router and id too), a candidate's target group and load balancer (onboard), an exclusion (exclude, lift-exclusion), an account alone (its connection).

type Operations

type Operations interface {
	Start(ctx context.Context, router string) (Operation, error)
	Get(ctx context.Context, id string) (Operation, error)
}

Operations starts and reads the manager's operations.

func NewOperations

func NewOperations(c *Client) Operations

NewOperations is the manager's operations through c: POST /operations, GET /operations/<id>.

type Outcome

type Outcome struct {
	Router    string        `json:"router"`
	From      string        `json:"from"`
	To        string        `json:"to"`
	Operation string        `json:"operation,omitempty"`
	Status    string        `json:"status"`
	Error     string        `json:"error,omitempty"`
	Duration  time.Duration `json:"-"`
}

Outcome is what became of an upgrade. Status: succeeded, failed (it did not start, or ended failed), running (the run stopped following it), unknown (the operation could not be read) or "not started" (the run stopped first).

func (Outcome) Line

func (o Outcome) Line() string

Line is the outcome as printed when it ends: ✓ from → to and its duration, or ✗ the failed step and its detail.

type Overview added in v0.6.0

type Overview struct {
	Workloads *Workloads
	States    *FleetStates
	StatesRaw json.RawMessage
	Savings   *SavingsAnswer
	Alerts    *AlertsAnswer
	Running   *[]Operation
	Routers   *Routers
	Missing   map[string]bool // the blocks whose route answered 404: that service is not in this manager
	Failed    []error         // one per route that failed otherwise, naming it
}

Overview is what the six routes of the overview answered: a block is nil when its route failed (Failed says why) or is not in this manager (Missing).

func ReadOverview added in v0.6.0

func ReadOverview(ctx context.Context, c *Client) Overview

ReadOverview reads the routes of the overview in turn; one that answers 404 is recorded in Missing, one that fails otherwise in Failed, and its block is left out.

func (Overview) JSON added in v0.6.0

func (o Overview) JSON() map[string]any

JSON is the composite --json prints: workloads {total, byState}, states (the API's answer), savings (the API's answer), alerts {open}, operations {running}, routers {total, outdated, available}; a block whose route is not in this manager is null, one whose route failed is absent.

func (Overview) Text added in v0.6.0

func (o Overview) Text(now time.Time) string

Text is the overview as labelled lines, a block per route that answered, then the running operations.

type Pause added in v0.6.0

type Pause struct {
	Scope      string `json:"scope"`
	By         string `json:"by"`
	At         string `json:"at"`
	Reason     string `json:"reason"`
	Until      string `json:"until"`
	KeepAsleep bool   `json:"keepAsleep"`
}

Pause is an active pause of the router (or of one of its workloads).

type Plan

type Plan struct {
	Available string
	Upgrade   []Step
	Skipped   []Skip
}

Plan is what an upgrade does to the routers selected.

func PlanUpgrade

func PlanUpgrade(rs []Router, available string) Plan

PlanUpgrade decides for each router, in order: written in Terraform, an operation running, its version unknown, up to date, newer than the version available (a pre-release is below its release), else upgraded.

func (Plan) Text

func (p Plan) Text() string

Text is the plan as printed: the routers to upgrade with from → to, then the skipped ones with their reasons.

type PlanSummary added in v0.6.0

type PlanSummary struct {
	Add       int      `json:"add"`
	Change    int      `json:"change"`
	Destroy   int      `json:"destroy"`
	Replaced  []string `json:"replaced"`
	Destroyed []string `json:"destroyed"`
}

PlanSummary is what a plan changes: resources added, changed and destroyed, and the addresses replaced or destroyed.

func (PlanSummary) Counts added in v0.6.0

func (p PlanSummary) Counts() string

Counts is what the plan changes in a few words: "2 to add, 1 to change, 0 to destroy".

type Problem added in v0.6.0

type Problem struct {
	Level string `json:"level"`
	Text  string `json:"text"`
}

Problem is a finding of the router's health.

type ReleaseNotes added in v0.6.0

type ReleaseNotes struct {
	Version      string `json:"version"`
	Notes        string `json:"notes"`
	Access       string `json:"access"`
	AccessNeeded bool   `json:"accessNeeded"`
}

ReleaseNotes is a version's section of the changelog (Notes "" when it could not be read), and the access change it asks for, which the update does not apply (AccessNeeded).

type Result

type Result struct {
	Available string    `json:"available"`
	Upgraded  []Outcome `json:"upgraded"`
	Skipped   []Skip    `json:"skipped"`
	Stopped   bool      `json:"-"` // the context ended before every upgrade did
}

Result is what an upgrade run did: the outcome of each router of the plan, in its order, and the routers skipped.

func Upgrade

func Upgrade(ctx context.Context, api Operations, plan Plan, o UpgradeOptions) Result

Upgrade starts the plan's upgrades, at most Concurrency at once, and follows each every Poll until it ends. When ctx ends, it starts no more and stops following: the upgrades started go on in the manager, reported as running.

func (Result) Failed

func (r Result) Failed() int

Failed counts the upgrades that failed or whose operation could not be read.

func (Result) NotStarted

func (r Result) NotStarted() int

func (Result) Running

func (r Result) Running() int

Running counts those the run stopped following; NotStarted those it stopped before starting.

func (Result) Summary

func (r Result) Summary() string

Summary counts the outcomes: "2 upgraded, 1 failed, 1 still running, 3 not started" (only those there are).

func (Result) Unfinished

func (r Result) Unfinished() (n int)

Unfinished counts the upgrades with an operation in the manager whose end the run did not see: they may go on there.

type Router

type Router struct {
	Name           string         `json:"name"`
	Account        string         `json:"account,omitempty"` // absent for a router of the manager's own account written in Terraform
	Region         string         `json:"region"`
	Source         string         `json:"source"`            // manager or terraform
	Version        string         `json:"version,omitempty"` // "" when unknown (null)
	Health         Health         `json:"health"`
	Workloads      int            `json:"workloads"`
	WorkloadStates map[string]int `json:"workloadStates,omitempty"`
	Error          string         `json:"error,omitempty"` // the router did not answer
	Operation      *OpRef         `json:"operation,omitempty"`
	// contains filtered or unexported fields
}

Router is a row of GET /iam/routers: what the CLI reads of it. The row as the API sent it is kept, so --json prints every field, not only these.

func (Router) MarshalJSON

func (r Router) MarshalJSON() ([]byte, error)

MarshalJSON is the row as the API sent it, or the fields known when it was built here.

func (Router) Outdated

func (r Router) Outdated(available string) bool

Outdated tells whether the router runs a version below the one available (a pre-release is below its release; an unknown version, or none available, is not outdated).

func (*Router) UnmarshalJSON

func (r *Router) UnmarshalJSON(data []byte) error

type RouterDetails added in v0.6.0

type RouterDetails struct {
	Name    string `json:"name"`
	Region  string `json:"region"`
	Account string `json:"account"`
	Source  string `json:"source"`
	Router  struct {
		Version string `json:"version"`
		Build   string `json:"build"`
	} `json:"router"`
	Clusters      []ClusterCheck `json:"clusters"`
	Configuration struct {
		CheckSchedule  Configured[*string]    `json:"checkSchedule"`
		IPLists        Configured[[]IPList]   `json:"ipLists"`
		IPListsCatalog *Configured[IPCatalog] `json:"ipListsCatalog"`
		NoWakeRules    Configured[[]NoWake]   `json:"noWakeRules"`
		Metrics        Configured[*bool]      `json:"metrics"`
	} `json:"configuration"`
	Pauses    []Pause `json:"pauses"`
	Workloads struct {
		Total          int            `json:"total"`
		ByState        map[string]int `json:"byState"`
		Paused         int            `json:"paused"`
		LastActivityAt string         `json:"lastActivityAt"`
	} `json:"workloads"`
	Health struct {
		Status               string    `json:"status"`
		Problems             []Problem `json:"problems"`
		CheckSchedule        *string   `json:"checkSchedule"`
		LastScheduledCheckAt string    `json:"lastScheduledCheckAt"`
		Lambda               struct {
			Error      string                           `json:"error"`
			Controller *struct{ Errors, Throttles int } `json:"controller"`
			Waker      *struct {
				Errors, Throttles int
				PeakConcurrency   int `json:"peakConcurrency"`
			} `json:"waker"`
		} `json:"lambda"`
		Queues struct {
			Error      string `json:"error"`
			Check      *int   `json:"check"`
			Controller *int   `json:"controller"`
		} `json:"queues"`
		IPLists []struct {
			Name      string `json:"name"`
			Entries   int    `json:"entries"`
			FetchedAt string `json:"fetchedAt"`
			Error     string `json:"error"`
			Pending   bool   `json:"pending"`
			Source    string `json:"source"`
		} `json:"ipLists"`
		Concurrency *struct {
			Limit, Needed int
			WorstCase     *int   `json:"worstCase"`
			Error         string `json:"error"`
		} `json:"concurrency"`
	} `json:"health"`
	// contains filtered or unexported fields
}

RouterDetails is the answer of GET /iam/routers/{router}: what the CLI prints of it. The answer as the API sent it is kept, so --json prints every field.

func (RouterDetails) MarshalJSON added in v0.6.0

func (d RouterDetails) MarshalJSON() ([]byte, error)

MarshalJSON is the answer as the API sent it, or the fields known when it was built here.

func (RouterDetails) Text added in v0.6.0

func (d RouterDetails) Text(loc *time.Location) string

Text is the details as labelled lines, times in loc: the router, its health and figures, its pauses, then its configuration with where each setting is set.

func (*RouterDetails) UnmarshalJSON added in v0.6.0

func (d *RouterDetails) UnmarshalJSON(data []byte) error

type RouterError

type RouterError struct {
	Router  string `json:"router"`
	Message string `json:"message"`
}

RouterError is a router that did not answer the workloads' listing.

type Routers

type Routers struct {
	Rows      []Router
	Available string
}

Routers is the answer of GET /iam/routers: the rows and the version available ("" when the manager names none).

func (Routers) MarshalJSON

func (rs Routers) MarshalJSON() ([]byte, error)

MarshalJSON is the API's shape: available is absent when none is named.

func (*Routers) UnmarshalJSON

func (rs *Routers) UnmarshalJSON(data []byte) error

type RunRecord added in v0.6.0

type RunRecord struct {
	StartedAt     string `json:"startedAt"`
	FinishedAt    string `json:"finishedAt"`
	Trigger       string `json:"trigger"`
	By            string `json:"by"`
	Status        string `json:"status"` // running, ok, partial, failed or skipped
	SkippedReason string `json:"skippedReason"`
	Error         string `json:"error"`
	Targets       []struct {
		Account string `json:"account"`
		Region  string `json:"region"`
		Status  string `json:"status"`
		Error   string `json:"error"`
	} `json:"targets"`
	EmptyPairs int `json:"emptyPairs"`
	Skipped    []struct {
		Reason string `json:"reason"`
		Pairs  int    `json:"pairs"`
	} `json:"skipped"`
	Lint       []LintFinding `json:"lint"`
	Delegation string        `json:"delegation"`
}

RunRecord is a discovery run as the manager records it.

func (RunRecord) Ended added in v0.6.0

func (r RunRecord) Ended() bool

Ended tells whether the run is over (it shows as running while its accounts are scanned).

type SavingsAnswer added in v0.6.0

type SavingsAnswer struct {
	Summary  *SavingsSummary  `json:"summary"`
	Settings *SavingsSettings `json:"settings"`
	// contains filtered or unexported fields
}

SavingsAnswer is the answer of GET /savings: the summary (null before the first night's run) and the settings.

func GetSavings added in v0.6.0

func GetSavings(ctx context.Context, c *Client) (SavingsAnswer, error)

GetSavings reads GET /savings.

func (SavingsAnswer) MarshalJSON added in v0.6.0

func (a SavingsAnswer) MarshalJSON() ([]byte, error)

MarshalJSON is the answer as the API sent it.

func (SavingsAnswer) Text added in v0.6.0

func (a SavingsAnswer) Text(loc *time.Location) string

Text is the estimate as the Savings card tells it: the figures as labelled lines, the top savers as a table, the discounts and what is not counted. Times in loc.

func (*SavingsAnswer) UnmarshalJSON added in v0.6.0

func (a *SavingsAnswer) UnmarshalJSON(data []byte) error

type SavingsSettings added in v0.6.0

type SavingsSettings struct {
	Discounts
	UpdatedAt string `json:"updatedAt,omitempty"`
	UpdatedBy string `json:"updatedBy,omitempty"`
}

SavingsSettings are the discounts as an administrator last set them.

type SavingsSummary added in v0.6.0

type SavingsSummary struct {
	ComputedAt string `json:"computedAt"`
	Day        string `json:"day"`
	Baseline   struct {
		Kind     string `json:"kind"`
		TimeZone string `json:"timeZone,omitempty"`
	} `json:"baseline"`
	Last30 struct {
		USD         float64 `json:"usd"`
		AsleepHours float64 `json:"asleepHours"`
	} `json:"last30"`
	Month struct {
		Month string  `json:"month"`
		USD   float64 `json:"usd"`
	} `json:"month"`
	Cumulative struct {
		USD   float64 `json:"usd"`
		Since string  `json:"since"`
	} `json:"cumulative"`
	Top []struct {
		Router     string  `json:"router"`
		WorkloadID string  `json:"workloadId"`
		Name       string  `json:"name,omitempty"`
		USD        float64 `json:"usd"`
	} `json:"top"`
	Unpriced struct {
		Workloads int     `json:"workloads"`
		Hours     float64 `json:"hours"`
	} `json:"unpriced"`
	Workloads int `json:"workloads"`
	Dormeto   struct {
		USDMonth float64 `json:"usdMonth"`
	} `json:"dormeto"`
	Discounts *Discounts `json:"discounts,omitempty"`
}

SavingsSummary is the daily job's estimate of what the naps saved (GET /savings).

type ScheduleView added in v0.6.0

type ScheduleView struct {
	TimeZone string `json:"timeZone"`
	Windows  []struct {
		Kind  string   `json:"kind"`
		Days  []string `json:"days"`
		Start string   `json:"start"`
		End   string   `json:"end"`
		Wake  string   `json:"wake"`
	} `json:"windows"`
	Exceptions []string `json:"exceptions"`
	MaxNapDays int      `json:"maxNapDays"`
}

ScheduleView is the part of a schedule the display reads (the rest is kept as the API sent it).

type Selection

type Selection struct {
	Names, Accounts, RouterRegions []string
	NameGlob                       string // *, ? and […] on the router's name
	Tags                           map[string]string
	All                            bool
}

Selection is which routers a command acts on: the names given (upgrade) narrowed by the filters. Accounts and RouterRegions are ORed within each, every filter ANDed with the others; Tags keeps the routers that serve a workload carrying all of them (the caller asks the manager for those workloads and passes their routers to Select).

func (Selection) Select

func (s Selection) Select(rs []Router, tagged map[string]bool) ([]Router, error)

Select is the routers of rs the selection keeps, in rs's order, each once (a name given twice, or named and matched by a filter, counts once). tagged is the set of routers serving workloads that carry Tags. A name that is no router's is an error.

func (Selection) Validate

func (s Selection) Validate(forUpgrade bool) error

Validate refuses what cannot be selected. An upgrade must name routers, filter them or take --all, and --all takes neither: an upgrade of everything is never the default of an empty command line.

type Skip

type Skip struct {
	Router string `json:"router"`
	Reason string `json:"reason"`
}

Skip is a router the plan leaves alone, and why.

type Step

type Step struct{ Router, From, To string }

Step is a router the plan upgrades.

type Target added in v0.5.0

type Target struct{ Router, ID string }

Target is a workload as a command names it: <router>/<id>.

func ParseTarget added in v0.5.0

func ParseTarget(s string) (Target, error)

ParseTarget reads "<router>/<id>": the router's name, then the workload's id (everything after the first slash).

func (Target) Path added in v0.5.0

func (t Target) Path(suffix string) string

Path is the target's route under /iam, with an optional suffix such as "/pause".

func (Target) String added in v0.5.0

func (t Target) String() string

type UpdateBuild added in v0.6.0

type UpdateBuild struct {
	ID         string   `json:"id"`
	By         string   `json:"by"`
	Action     string   `json:"action"`
	Version    string   `json:"version"`
	Status     string   `json:"status"`
	Phase      string   `json:"phase"`
	StartedAt  string   `json:"startedAt"`
	EndedAt    string   `json:"endedAt"`
	Steps      []string `json:"steps"`
	Tail       []string `json:"tail"`
	ConsoleURL string   `json:"consoleUrl"`
}

UpdateBuild is the install project's newest build: started by the manager (dashboard) or the CLI, its steps and, when it failed, the end of its log.

func (UpdateBuild) FailureText added in v0.6.0

func (b UpdateBuild) FailureText() string

FailureText is what a failed build says of its failure: the step that failed, the end of its log and its page in the CodeBuild console; "" for a build that did not fail.

type UpdateCheck added in v0.6.0

type UpdateCheck struct {
	Enabled   bool          `json:"enabled"`
	Alert     bool          `json:"alert"`
	Newer     bool          `json:"newer"`
	UpdatedAt string        `json:"updatedAt,omitempty"`
	UpdatedBy string        `json:"updatedBy,omitempty"`
	Result    *UpdateResult `json:"result"`
	// contains filtered or unexported fields
}

UpdateCheck is the answer of GET and PUT /update/check: the daily check's setting and its last result.

func GetUpdateCheck added in v0.6.0

func GetUpdateCheck(ctx context.Context, c *Client) (UpdateCheck, error)

GetUpdateCheck reads GET /update/check (a 404 when the manager has no daily check).

func PutUpdateCheck added in v0.6.0

func PutUpdateCheck(ctx context.Context, c *Client, enabled, alert bool) (UpdateCheck, error)

PutUpdateCheck sets the daily check: PUT /update/check, the setting as written.

func (UpdateCheck) MarshalJSON added in v0.6.0

func (u UpdateCheck) MarshalJSON() ([]byte, error)

MarshalJSON is the answer as the API sent it.

func (UpdateCheck) Text added in v0.6.0

func (u UpdateCheck) Text(loc *time.Location) string

Text is the daily check's setting and last result, times in loc.

func (*UpdateCheck) UnmarshalJSON added in v0.6.0

func (u *UpdateCheck) UnmarshalJSON(data []byte) error

type UpdatePending added in v0.6.0

type UpdatePending struct {
	ID         string `json:"id"`
	Action     string `json:"action"`
	Version    string `json:"version"`
	PlanBuild  string `json:"planBuild,omitempty"`
	At         string `json:"at"`
	Who        string `json:"who"`
	Operation  string `json:"operation,omitempty"`
	NotStarted bool   `json:"notStarted,omitempty"`
}

UpdatePending is a request waiting for its build (the answer of POST /update/plan and apply too): Operation is the update-manager operation it is recorded as; NotStarted, no build took it in time.

type UpdatePlan added in v0.6.0

type UpdatePlan struct {
	Build   string      `json:"build"`
	Version string      `json:"version"`
	Summary PlanSummary `json:"summary"`
}

UpdatePlan is the plan ready to apply: its build (what POST /update/apply takes), its version and summary.

func (UpdatePlan) Rows added in v0.6.0

func (p UpdatePlan) Rows() [][2]string

Rows are the plan as labelled lines: its version and build, what it changes, the addresses replaced and destroyed.

func (UpdatePlan) Text added in v0.6.0

func (p UpdatePlan) Text() string

Text is the plan's summary, as the Update page shows it.

type UpdateResult added in v0.6.0

type UpdateResult struct {
	CheckedAt string `json:"checkedAt"`
	Running   string `json:"running"`
	Latest    string `json:"latest"`
	Error     string `json:"error,omitempty"`
	Notified  string `json:"notified,omitempty"`
}

UpdateResult is the daily check's last result: the newest version above the one running, or why it is unknown.

type UpdateState added in v0.6.0

type UpdateState struct {
	InstalledWithCLI    bool            `json:"installedWithCli"`
	Version             string          `json:"version"`
	Env                 string          `json:"env"`
	Region              string          `json:"region"`
	Applied             *AppliedVersion `json:"applied,omitempty"`
	CLI                 string          `json:"cli,omitempty"`
	Versions            []VersionEntry  `json:"versions,omitempty"`
	Build               *UpdateBuild    `json:"build,omitempty"`
	Pending             *UpdatePending  `json:"pending,omitempty"`
	Plan                *UpdatePlan     `json:"plan,omitempty"`
	ReleasesUnreachable bool            `json:"releasesUnreachable,omitempty"`
	// contains filtered or unexported fields
}

UpdateState is the answer of GET /update. A manager not installed with the CLI (InstalledWithCLI false) gives only its version, env and region.

func GetUpdate added in v0.6.0

func GetUpdate(ctx context.Context, c *Client) (UpdateState, error)

GetUpdate reads GET /update.

func (UpdateState) MarshalJSON added in v0.6.0

func (s UpdateState) MarshalJSON() ([]byte, error)

MarshalJSON is the answer as the API sent it.

func (UpdateState) Newest added in v0.6.0

func (s UpdateState) Newest() string

Newest is the highest version offered above the running one; "" when there is none.

func (*UpdateState) UnmarshalJSON added in v0.6.0

func (s *UpdateState) UnmarshalJSON(data []byte) error

type UpgradeOptions

type UpgradeOptions struct {
	Concurrency int // at most this many upgrades run at once
	Poll        time.Duration
	Sleep       func(context.Context, time.Duration) error // ends with the context's error when it is done
	Now         func() time.Time
	Progress    func(Event) // called one at a time
}

UpgradeOptions are how Upgrade runs; Sleep and Now are injected so that tests need no real time.

type User added in v0.6.0

type User struct {
	Email     string   `json:"email"`
	Role      string   `json:"role"`
	Groups    []string `json:"groups"`
	Status    string   `json:"status"`
	Enabled   bool     `json:"enabled"`
	CreatedAt string   `json:"createdAt"`
	MFA       *bool    `json:"mfa,omitempty"`
	// contains filtered or unexported fields
}

User is a row of GET /iam/users: what the CLI reads of it. The row as the API sent it is kept, so --json prints every field.

func ListUsers added in v0.6.0

func ListUsers(ctx context.Context, c *Client) ([]User, error)

ListUsers reads GET /users.

func (User) MarshalJSON added in v0.6.0

func (u User) MarshalJSON() ([]byte, error)

MarshalJSON is the row as the API sent it, or the fields known when it was built here.

func (*User) UnmarshalJSON added in v0.6.0

func (u *User) UnmarshalJSON(data []byte) error

type VersionEntry added in v0.6.0

type VersionEntry struct {
	Version   string `json:"version"`
	Router    string `json:"router"`
	MinCLI    string `json:"minCli"`
	Published string `json:"published"`
	Staged    bool   `json:"staged,omitempty"`
	Disabled  string `json:"disabled,omitempty"`
}

VersionEntry is a version the manager can be updated to: its router version, the CLI it needs, when it was published, whether it is the release staged in the install bucket, and why it cannot be applied from the manager (Disabled).

type Workload

type Workload struct {
	WorkloadID string            `json:"workloadId"`
	Name       string            `json:"name,omitempty"`
	Router     string            `json:"router"`
	Account    string            `json:"account,omitempty"`
	Region     string            `json:"region,omitempty"`
	State      string            `json:"state"`
	Tags       map[string]string `json:"tags,omitempty"`
	StateAt    string            `json:"stateAt,omitempty"`
	UpdatedAt  string            `json:"updatedAt,omitempty"`
	Scheduled  bool              `json:"scheduled,omitempty"` // a schedule is set (manager 0.16.0)
}

Workload is a row of GET /iam/workloads. StateAt is when its state began; UpdatedAt the last change of any kind.

type WorkloadDetails added in v0.6.0

type WorkloadDetails struct {
	WorkloadID string            `json:"workloadId"`
	Name       string            `json:"name"`
	State      string            `json:"state"`
	UpdatedAt  string            `json:"updatedAt"`
	URL        string            `json:"url"`
	Account    string            `json:"account"`
	Region     string            `json:"region"`
	Tags       map[string]string `json:"tags"`
	Router     struct {
		Version string `json:"version"`
		Build   string `json:"build"`
	} `json:"router"`
	Failure *struct {
		Kind    string `json:"kind"`
		Step    string `json:"step"`
		Message string `json:"message"`
	} `json:"failure"`
	Settings struct {
		IdleMinutes        *int `json:"idleMinutes"`
		WaitSeconds        *int `json:"waitSeconds"`
		DrainSeconds       *int `json:"drainSeconds"`
		WakeTimeoutSeconds *int `json:"wakeTimeoutSeconds"`
		MaxHolders         *int `json:"maxHolders"`
	} `json:"settings"`
	Pauses         []Pause         `json:"pauses"`
	Schedule       json.RawMessage `json:"schedule"`
	Next           []NextEvent     `json:"next"`
	MaintenanceDue string          `json:"maintenanceDue"`
	States7d       *struct {
		Totals map[string]int `json:"totals"`
	} `json:"states7d"`
	IdleHours7d *float64 `json:"idleHours7d"`
	Requests7d  *int     `json:"requests7d"`
	Costs       *struct {
		SavedShare *float64 `json:"savedShare"`
		Items      []struct {
			Hourly *float64 `json:"hourly"`
		} `json:"items"`
		Saved struct {
			USD           float64 `json:"usd"`
			Hours         float64 `json:"hours"`
			UnpricedHours float64 `json:"unpricedHours"`
		} `json:"saved"`
		Discounts *struct {
			Compute   float64 `json:"compute"`
			Databases float64 `json:"databases"`
		} `json:"discounts"`
	} `json:"costs"`
	Energy *struct {
		KWh       float64 `json:"kwh"`
		CO2Kg     float64 `json:"co2Kg"`
		Estimated int     `json:"estimated"`
	} `json:"energy"`
}

WorkloadDetails is the answer of GET /iam/workloads/{router}/{id}: the router's `status` action spread with the manager's fields; what the CLI prints of it (the rest is in --json).

func (WorkloadDetails) Text added in v0.6.0

func (d WorkloadDetails) Text(router string, loc *time.Location) string

Text is the workload as labelled lines (times in loc), then its settings, pauses, schedule, last 7 days and costs.

type WorkloadHistory added in v0.6.0

type WorkloadHistory struct {
	From   string         `json:"from"`
	To     string         `json:"to"`
	Totals map[string]int `json:"totals"`
	Wakes  struct {
		Count    int  `json:"count"`
		Failed   int  `json:"failed"`
		MedianMs *int `json:"medianMs"`
		MaxMs    *int `json:"maxMs"`
	} `json:"wakes"`
	Entries   []HistoryEntry `json:"entries"`
	Truncated bool           `json:"truncated"`
	Savings   *struct {
		USD       float64           `json:"usd"`
		Items     []json.RawMessage `json:"items"`
		Unpriced  []json.RawMessage `json:"unpriced"`
		Discounts json.RawMessage   `json:"discounts"`
	} `json:"savings"`
}

WorkloadHistory is the answer of GET /iam/workloads/{router}/{id}/history: the manager's historyView with the entries it was computed from.

func (WorkloadHistory) Text added in v0.6.0

func (h WorkloadHistory) Text(loc *time.Location) string

Text is the period, the time in each state, the wakes and the savings, then the latest changes (newest first) with what started each and, for a wake, how long it took.

type Workloads

type Workloads struct {
	Rows    []Workload      `json:"workloads"`
	Total   int             `json:"total"`
	ByState map[string]int  `json:"byState,omitempty"`
	Cursor  json.RawMessage `json:"cursor,omitempty"` // null when the listing is complete
	Errors  []RouterError   `json:"errors,omitempty"`
}

Workloads is the answer of GET /iam/workloads.

func (Workloads) More

func (w Workloads) More() bool

More tells whether the answer is a page of a longer listing.

Jump to

Keyboard shortcuts

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