objects

package
v1.46.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBucketNameNotUnique = errRange.New(
		"Duplicate bucket name",
		"An object storage bucket name must be unique.",

		errors.PrependDetails("If you wish to reuse the same bucket, then you can export the original Bucket object and reference it from here."),
	)

	ErrUnsupportedOperationOutsideService = errRange.Newf(
		"Unsupported bucket operation outside of service",
		"The %s operation can only be performed within a service. Use objects.BucketRef to pass the bucket reference to other, non-service components.",
	)

	ErrBucketRefOutsideService = errRange.New(
		"Call to objects.BucketRef outside service",
		"objects.BucketRef can only be called from within a service.",
	)

	ErrBucketNotPublic = errRange.New(
		"Call to PublicURL for non-public objects.Bucket",
		"The PublicURL method can only be called on a public bucket.",
	)
)
View Source
var BucketParser = &resourceparser.Parser{
	Name: "Bucket",

	InterestingImports: []paths.Pkg{"encore.dev/storage/objects"},
	Run: func(p *resourceparser.Pass) {
		name := pkginfo.QualifiedName{Name: "NewBucket", PkgPath: "encore.dev/storage/objects"}

		spec := &parseutil.ReferenceSpec{
			MinTypeArgs: 0,
			MaxTypeArgs: 0,
			Parse:       parseBucket,
		}

		parseutil.FindPkgNameRefs(p.Pkg, []pkginfo.QualifiedName{name}, func(file *pkginfo.File, name pkginfo.QualifiedName, stack []ast.Node) {
			parseutil.ParseReference(p, spec, parseutil.ReferenceData{
				File:         file,
				Stack:        stack,
				ResourceFunc: name,
			})
		})
	},
}

Functions

func ResolveBucketUsage

func ResolveBucketUsage(data usage.ResolveData, bkt *Bucket) usage.Usage

Types

type Bucket

type Bucket struct {
	AST       *ast.CallExpr
	File      *pkginfo.File
	Name      string // The unique name of the bucket
	Doc       string // The documentation on the bucket
	Versioned bool
	Public    bool
}

func (*Bucket) ASTExpr

func (t *Bucket) ASTExpr() ast.Expr

func (*Bucket) End

func (t *Bucket) End() token.Pos

func (*Bucket) Kind

func (t *Bucket) Kind() resource.Kind

func (*Bucket) Package

func (t *Bucket) Package() *pkginfo.Package

func (*Bucket) Pos

func (t *Bucket) Pos() token.Pos

func (*Bucket) ResourceName

func (t *Bucket) ResourceName() string

func (*Bucket) SortKey

func (t *Bucket) SortKey() string

type MethodUsage

type MethodUsage struct {
	usage.Base
	Method string
	Perm   Perm
}

type Perm

type Perm string
const (
	ListObjects          Perm = "list-objects"
	ReadObjectContents   Perm = "read-object-contents"
	WriteObject          Perm = "write-object"
	UpdateObjectMetadata Perm = "update-object-metadata"
	GetObjectMetadata    Perm = "get-object-metadata"
	DeleteObject         Perm = "delete-object"
	GetPublicURL         Perm = "get-public-url"
	SignedUploadURL      Perm = "signed-upload-url"
	SignedDownloadURL    Perm = "signed-download-url"
)

func (Perm) ToMeta

func (p Perm) ToMeta() (meta.BucketUsage_Operation, bool)

type RefUsage

type RefUsage struct {
	usage.Base
	Perms []Perm
}

func (*RefUsage) HasPerm

func (u *RefUsage) HasPerm(perm Perm) bool

Jump to

Keyboard shortcuts

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