s3uri

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package s3uri parses and generates URI strings for Amazon S3 resources. it is based on this original Gist by https://github.com/kwilczynski https://gist.github.com/kwilczynski/f6e626990d6d2395b42a12721b165b86

Index

Constants

View Source
const DefaultRegion = "us-east-1"

DefaultRegion contains a default region for an S3 bucket, when a region cannot be determined, for example when the s3:// schema is used or when path style URL has been given without the region component in the fully-qualified domain name.

Variables

View Source
var (
	ErrBucketNotFound    = errors.New("bucket name could not be found")
	ErrHostnameNotFound  = errors.New("hostname could not be found")
	ErrInvalidS3Endpoint = errors.New("an invalid S3 endpoint URL")
)

Functions

func Bool

func Bool(b bool) *bool

func BoolValue

func BoolValue(b *bool) bool

func String

func String(s string) *string

func StringValue

func StringValue(s *string) string

func Validate

func Validate(v any) bool

func ValidateString

func ValidateString(s string) bool

func ValidateURL

func ValidateURL(u *url.URL) bool

Types

type Option

type Option func(*S3URI)

func WithBucket

func WithBucket(s string) Option

func WithCredenials

func WithCredenials(username string, password string) Option

func WithKey

func WithKey(s string) Option

func WithNormalizedKey

func WithNormalizedKey(b bool) Option

func WithRegion

func WithRegion(s string) Option

func WithScheme

func WithScheme(s string) Option

func WithVersionID

func WithVersionID(s string) Option

type S3URI

type S3URI struct {
	HostStyle   *bool
	PathStyle   *bool
	Accelerated *bool
	DualStack   *bool
	Website     *bool

	Scheme    *string
	Bucket    *string
	Key       *string
	VersionID *string
	Region    *string

	AccessKey *string
	Secret    *string
	// contains filtered or unexported fields
}

func MustParse

func MustParse(s3u *S3URI, err error) *S3URI

func NewS3URI

func NewS3URI(opts ...Option) *S3URI

func Parse

func Parse(v any) (*S3URI, error)

func ParseString

func ParseString(s string) (*S3URI, error)

func ParseURL

func ParseURL(u *url.URL) (*S3URI, error)

func (*S3URI) GetCredentials

func (s3u *S3URI) GetCredentials() (string, string, string)

func (*S3URI) HasCredentials

func (s3u *S3URI) HasCredentials() bool

func (*S3URI) Parse

func (s3u *S3URI) Parse(v any) (*S3URI, error)

func (*S3URI) ParseString

func (s3u *S3URI) ParseString(s string) (*S3URI, error)

func (*S3URI) ParseURL

func (s3u *S3URI) ParseURL(u *url.URL) (*S3URI, error)

func (*S3URI) Reset

func (s3u *S3URI) Reset() *S3URI

func (*S3URI) URI

func (s3u *S3URI) URI() *url.URL

Jump to

Keyboard shortcuts

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