spud/service_definition/fetcher.go

27 lines
552 B
Go
Raw Normal View History

// Definition fetcher
//
// Handles fetching and building ServiceDefinition structs from different
// data sources.
package service_definition
import (
"fmt"
)
type DefinitionFetcher interface {
GetDefinition(path string) (ServiceDefinition, error)
}
func NewDefinitionFetcher(fetcher_type string) (DefinitionFetcher, error) {
if fetcher_type == "git" {
return NewGitDefinitionFetcher(), nil
}
if fetcher_type == "file" {
return NewFileDefinitionFetcher(), nil
}
return nil, fmt.Errorf("Unrecognized fetcher type: %s", fetcher_type)
}