fetchers

package
v0.0.0-...-12687f4 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SecuritySourceBackground is used when security is set from the compute instance level
	SecuritySourceBackground = "background"
	// SecuritySourceFile is used when security is set by JWT config from a JSON file
	SecuritySourceFile = "file"
)

Variables

This section is empty.

Functions

func InitFetchers

func InitFetchers(cfg *config.Config)

InitFetchers initializes fetchers from config

Types

type Fetcher

type Fetcher interface {
	GetName() string
	GetFetcherType() string
	Fetch(ctx echo.Context, url string) (responseBody io.Reader, contentType string, err error)
}

Fetcher interface handles fetching content from different sources

func GetFetcherByName

func GetFetcherByName(name string) Fetcher

GetFetcherByName returns a fetcher by its configured name

func GetFetcherByPath

func GetFetcherByPath(path string) Fetcher

GetFetcherByPath returns the fetcher specified by its path

func GetFetcherByType

func GetFetcherByType(fetcherType string) Fetcher

GetFetcherByType returns the fetcher specified by its type

type GoogleStroageFetcher

type GoogleStroageFetcher struct {
	Name        string
	FetcherType string
	Bucket      string
	Path        string

	ProjectID              string
	SecuritySource         string
	ServiceAccountJSONFile string
}

GoogleStroageFetcher fetches content from http/https sources

URL Format used: gs://bucketName/path/file

func NewGoogleStroageFetcher

func NewGoogleStroageFetcher(cfg map[string]interface{}) *GoogleStroageFetcher

NewGoogleStroageFetcher creates a new fetcher that support Google Storage buckets

func (*GoogleStroageFetcher) Fetch

func (fetcher *GoogleStroageFetcher) Fetch(c echo.Context, url string) (io.Reader, string, error)

Fetch returns content from the local machine

func (*GoogleStroageFetcher) GetFetcherType

func (fetcher *GoogleStroageFetcher) GetFetcherType() string

GetFetcherType returns the type of this fetcher to be used in the 'type' properties when defining fetchers

func (*GoogleStroageFetcher) GetName

func (fetcher *GoogleStroageFetcher) GetName() string

GetName returns the name assigned to this fetcher that can be used in the 'paths' section

type HTTPFetcher

type HTTPFetcher struct {
	Name        string
	FetcherType string

	UserName string
	Password string

	Secure        bool
	RestrictHosts []string
	RestrictPaths []string
}

HTTPFetcher fetches content from http/https sources

func NewHTTPFetcher

func NewHTTPFetcher(cfg map[string]interface{}) *HTTPFetcher

NewHTTPFetcher creates a new fetcher that support http/https

func (*HTTPFetcher) Fetch

func (fetcher *HTTPFetcher) Fetch(c echo.Context, url string) (io.Reader, string, error)

Fetch returns content from http/https sources

func (*HTTPFetcher) GetFetcherType

func (fetcher *HTTPFetcher) GetFetcherType() string

GetFetcherType returns the type of this fetcher to be used in the 'type' properties when defining fetchers

func (*HTTPFetcher) GetName

func (fetcher *HTTPFetcher) GetName() string

GetName returns the name assigned to this fetcher that can be used in the 'paths' section

type LocalFetcher

type LocalFetcher struct {
	Name        string
	FetcherType string

	Path string
}

LocalFetcher fetches content from http/https sources

func NewLocalFetcher

func NewLocalFetcher(cfg map[string]interface{}) *LocalFetcher

NewLocalFetcher creates a new fetcher that support http/https

func (*LocalFetcher) Fetch

func (fetcher *LocalFetcher) Fetch(c echo.Context, url string) (io.Reader, string, error)

Fetch returns content from the local machine

func (*LocalFetcher) GetFetcherType

func (fetcher *LocalFetcher) GetFetcherType() string

GetFetcherType returns the type of this fetcher to be used in the 'type' properties when defining fetchers

func (*LocalFetcher) GetName

func (fetcher *LocalFetcher) GetName() string

GetName returns the name assigned to this fetcher that can be used in the 'paths' section

type S3Fetcher

type S3Fetcher struct {
	Name            string
	FetcherType     string
	Region          string
	AccessKeyID     string
	SecretAccessKey string
}

S3Fetcher fetches content from an s3 bucket

func NewS3Fetcher

func NewS3Fetcher(cfg map[string]interface{}) *S3Fetcher

NewS3Fetcher creates a new fetcher that support s3 bucket

func (*S3Fetcher) Fetch

func (fetcher *S3Fetcher) Fetch(c echo.Context, fileURL string) (io.Reader, string, error)

Fetch returns content from the local machine

It supports the following S3 URL format: - path style: s3://s3-aws-region.amazonaws.com/bucket/path/file - path style without region: s3://s3.amazonaws.com/bucket/path/file - default region must be configured in the configuration The bucket and path will be extracted from the URL.

If you are accessing an S3 file that is accessible via anonymous direct HTTP/S consider using the http fetcher.

func (*S3Fetcher) GetFetcherType

func (fetcher *S3Fetcher) GetFetcherType() string

GetFetcherType returns the type of this fetcher to be used in the 'type' properties when defining fetchers

func (*S3Fetcher) GetName

func (fetcher *S3Fetcher) GetName() string

GetName returns the name assigned to this fetcher that can be used in the 'paths' section

Jump to

Keyboard shortcuts

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