provider

package
v0.0.0-...-d49323b Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SchemaMap = map[string]func(uri *url.URL, logger *slog.Logger) (io.ReadWriteCloser, error){
	"http":  OpenHTTP,
	"https": OpenHTTP,
	"file":  OpenFile,
	"s3":    OpenS3,
}

Functions

func OpenFile

func OpenFile(uri *url.URL, logger *slog.Logger) (io.ReadWriteCloser, error)

OpenFile opens a local file specified by the URL and supports reading and writing. If the path is "-", it returns os.Stdin for reading or os.Stdout for writing.

func OpenHTTP

func OpenHTTP(uri *url.URL, logger *slog.Logger) (io.ReadWriteCloser, error)

OpenHTTP fetches the HTTP/HTTPS resource specified by the URL.

func OpenS3

func OpenS3(uri *url.URL, logger *slog.Logger) (io.ReadWriteCloser, error)

OpenS3 opens an S3 object for reading or reading and writing.

Types

type OpenFileMode

type OpenFileMode string

OpenFileMode represents the modes in which a file can be opened.

const (
	// ModeRead will open the file for reading.
	ModeRead OpenFileMode = "read"
	// ModeWrite will truncate the file before writing.
	ModeWrite OpenFileMode = "write"
	// ModeAppend will append to the file.
	ModeAppend OpenFileMode = "append"
)

type S3Config

type S3Config struct {
	Endpoint  string `env:"S3_ENDPOINT"`
	AccessKey string `env:"S3_ACCESS_KEY"`
	SecretKey string `env:"S3_SECRET_KEY"`
	Insecure  bool   `env:"S3_INSECURE"`
}

S3Config holds S3 configuration details.

func LoadS3Config

func LoadS3Config(query url.Values) (*S3Config, error)

LoadS3Config loads the configuration from environment variables or URL parameters.

Jump to

Keyboard shortcuts

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