|
|
|
@ -41,24 +41,32 @@ func NewGithubRegistry(owner, repository, path string) *GithubRegistry {
|
|
|
|
|
|
|
|
|
|
// List the types from the Registry.
|
|
|
|
|
func (g *GithubRegistry) List() ([]Type, error) {
|
|
|
|
|
// First list all the types at the top level.
|
|
|
|
|
types, err := g.getDirs("")
|
|
|
|
|
// First list all the collections at the top level.
|
|
|
|
|
collections, err := g.getDirs("")
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Printf("Failed to list templates: %v", err)
|
|
|
|
|
log.Printf("Failed to list qualifiers: %v", err)
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var retTypes []Type
|
|
|
|
|
for _, c := range collections {
|
|
|
|
|
// Then we need to fetch the versions (directories for this type)
|
|
|
|
|
types, err := g.getDirs(c)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Printf("Failed to fetch types for collection: %s", c)
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, t := range types {
|
|
|
|
|
// Then we need to fetch the versions (directories for this type)
|
|
|
|
|
versions, err := g.getDirs(t)
|
|
|
|
|
versions, err := g.getDirs(c + "/" + t)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Printf("Failed to fetch versions for template: %s", t)
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, v := range versions {
|
|
|
|
|
retTypes = append(retTypes, Type{Name: t, Version: v})
|
|
|
|
|
retTypes = append(retTypes, Type{Name: t, Version: v, Collection: c})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -71,7 +79,6 @@ func (g *GithubRegistry) GetURL(t Type) (string, error) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
log.Printf("Got repository path: %s", path)
|
|
|
|
|
_, dc, _, err := g.client.Repositories.GetContents(g.owner, g.repository, path, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Printf("Failed to list versions at path: %s: %v", path, err)
|
|
|
|
@ -134,7 +141,6 @@ func (g *GithubRegistry) mapCollection(collection string) (string, error) {
|
|
|
|
|
// Type.Collection will be mapped using mapCollection in the future, for now it's a straight
|
|
|
|
|
// 1:1 mapping (if given)
|
|
|
|
|
func (g *GithubRegistry) MakeRepositoryPath(t Type) (string, error) {
|
|
|
|
|
log.Printf("Making repository path: %v", t)
|
|
|
|
|
// First map the collection
|
|
|
|
|
collection, err := g.mapCollection(t.Collection)
|
|
|
|
|
if err != nil {
|
|
|
|
|