backy/pkg/configfetcher/configfetcher.go
Andrew Woodlee 5c2bfcc940
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
[WIP] v0.7.0
2025-01-14 09:42:43 -06:00

25 lines
689 B
Go

package configfetcher
import "strings"
type ConfigFetcher 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
}
func NewConfigFetcher(source string) ConfigFetcher {
if strings.HasPrefix(source, "http") || strings.HasPrefix(source, "https") {
return &HTTPFetcher{}
} else if strings.HasPrefix(source, "s3") {
return &S3Fetcher{}
} else {
return &LocalFetcher{}
}
}