2024-11-10 16:08:16 +00:00
|
|
|
// Definition fetcher
|
|
|
|
//
|
|
|
|
// Handles fetching and building ServiceDefinition structs from different
|
|
|
|
// data sources.
|
|
|
|
|
2024-11-10 15:37:46 +00:00
|
|
|
package service_definition
|
|
|
|
|
|
|
|
import (
|
2024-11-14 04:56:19 +00:00
|
|
|
"fmt"
|
2024-11-10 15:37:46 +00:00
|
|
|
)
|
|
|
|
|
2024-11-14 04:56:19 +00:00
|
|
|
type DefinitionFetcher interface {
|
|
|
|
GetDefinition(path string) (ServiceDefinition, error)
|
2024-11-10 16:08:16 +00:00
|
|
|
}
|
|
|
|
|
2024-11-14 04:56:19 +00:00
|
|
|
func NewDefinitionFetcher(fetcher_type string) (DefinitionFetcher, error) {
|
|
|
|
if fetcher_type == "git" {
|
|
|
|
return NewGitDefinitionFetcher(), nil
|
2024-11-10 15:37:46 +00:00
|
|
|
}
|
|
|
|
|
2024-11-14 04:56:19 +00:00
|
|
|
if fetcher_type == "file" {
|
|
|
|
return NewFileDefinitionFetcher(), nil
|
2024-11-10 15:37:46 +00:00
|
|
|
}
|
|
|
|
|
2024-11-14 04:56:19 +00:00
|
|
|
return nil, fmt.Errorf("Unrecognized fetcher type: %s", fetcher_type)
|
2024-11-10 15:37:46 +00:00
|
|
|
}
|