s3

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: BSD-3-Clause, MIT Imports: 42 Imported by: 0

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

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

func Finalize(root *cobra.Command)

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

func NewAccessKeysCmd() *cobra.Command

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

func NewConfigureCmd() *cobra.Command

NewConfigureCmd builds `lsh s3 configure` (alias `credentials`): the interactive equivalent of `aws configure` for S3 access keys.

func NewCpCmd

func NewCpCmd() *cobra.Command

NewCpCmd builds `lsh s3 copy <source> <destination>`.

func NewGroupCmd

func NewGroupCmd() *cobra.Command

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

func NewLegacyAliasCmd(root *cobra.Command) *cobra.Command

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

func NewLifecycleCmd() *cobra.Command

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 NewLsCmd

func NewLsCmd() *cobra.Command

NewLsCmd builds `lsh s3 list [s3://bucket[/prefix]]`.

func NewMbCmd

func NewMbCmd() *cobra.Command

NewMbCmd builds `lsh s3 create-bucket s3://bucket`.

func NewMetricsCmd

func NewMetricsCmd() *cobra.Command

NewMetricsCmd builds `lsh s3 metrics [s3://bucket]`.

func NewMvCmd

func NewMvCmd() *cobra.Command

NewMvCmd builds `lsh s3 move <source> <destination>`.

func NewPresignCmd

func NewPresignCmd() *cobra.Command

NewPresignCmd builds `lsh s3 presign s3://bucket/key`.

func NewRbCmd

func NewRbCmd() *cobra.Command

NewRbCmd builds `lsh s3 delete-bucket s3://bucket`.

func NewRmCmd

func NewRmCmd() *cobra.Command

NewRmCmd builds `lsh s3 delete s3://bucket/key`.

func NewStatCmd

func NewStatCmd() *cobra.Command

NewStatCmd builds `lsh s3 get s3://bucket[/key]`.

func NewSyncCmd

func NewSyncCmd() *cobra.Command

NewSyncCmd builds `lsh s3 sync <source> <destination>`.

func NewUsageCmd

func NewUsageCmd() *cobra.Command

NewUsageCmd builds `lsh s3 usage`.

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

func (m *BucketRow) MarshalJSON() ([]byte, error)

MarshalJSON emits the API document plus the site slug (which the SDK model drops) so `-o json` carries everything `stat` shows.

func (*BucketRow) TableRow

func (m *BucketRow) TableRow() table.Row

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).

func (UsageRow) TableRow

func (u UsageRow) TableRow() table.Row

Jump to

Keyboard shortcuts

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