Documentation
¶
Overview ¶
Package s3 implements `lsh s3`, the object storage command group. It mixes control-plane calls to the Latitude API (buckets, access keys, lifecycle, metrics, usage) with data-plane calls straight to the bucket's S3 endpoint (list, copy, move, delete, get, presign), using the verbs and flags of `aws s3` so existing habits and scripts carry over.
Index ¶
- func BucketRows(data []components.ObjectStorageData, sites map[string]string) []renderer.ResponseData
- func Finalize(root *cobra.Command)
- func NewAccessKeysCmd() *cobra.Command
- func NewConfigureCmd() *cobra.Command
- func NewCpCmd() *cobra.Command
- func NewGroupCmd() *cobra.Command
- func NewLegacyAliasCmd(root *cobra.Command) *cobra.Command
- func NewLifecycleCmd() *cobra.Command
- func NewLsCmd() *cobra.Command
- func NewMbCmd() *cobra.Command
- func NewMetricsCmd() *cobra.Command
- func NewMvCmd() *cobra.Command
- func NewPresignCmd() *cobra.Command
- func NewRbCmd() *cobra.Command
- func NewRmCmd() *cobra.Command
- func NewStatCmd() *cobra.Command
- func NewSyncCmd() *cobra.Command
- func NewUsageCmd() *cobra.Command
- type BucketRow
- type LifecycleMutation
- type LifecycleRule
- type MetricsRow
- type Session
- type UsageRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BucketRows ¶
func BucketRows(data []components.ObjectStorageData, sites map[string]string) []renderer.ResponseData
BucketRows converts SDK payloads into renderable rows.
func Finalize ¶
Finalize walks the group's command tree and installs the shared error contract on every command:
- errors raised by cobra itself (bad flag, wrong argument count) are printed once and exit 2;
- errors returned by PreRunE/RunE are printed once through printErr (exit code preserved) and cobra is told not to echo them again.
build_s3.go calls it after attaching the subcommands.
func NewAccessKeysCmd ¶
NewAccessKeysCmd builds `lsh s3 access-keys` (alias `keys`): the S3 credentials of a project, managed through the Latitude API and optionally saved in the local profile so the data-plane commands pick them up.
func NewConfigureCmd ¶
NewConfigureCmd builds `lsh s3 configure` (alias `credentials`): the interactive equivalent of `aws configure` for S3 access keys.
func NewGroupCmd ¶
NewGroupCmd builds the `s3` group. Subcommands are attached by cmd/build_s3.go so each lives in its own file.
The canonical verbs follow the rest of the CLI (list, get, copy, move, delete, create-bucket, delete-bucket); the short S3 spellings (ls, stat, cp, mv, rm, mb, rb) are aliases, so both vocabularies work and the help reads in the CLI's own terms.
func NewLegacyAliasCmd ¶
NewLegacyAliasCmd returns the hidden `storage-objects` command kept for scripts written against the group this one replaced. Cobra prints the deprecation notice on stderr and leaves the command out of the help; the arguments are re-dispatched to `lsh s3` untouched (flag parsing is disabled here so nothing is interpreted before it reaches the real command).
Two legacy verbs changed meaning and are called out in the notice: `rm` and `delete` remove objects now, and a bucket is removed with `delete-bucket`.
func NewLifecycleCmd ¶
NewLifecycleCmd builds `lsh s3 lifecycle`, the bucket lifecycle rule group (list, get, create, update, delete). Rules are managed through the Latitude API; the bucket may be given as s3://<bucket> or <bucket>.
func NewMetricsCmd ¶
NewMetricsCmd builds `lsh s3 metrics [s3://bucket]`.
func NewPresignCmd ¶
NewPresignCmd builds `lsh s3 presign s3://bucket/key`.
func NewStatCmd ¶
NewStatCmd builds `lsh s3 get s3://bucket[/key]`.
func NewSyncCmd ¶
NewSyncCmd builds `lsh s3 sync <source> <destination>`.
Types ¶
type BucketRow ¶
type BucketRow struct {
components.ObjectStorageData
// Site is the Latitude site slug when known (the SDK model drops it).
Site string `json:"-"`
// contains filtered or unexported fields
}
BucketRow wraps the SDK bucket payload so the shared renderer can print it (-o table|json|yaml|csv, --query). JSON output is the API document as-is.
func NewBucketRow ¶
func NewBucketRow(b *objectstorage.Bucket) *BucketRow
NewBucketRow builds a row from a resolved bucket.
func (*BucketRow) MarshalJSON ¶
MarshalJSON emits the API document plus the site slug (which the SDK model drops) so `-o json` carries everything `stat` shows.
type LifecycleMutation ¶
type LifecycleMutation struct {
// Action is create, update or delete.
Action string `json:"action"`
Bucket string `json:"bucket"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
Error string `json:"error,omitempty"`
}
LifecycleMutation is the structured result of create/update/delete (create/update render the resulting rule; delete and dry-runs render this).
func (LifecycleMutation) HumanLine ¶
func (m LifecycleMutation) HumanLine() string
HumanLine renders the aws-style single line: `lifecycle: created <id> (<name>)`, or `(dryrun) lifecycle: create <name> on s3://bucket` for a dry-run.
func (LifecycleMutation) TableRow ¶
func (m LifecycleMutation) TableRow() table.Row
type LifecycleRule ¶
type LifecycleRule struct {
components.LifecycleRuleData
}
LifecycleRule wraps the SDK payload so the shared renderer can print it (-o table|json|yaml|csv, --query). JSON output is the API document as-is.
func (LifecycleRule) RuleID ¶
func (r LifecycleRule) RuleID() string
RuleID returns the rule id or "".
func (LifecycleRule) RuleName ¶
func (r LifecycleRule) RuleName() string
RuleName returns the rule name or "".
func (LifecycleRule) TableRow ¶
func (r LifecycleRule) TableRow() table.Row
TableRow renders the rule as a table row: id, name, prefix, expiration, noncurrent, abort-mpu and enabled.
type MetricsRow ¶
type MetricsRow struct {
Bucket string `json:"bucket"`
ID string `json:"id"`
Project string `json:"project,omitempty"`
StorageClass string `json:"storage_class,omitempty"`
Site string `json:"site,omitempty"`
CurrentGB *int64 `json:"current_gb"`
ConsumedGB *int64 `json:"consumed_gb"`
Unit string `json:"unit,omitempty"`
CostAmount *float64 `json:"estimated_cost"`
Currency string `json:"currency,omitempty"`
PeriodStart *time.Time `json:"period_start,omitempty"`
PeriodEnd *time.Time `json:"period_end,omitempty"`
// Total marks the aggregated row appended in table mode.
Total bool `json:"-"`
// contains filtered or unexported fields
}
MetricsRow is one bucket's consumption and estimated cost for the current billing period, as returned by GET /storage/buckets/{id}/metrics.
func (MetricsRow) TableRow ¶
func (m MetricsRow) TableRow() table.Row
type Session ¶
type Session struct {
Bucket *objectstorage.Bucket
Cred objectstorage.Credential
Client *minio.Client
}
Session bundles everything a data-plane command needs for one bucket.
type UsageRow ¶
type UsageRow struct {
Date string `json:"date,omitempty"`
Project string `json:"project,omitempty"`
Bucket string `json:"bucket,omitempty"`
StorageID string `json:"storage_id,omitempty"`
Tier string `json:"tier,omitempty"`
Region string `json:"region,omitempty"`
// Bytes is the sum of the daily samples in the group (byte-days when the
// group spans several days).
Bytes int64 `json:"bytes"`
// Days is the number of distinct days in the group; AvgBytes = Bytes/Days.
Days int `json:"days,omitempty"`
AvgBytes int64 `json:"avg_bytes,omitempty"`
Size string `json:"size,omitempty"` // human size of Bytes (-H only)
AvgSize string `json:"avg_size,omitempty"` // human size of AvgBytes (-H only)
// contains filtered or unexported fields
}
UsageRow is an aggregated usage record (one per group key).
Source Files
¶
- accesskeys.go
- accesskeys_create.go
- accesskeys_delete.go
- accesskeys_forget.go
- accesskeys_get.go
- accesskeys_import.go
- accesskeys_list.go
- accesskeys_rotate.go
- accesskeys_shared.go
- bucket_render.go
- configure.go
- configure_export.go
- cp.go
- lifecycle.go
- lifecycle_create.go
- lifecycle_delete.go
- lifecycle_get.go
- lifecycle_list.go
- lifecycle_update.go
- ls.go
- mb.go
- metrics.go
- mv.go
- petname.go
- presign.go
- rb.go
- rm.go
- s3.go
- stat.go
- sync.go
- transfer.go
- usage.go