uri

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package uri provides parsing of cloud object-storage URIs in the scheme-bucket-key/prefix/pattern shape used throughout gonimbus.

Supported schemes as of v0.3.x: s3, gs, file.

Glob pattern characters in the key, including *, ?, [, ], {, }, and **, are recognized and surface via ObjectURI.IsPattern. The original pattern is preserved in ObjectURI.Pattern; the longest pre-glob listing prefix is available in ObjectURI.Key. Escaped glob metacharacters are treated as literal key characters, and non-pattern keys are unescaped for object-store lookup.

API stability: Stable. Breaking changes to exported symbols or documented behavior follow the Library API protocol in docs/api-stability.md.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidURI indicates the URI could not be parsed.
	ErrInvalidURI = errors.New("invalid URI")

	// ErrUnsupportedProvider indicates the URI scheme is not supported.
	ErrUnsupportedProvider = errors.New("unsupported provider")

	// ErrMissingBucket indicates the URI is missing a bucket name.
	ErrMissingBucket = errors.New("missing bucket name")

	// ErrInvalidFileURI indicates a file:// URI is not a supported local absolute path.
	ErrInvalidFileURI = errors.New("invalid file URI")
)

URI parsing errors

Functions

This section is empty.

Types

type ObjectURI

type ObjectURI struct {
	// Provider is the storage provider (e.g., "s3" or "file").
	Provider string

	// Bucket is the bucket name. For file:// URIs this is the sentinel "local".
	Bucket string

	// Key is the object key or prefix. For file:// URIs this is the absolute
	// local filesystem path.
	Key string

	// Pattern is set if Key contains glob characters.
	// When set, Key is the prefix before the first glob character.
	Pattern string
}

ObjectURI represents a parsed object URI.

Example URIs:

  • s3://bucket/key/path.txt
  • gs://bucket/key/path.txt
  • s3://bucket/prefix/
  • s3://bucket/prefix/**/*.parquet
  • file:///absolute/path

func ParseURI

func ParseURI(uri string) (*ObjectURI, error)

ParseURI parses a cloud storage URI into its components.

Supported formats:

  • s3://bucket
  • s3://bucket/
  • s3://bucket/key
  • s3://bucket/prefix/
  • s3://bucket/prefix/**/*.parquet
  • gs://bucket/key
  • file:///absolute/path
  • file:///absolute/path/

Returns an error if the URI is malformed or uses an unsupported provider.

func (*ObjectURI) IsPattern

func (u *ObjectURI) IsPattern() bool

IsPattern returns true if the URI contains glob pattern characters.

func (*ObjectURI) IsPrefix

func (u *ObjectURI) IsPrefix() bool

IsPrefix returns true if the URI represents a prefix (ends with /).

func (*ObjectURI) String

func (u *ObjectURI) String() string

String returns the URI in canonical form.

Jump to

Keyboard shortcuts

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