Documentation
¶
Overview ¶
Package cli is the estimate command (vision docs/specs/2026-10-10-savings-estimate-design.md §3, §8): the options, the accounts, the three phases with their progress, the reports and the summary. Exit code 0; 1 when AWS refuses (credentials, an organization call); 2 on a bad option (accounts given that cannot be estimated too). AWS comes through EstimateAWS (aws.go wires the SDK; the tests, fakes).
Ports manager packages/estimate/src/cli.ts (EstimateAws, CliDeps, main).
Index ¶
Constants ¶
const Interrupted = 130
Interrupted is the exit code of a run stopped by Ctrl-C (its context cancelled): 128 + SIGINT, what a shell reports for the Node estimate, killed by the signal. Nothing is said, no report is written.
Variables ¶
This section is empty.
Functions ¶
func Main ¶
Main runs the estimate command with its arguments (those after "estimate") and returns its exit code: 0; 2 with the message and the usage for a bad option, or the message for accounts given that cannot be estimated (known once AWS answered); 1 with `name: message` for anything else (credentials that do not work, an organization call AWS refuses), on one line, AWS's words without the SDK's wrappers (awserr.Cause), and for an SSO token error a second line, `Run aws sso login --profile <profile> and try again.`; Interrupted when the context is cancelled. --help prints the usage (exit code 0). A panic is said as `Error: <its value>`, exit code 1, without a goroutine dump (F6: Node says `TypeError: …` and exits 1); a worker's is its item's error (limit.Map).
func StatusOf ¶
StatusOf is the Status of out when it is a terminal (the command's stdout), else nil: a line per account or region.
Types ¶
type Deps ¶
type Deps struct {
// Context is the run's: cancelled on Ctrl-C (nil: never).
Context context.Context
Now func() time.Time
CacheRoot string
Log func(line string)
Error func(line string)
// AWS is each profile's: an account is read with the profile reaching it.
AWS func(o options.Options, profile string) EstimateAWS
// WriteFile writes a report (nil: the file is written, its directory made).
WriteFile func(path, text string) error
// Status is a terminal's: each phase's progress on one line rewritten in place (nil: a line per account or region).
Status progress.Status
// Version is the JSON report's tool version.
Version string
}
Deps are the command's dependencies (Node's CliDeps).
type EstimateAWS ¶
type EstimateAWS struct {
Accounts accounts.Ports
RegionsOf func(ctx context.Context, account string, creds *aws.Credentials) ([]string, error)
PortsOf func(ctx context.Context, account, region string, creds *aws.Credentials) (discover.RegionPorts, error)
CloudWatchOf func(ctx context.Context, account, region string, creds *aws.Credentials) (metrics.CloudWatchPort, error)
Prices func(cache prices.Cache) PriceBook
}
EstimateAWS is one profile's AWS (Node's EstimateAws): the accounts it reaches, an account's enabled regions, the ports of an account's region, its CloudWatch, and the price book. creds nil: the profile's own.
func AWSOf ¶
func AWSOf(_ options.Options, profile string) EstimateAWS
AWSOf is one profile's AWS (several are given with --profile a,b, each reaching its accounts): its shared configuration, read now; its credentials resolved when a call needs them. A profile that cannot be loaded (missing from the config) fails every call with the SDK's message: the first, who the profile is, gives exit code 1.
type PriceBook ¶
type PriceBook struct {
Hourly func(ctx context.Context, region string, item stopped.Item, d prices.Discounts) (*float64, error)
Failure func() string
}
PriceBook is the price book the estimate reads: an item's hourly price in a region, net of the discounts (nil: no price), and the first price lookup AWS refused, said as `name: message` (Failure nil or "": none), so the unpriced workloads say why.