clean up the code for fetching registries

pull/172/head
vaikas-google 9 years ago
parent 1ee72edf31
commit 3db24d8531

@ -44,7 +44,7 @@ var (
deployment_name = flag.String("name", "", "Name of deployment, used for deploy and update commands (defaults to template name)")
stdin = flag.Bool("stdin", false, "Reads a configuration from the standard input")
properties = flag.String("properties", "", "Properties to use when deploying a template (e.g., --properties k1=v1,k2=v2)")
template_registry = flag.String("registry", "kubernetes/application-dm-templates", "Github based template registry (owner/repo[/path])")
template_registry = flag.String("registry", "github.com/kubernetes/application-dm-templates", "Registry (github.com/owner/repo)")
service = flag.String("service", "http://localhost:8001/api/v1/proxy/namespaces/dm/services/manager-service:manager", "URL for deployment manager")
binary = flag.String("binary", "../expandybird/expansion/expansion.py", "Path to template expansion binary")
timeout = flag.Int("timeout", 10, "Time in seconds to wait for response")
@ -82,12 +82,7 @@ var usage = func() {
}
func getGitRegistry() (registry.Registry, error) {
rs := registry.NewDefaultRegistryProvider()
s := strings.Split(*template_registry, "/")
if len(s) < 2 {
panic(fmt.Errorf("invalid template registry: %s", *template_registry))
}
return rs.GetRegistry("github.com/" + s[0] + "/" + s[1])
return registry.NewDefaultRegistryProvider().GetRegistry(*template_registry)
}
func main() {

@ -66,20 +66,11 @@ func (rs *inmemRepositoryService) Get(name string) (*common.Registry, error) {
func (rs *inmemRepositoryService) Delete(name string) error {
return nil
}
func (rs *inmemRepositoryService) GetByURL(URL string) (*common.Registry, error) {
if !strings.HasPrefix(URL, "github.com/") {
return nil, fmt.Errorf("Failed to parse short github url: %s", URL)
}
s := strings.Split(URL, "/")
if len(s) < 3 {
panic(fmt.Errorf("invalid template registry: %s", URL))
}
toFind := "github.com/" + s[1] + "/" + s[2]
fmt.Printf("toFind: %s", toFind)
// GetByURL returns a registry that handles the types for a given URL.
func (rs *inmemRepositoryService) GetByURL(URL string) (*common.Registry, error) {
for _, r := range rs.repositories {
fmt.Printf("Checking: %s", r.URL)
if r.URL == toFind {
if strings.HasPrefix(r.URL, URL) {
return r, nil
}
}

Loading…
Cancel
Save