// Git Definition fetcher // // Handles fetching and building ServiceDefinition structs from git // repositories. package service_definition import ( "os" git "spud/git" "strings" ) type GitDefinitionFetcher struct { Git git.GitClient } func NewGitDefinitionFetcher() *GitDefinitionFetcher { return &GitDefinitionFetcher{ Git: git.Git{}, } } // Clones the target git repository and uses it as a basis to extract // a service definition. func (f GitDefinitionFetcher) GetDefinition(path string) (ServiceDefinition, error) { dir, err := os.MkdirTemp("/tmp", "spud-service-") if err != nil { return ServiceDefinition{}, err } if _, err := f.Git.Clone(strings.TrimPrefix(path, "git+"), dir); err != nil { return ServiceDefinition{}, err } return NewFileDefinitionFetcher().GetDefinition((dir + "/service.yml")) }