Documentation
¶
Index ¶
- Constants
- Variables
- func NewConfigStore(cfg *Config) store.Store
- func Run(ctx context.Context) error
- type AccessControlPolicy
- type BackendClient
- type BackendConfig
- type BucketConfig
- type BucketEntry
- type CLI
- type CORSConfiguration
- type CORSRuleXML
- type CommonPrefix
- type CompleteMultipartUploadResult
- type Config
- type CopyObjectResult
- type CopyPartResult
- type DeleteError
- type DeleteMarkerEntry
- type DeleteResult
- type DeletedObject
- type Grant
- type Grantee
- type InitiateMultipartUploadResult
- type KeyConfig
- type ListAllMyBucketsResult
- type ListBucketResult
- type ListBucketResultV1
- type ListMultipartUploadsResult
- type ListPartsResult
- type ListVersionsResult
- type LocationConstraint
- type Object
- type ObjectVersion
- type Owner
- type Part
- type Password
- type S3Error
- type S3RP
- type StoreConfig
- type Tag
- type TagSet
- type Tagging
- type TenantConfig
- type Upload
- type UserConfig
- type VersioningConfiguration
Constants ¶
const ( DefaultListen = ":8080" DefaultRegion = "us-east-1" )
Variables ¶
var Version = "v0.0.1"
Functions ¶
func NewConfigStore ¶
NewConfigStore builds a store.Store from a validated config.
Types ¶
type AccessControlPolicy ¶
type AccessControlPolicy struct {
XMLName xml.Name `xml:"AccessControlPolicy"`
XMLNS string `xml:"xmlns,attr"`
Owner Owner `xml:"Owner"`
AccessControlList struct {
Grants []Grant `xml:"Grant"`
} `xml:"AccessControlList"`
}
AccessControlPolicy is the response of GetBucketAcl / GetObjectAcl.
type BackendClient ¶
type BackendClient interface {
GetObject(ctx context.Context, in *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
PutObject(ctx context.Context, in *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
HeadObject(ctx context.Context, in *s3.HeadObjectInput, optFns ...func(*s3.Options)) (*s3.HeadObjectOutput, error)
DeleteObject(ctx context.Context, in *s3.DeleteObjectInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)
ListObjectsV2(ctx context.Context, in *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
HeadBucket(ctx context.Context, in *s3.HeadBucketInput, optFns ...func(*s3.Options)) (*s3.HeadBucketOutput, error)
CreateMultipartUpload(ctx context.Context, in *s3.CreateMultipartUploadInput, optFns ...func(*s3.Options)) (*s3.CreateMultipartUploadOutput, error)
UploadPart(ctx context.Context, in *s3.UploadPartInput, optFns ...func(*s3.Options)) (*s3.UploadPartOutput, error)
CompleteMultipartUpload(ctx context.Context, in *s3.CompleteMultipartUploadInput, optFns ...func(*s3.Options)) (*s3.CompleteMultipartUploadOutput, error)
AbortMultipartUpload(ctx context.Context, in *s3.AbortMultipartUploadInput, optFns ...func(*s3.Options)) (*s3.AbortMultipartUploadOutput, error)
ListParts(ctx context.Context, in *s3.ListPartsInput, optFns ...func(*s3.Options)) (*s3.ListPartsOutput, error)
ListMultipartUploads(ctx context.Context, in *s3.ListMultipartUploadsInput, optFns ...func(*s3.Options)) (*s3.ListMultipartUploadsOutput, error)
ListObjects(ctx context.Context, in *s3.ListObjectsInput, optFns ...func(*s3.Options)) (*s3.ListObjectsOutput, error)
DeleteObjects(ctx context.Context, in *s3.DeleteObjectsInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectsOutput, error)
CopyObject(ctx context.Context, in *s3.CopyObjectInput, optFns ...func(*s3.Options)) (*s3.CopyObjectOutput, error)
UploadPartCopy(ctx context.Context, in *s3.UploadPartCopyInput, optFns ...func(*s3.Options)) (*s3.UploadPartCopyOutput, error)
GetBucketVersioning(ctx context.Context, in *s3.GetBucketVersioningInput, optFns ...func(*s3.Options)) (*s3.GetBucketVersioningOutput, error)
PutBucketVersioning(ctx context.Context, in *s3.PutBucketVersioningInput, optFns ...func(*s3.Options)) (*s3.PutBucketVersioningOutput, error)
ListObjectVersions(ctx context.Context, in *s3.ListObjectVersionsInput, optFns ...func(*s3.Options)) (*s3.ListObjectVersionsOutput, error)
GetObjectTagging(ctx context.Context, in *s3.GetObjectTaggingInput, optFns ...func(*s3.Options)) (*s3.GetObjectTaggingOutput, error)
PutObjectTagging(ctx context.Context, in *s3.PutObjectTaggingInput, optFns ...func(*s3.Options)) (*s3.PutObjectTaggingOutput, error)
DeleteObjectTagging(ctx context.Context, in *s3.DeleteObjectTaggingInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectTaggingOutput, error)
}
BackendClient is the narrow interface of the S3 client methods s3rp uses, for injecting stubs in tests.
type BackendConfig ¶
Password and BackendConfig are defined in the store package; the aliases keep the config schema in one place with the rest of the config types.
type BucketConfig ¶
type BucketConfig struct {
Name string `yaml:"name" json:"name"`
Backend *BackendConfig `yaml:"backend" json:"backend"`
Policy string `yaml:"policy,omitempty" json:"policy,omitempty"` // bucket policy JSON text
CORS []*store.CORSRule `yaml:"cors,omitempty" json:"cors,omitempty"`
}
type BucketEntry ¶
type CLI ¶
type CLI struct {
Config string `help:"config file path" default:"s3rp.yaml" env:"S3RP_CONFIG"`
Listen string `help:"listen address (overrides config)" env:"S3RP_LISTEN"`
LogLevel string `help:"log level" default:"info" enum:"debug,info,warn,error" env:"S3RP_LOG_LEVEL"`
Version kong.VersionFlag `help:"show version"`
}
type CORSConfiguration ¶
type CORSConfiguration struct {
XMLName xml.Name `xml:"CORSConfiguration"`
XMLNS string `xml:"xmlns,attr"`
Rules []CORSRuleXML `xml:"CORSRule"`
}
CORSConfiguration is the response of GetBucketCors.
type CORSRuleXML ¶
type CommonPrefix ¶
type CommonPrefix struct {
Prefix string `xml:"Prefix"`
}
type CompleteMultipartUploadResult ¶
type CompleteMultipartUploadResult struct {
XMLName xml.Name `xml:"CompleteMultipartUploadResult"`
XMLNS string `xml:"xmlns,attr"`
Location string `xml:"Location"`
Bucket string `xml:"Bucket"`
Key string `xml:"Key"`
ETag string `xml:"ETag"`
ChecksumCRC32 string `xml:"ChecksumCRC32,omitempty"`
ChecksumCRC32C string `xml:"ChecksumCRC32C,omitempty"`
ChecksumCRC64NVME string `xml:"ChecksumCRC64NVME,omitempty"`
ChecksumSHA1 string `xml:"ChecksumSHA1,omitempty"`
ChecksumSHA256 string `xml:"ChecksumSHA256,omitempty"`
ChecksumType string `xml:"ChecksumType,omitempty"`
}
CompleteMultipartUploadResult is the response of CompleteMultipartUpload.
type Config ¶
type Config struct {
Listen string `yaml:"listen" json:"listen"`
Store *StoreConfig `yaml:"store,omitempty" json:"store,omitempty"`
Tenants []*TenantConfig `yaml:"tenants,omitempty" json:"tenants,omitempty"`
}
func LoadConfig ¶
LoadConfig reads a YAML config file, expanding environment variables in the content.
func (*Config) SetDefaults ¶
func (c *Config) SetDefaults()
func (*Config) StoreDriver ¶
StoreDriver returns the effective store driver.
type CopyObjectResult ¶
type CopyObjectResult struct {
XMLName xml.Name `xml:"CopyObjectResult"`
XMLNS string `xml:"xmlns,attr"`
ETag string `xml:"ETag"`
LastModified string `xml:"LastModified,omitempty"`
}
CopyObjectResult is the response of CopyObject.
type CopyPartResult ¶
type CopyPartResult struct {
XMLName xml.Name `xml:"CopyPartResult"`
XMLNS string `xml:"xmlns,attr"`
ETag string `xml:"ETag"`
LastModified string `xml:"LastModified,omitempty"`
}
CopyPartResult is the response of UploadPartCopy.
type DeleteError ¶
type DeleteMarkerEntry ¶
type DeleteResult ¶
type DeleteResult struct {
XMLName xml.Name `xml:"DeleteResult"`
XMLNS string `xml:"xmlns,attr"`
Deleted []DeletedObject `xml:"Deleted"`
Errors []DeleteError `xml:"Error"`
}
DeleteResult is the response of DeleteObjects.
type DeletedObject ¶
type InitiateMultipartUploadResult ¶
type InitiateMultipartUploadResult struct {
XMLName xml.Name `xml:"InitiateMultipartUploadResult"`
XMLNS string `xml:"xmlns,attr"`
Bucket string `xml:"Bucket"`
Key string `xml:"Key"`
UploadID string `xml:"UploadId"`
}
InitiateMultipartUploadResult is the response of CreateMultipartUpload.
type ListAllMyBucketsResult ¶
type ListAllMyBucketsResult struct {
XMLName xml.Name `xml:"ListAllMyBucketsResult"`
XMLNS string `xml:"xmlns,attr"`
Owner Owner `xml:"Owner"`
Buckets struct {
Bucket []BucketEntry `xml:"Bucket"`
} `xml:"Buckets"`
}
ListAllMyBucketsResult is the response of ListBuckets.
type ListBucketResult ¶
type ListBucketResult struct {
XMLName xml.Name `xml:"ListBucketResult"`
XMLNS string `xml:"xmlns,attr"`
Name string `xml:"Name"`
Prefix string `xml:"Prefix"`
StartAfter string `xml:"StartAfter,omitempty"`
ContinuationToken string `xml:"ContinuationToken,omitempty"`
NextContinuationToken string `xml:"NextContinuationToken,omitempty"`
KeyCount int32 `xml:"KeyCount"`
MaxKeys int32 `xml:"MaxKeys"`
Delimiter string `xml:"Delimiter,omitempty"`
EncodingType string `xml:"EncodingType,omitempty"`
IsTruncated bool `xml:"IsTruncated"`
Contents []Object `xml:"Contents"`
CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"`
}
ListBucketResult is the response of ListObjectsV2.
type ListBucketResultV1 ¶
type ListBucketResultV1 struct {
XMLName xml.Name `xml:"ListBucketResult"`
XMLNS string `xml:"xmlns,attr"`
Name string `xml:"Name"`
Prefix string `xml:"Prefix"`
Marker string `xml:"Marker"`
NextMarker string `xml:"NextMarker,omitempty"`
MaxKeys int32 `xml:"MaxKeys"`
Delimiter string `xml:"Delimiter,omitempty"`
EncodingType string `xml:"EncodingType,omitempty"`
IsTruncated bool `xml:"IsTruncated"`
Contents []Object `xml:"Contents"`
CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"`
}
ListBucketResultV1 is the response of ListObjects (version 1).
type ListMultipartUploadsResult ¶
type ListMultipartUploadsResult struct {
XMLName xml.Name `xml:"ListMultipartUploadsResult"`
XMLNS string `xml:"xmlns,attr"`
Bucket string `xml:"Bucket"`
KeyMarker string `xml:"KeyMarker,omitempty"`
UploadIDMarker string `xml:"UploadIdMarker,omitempty"`
NextKeyMarker string `xml:"NextKeyMarker,omitempty"`
NextUploadIDMarker string `xml:"NextUploadIdMarker,omitempty"`
Delimiter string `xml:"Delimiter,omitempty"`
Prefix string `xml:"Prefix,omitempty"`
MaxUploads int32 `xml:"MaxUploads"`
IsTruncated bool `xml:"IsTruncated"`
Uploads []Upload `xml:"Upload"`
CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"`
}
ListMultipartUploadsResult is the response of ListMultipartUploads.
type ListPartsResult ¶
type ListPartsResult struct {
XMLName xml.Name `xml:"ListPartsResult"`
XMLNS string `xml:"xmlns,attr"`
Bucket string `xml:"Bucket"`
Key string `xml:"Key"`
UploadID string `xml:"UploadId"`
PartNumberMarker string `xml:"PartNumberMarker,omitempty"`
NextPartNumberMarker string `xml:"NextPartNumberMarker,omitempty"`
MaxParts int32 `xml:"MaxParts"`
IsTruncated bool `xml:"IsTruncated"`
Parts []Part `xml:"Part"`
Initiator *Owner `xml:"Initiator,omitempty"`
Owner *Owner `xml:"Owner,omitempty"`
StorageClass string `xml:"StorageClass,omitempty"`
}
ListPartsResult is the response of ListParts.
type ListVersionsResult ¶
type ListVersionsResult struct {
XMLName xml.Name `xml:"ListVersionsResult"`
XMLNS string `xml:"xmlns,attr"`
Name string `xml:"Name"`
Prefix string `xml:"Prefix"`
KeyMarker string `xml:"KeyMarker"`
VersionIDMarker string `xml:"VersionIdMarker"`
NextKeyMarker string `xml:"NextKeyMarker,omitempty"`
NextVersionIDMarker string `xml:"NextVersionIdMarker,omitempty"`
MaxKeys int32 `xml:"MaxKeys"`
Delimiter string `xml:"Delimiter,omitempty"`
EncodingType string `xml:"EncodingType,omitempty"`
IsTruncated bool `xml:"IsTruncated"`
Versions []ObjectVersion `xml:"Version"`
DeleteMarkers []DeleteMarkerEntry `xml:"DeleteMarker"`
CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"`
}
ListVersionsResult is the response of ListObjectVersions.
type LocationConstraint ¶
type LocationConstraint struct {
XMLName xml.Name `xml:"LocationConstraint"`
XMLNS string `xml:"xmlns,attr"`
Value string `xml:",chardata"`
}
LocationConstraint is the response of GetBucketLocation.
type ObjectVersion ¶
type ObjectVersion struct {
Key string `xml:"Key"`
VersionID string `xml:"VersionId"`
IsLatest bool `xml:"IsLatest"`
LastModified string `xml:"LastModified,omitempty"`
ETag string `xml:"ETag"`
Size int64 `xml:"Size"`
StorageClass string `xml:"StorageClass,omitempty"`
Owner *Owner `xml:"Owner,omitempty"`
}
type Password ¶
Password and BackendConfig are defined in the store package; the aliases keep the config schema in one place with the rest of the config types.
type S3Error ¶
type S3Error struct {
XMLName xml.Name `xml:"Error"`
Code string `xml:"Code"`
Message string `xml:"Message"`
Resource string `xml:"Resource,omitempty"`
RequestID string `xml:"RequestId,omitempty"`
// contains filtered or unexported fields
}
S3Error is an S3 API error response. https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html
type S3RP ¶
type S3RP struct {
// contains filtered or unexported fields
}
S3RP is an S3 API reverse proxy that verifies SigV4 signatures with front-side access keys and forwards operations to per-bucket backends.
func New ¶
New creates an S3RP from a config, selecting the definition store by the store.driver setting.
func NewWithStore ¶
NewWithStore creates an S3RP using the given Store for tenant, key and bucket definitions.
type StoreConfig ¶
type StoreConfig struct {
Driver string `yaml:"driver" json:"driver"` // "yaml" (default) or "sqlite"
DSN string `yaml:"dsn,omitempty" json:"dsn,omitempty"`
}
StoreConfig selects where tenant/user/bucket definitions come from.
type Tagging ¶
type Tagging struct {
XMLName xml.Name `xml:"Tagging"`
XMLNS string `xml:"xmlns,attr,omitempty"`
TagSet TagSet `xml:"TagSet"`
}
Tagging is the request and response body of PutObjectTagging / GetObjectTagging.
type TenantConfig ¶
type TenantConfig struct {
Name string `yaml:"name" json:"name"`
Users []*UserConfig `yaml:"users" json:"users"`
Buckets []*BucketConfig `yaml:"buckets" json:"buckets"`
}
TenantConfig defines a tenant: its users and the buckets it owns.
type UserConfig ¶
type UserConfig struct {
Name string `yaml:"name" json:"name"`
Keys []*KeyConfig `yaml:"keys" json:"keys"`
}
UserConfig defines a user of a tenant. The user name is the stable identity (e.g. for policy principals); access keys rotate under it.
type VersioningConfiguration ¶
type VersioningConfiguration struct {
XMLName xml.Name `xml:"VersioningConfiguration"`
XMLNS string `xml:"xmlns,attr,omitempty"`
Status string `xml:"Status,omitempty"`
}
VersioningConfiguration is the request and response body of PutBucketVersioning / GetBucketVersioning.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
s3rp
command
|
|
|
s3rp-admin
command
s3rp-admin is the write-side tooling for the s3rp database: schema migration and importing a YAML config.
|
s3rp-admin is the write-side tooling for the s3rp database: schema migration and importing a YAML config. |
|
Package db holds the shared schema and the write-side operations (migration and importing a YAML config).
|
Package db holds the shared schema and the write-side operations (migration and importing a YAML config). |
|
Package policy implements AWS-style bucket policy documents for s3rp.
|
Package policy implements AWS-style bucket policy documents for s3rp. |
|
Package store defines the read-only contract for tenant, key and bucket definitions used by s3rp.
|
Package store defines the read-only contract for tenant, key and bucket definitions used by s3rp. |
|
rdb
Package rdb is a read-only store.Store implementation backed by a relational database (sqlite for the PoC), using the sqlc-generated queries in the readdb package.
|
Package rdb is a read-only store.Store implementation backed by a relational database (sqlite for the PoC), using the sqlc-generated queries in the readdb package. |