Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrIgnoreFileNotFound = errors.New("remotefetcher: file not found")
ErrIgnoreFileNotFound is returned when the file is not found and should be ignored
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (*Cache) AddDataToStore ¶
type CacheData ¶
type CacheData struct { Hash string `yaml:"hash"` Path string `yaml:"path"` Type string `yaml:"type"` URL string `yaml:"url"` }
func LoadMetadataFromFile ¶
Function to read and parse the metadata file
type CachedFetcher ¶
type CachedFetcher struct {
// contains filtered or unexported fields
}
func (*CachedFetcher) Hash ¶
func (cf *CachedFetcher) Hash(data []byte) string
func (*CachedFetcher) Parse ¶
func (cf *CachedFetcher) Parse(data []byte, target interface{}) error
type FetcherConfig ¶
type FetcherConfig struct { S3Client *s3.Client HTTPClient *http.Client FileType string IgnoreFileNotFound bool }
FetcherConfig holds the configuration for a fetcher.
type FetcherOption ¶
type FetcherOption func(*FetcherConfig)
Option is a function that configures a fetcher.
func IgnoreFileNotFound ¶
func IgnoreFileNotFound() FetcherOption
func WithFileType ¶
func WithFileType(fileType string) FetcherOption
WithFileType ensures the default FileType will be yaml
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) FetcherOption
WithHTTPClient sets the HTTP client for the fetcher.
func WithS3Client ¶
func WithS3Client(client *s3.Client) FetcherOption
WithS3Client sets the S3 client for the fetcher.
type HTTPFetcher ¶
func NewHTTPFetcher ¶
func NewHTTPFetcher(options ...FetcherOption) *HTTPFetcher
NewHTTPFetcher creates a new instance of HTTPFetcher with the provided options.
func (*HTTPFetcher) Fetch ¶
func (h *HTTPFetcher) Fetch(source string) ([]byte, error)
Fetch retrieves the file from the specified source URL
func (*HTTPFetcher) Hash ¶
func (h *HTTPFetcher) Hash(data []byte) string
func (*HTTPFetcher) Parse ¶
func (h *HTTPFetcher) Parse(data []byte, target interface{}) error
Parse decodes the raw data into the provided target structure
type LocalFetcher ¶
type LocalFetcher struct {
// contains filtered or unexported fields
}
func (*LocalFetcher) Fetch ¶
func (l *LocalFetcher) Fetch(source string) ([]byte, error)
Fetch retrieves the file from the specified local file path
func (*LocalFetcher) Hash ¶
func (l *LocalFetcher) Hash(data []byte) string
func (*LocalFetcher) Parse ¶
func (l *LocalFetcher) Parse(data []byte, target interface{}) error
Parse decodes the raw data into the provided target structure
type RemoteFetcher ¶
type RemoteFetcher interface { // Fetch retrieves the configuration from the specified URL or source // Returns the raw data as bytes or an error Fetch(source string) ([]byte, error) // Parse decodes the raw data into a Go structure (e.g., Commands, CommandLists) // Takes the raw data as input and populates the target interface Parse(data []byte, target interface{}) error // Hash returns the hash of the configuration data Hash(data []byte) string }
func NewRemoteFetcher ¶
func NewRemoteFetcher(source string, cache *Cache, options ...FetcherOption) (RemoteFetcher, error)
type S3Fetcher ¶
type S3Fetcher struct { S3Client *minio.Client // contains filtered or unexported fields }
func NewS3Fetcher ¶
func NewS3Fetcher(endpoint string, options ...FetcherOption) (*S3Fetcher, error)
NewS3Fetcher creates a new instance of S3Fetcher with the provided options.