|
|
@ -36,6 +36,7 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
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")
|
|
|
|
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)")
|
|
|
|
properties = flag.String("properties", "", "Properties to use when deploying a template (e.g., --properties k1=v1,k2=v2)")
|
|
|
|
template_registry = flag.String("registry", "kubernetes/deployment-manager/templates", "Github based template registry (owner/repo[/path])")
|
|
|
|
template_registry = flag.String("registry", "kubernetes/deployment-manager/templates", "Github based template registry (owner/repo[/path])")
|
|
|
@ -111,10 +112,7 @@ func main() {
|
|
|
|
fmt.Printf("Templates:\n")
|
|
|
|
fmt.Printf("Templates:\n")
|
|
|
|
for _, t := range templates {
|
|
|
|
for _, t := range templates {
|
|
|
|
fmt.Printf("%s:%s\n", t.Name, t.Version)
|
|
|
|
fmt.Printf("%s:%s\n", t.Name, t.Version)
|
|
|
|
downloadURL, err := git.GetURL(t)
|
|
|
|
downloadURL := getDownloadUrl(t)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.Printf("Failed to get download URL for template %s:%s", t.Name, t.Version)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Printf("\tdownload URL: %s\n", downloadURL)
|
|
|
|
fmt.Printf("\tdownload URL: %s\n", downloadURL)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -160,8 +158,9 @@ func main() {
|
|
|
|
usage()
|
|
|
|
usage()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
path := fmt.Sprintf("types/%s/instances", url.QueryEscape(args[1]))
|
|
|
|
tUrl := getTypeUrl(args[1])
|
|
|
|
action := fmt.Sprintf("list deployed instances of type %s", args[1])
|
|
|
|
path := fmt.Sprintf("types/%s/instances", url.QueryEscape(tUrl))
|
|
|
|
|
|
|
|
action := fmt.Sprintf("list deployed instances of type %s", tUrl)
|
|
|
|
callService(path, "GET", action, nil)
|
|
|
|
callService(path, "GET", action, nil)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
usage()
|
|
|
|
usage()
|
|
|
@ -216,28 +215,38 @@ func describeType(args []string) {
|
|
|
|
usage()
|
|
|
|
usage()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var tUrl string
|
|
|
|
tUrl := getTypeUrl(args[1])
|
|
|
|
|
|
|
|
schemaUrl := tUrl + ".schema"
|
|
|
|
|
|
|
|
fmt.Println(callHttp(schemaUrl, "GET", "get schema for type ("+tUrl+")", nil))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if strings.HasPrefix(args[1], "http://") || strings.HasPrefix(args[1], "https://") {
|
|
|
|
func getTypeUrl(tName string) string {
|
|
|
|
|
|
|
|
if isHttp(tName) {
|
|
|
|
// User can pass raw URL to template.
|
|
|
|
// User can pass raw URL to template.
|
|
|
|
tUrl = args[1]
|
|
|
|
return tName
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// User can pass registry type.
|
|
|
|
// User can pass registry type.
|
|
|
|
t := getRegistryType(args[1])
|
|
|
|
t := getRegistryType(tName)
|
|
|
|
if t == nil {
|
|
|
|
if t == nil {
|
|
|
|
log.Fatalf("Invalid type name, must be in the form \"<type-name>:<version>\": %s", args[1])
|
|
|
|
log.Fatalf("Invalid type name, must be in the form \"<type-name>:<version>\": %s", tName)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return getDownloadUrl(*t)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func getDownloadUrl(t registry.Type) string {
|
|
|
|
git := getGitRegistry()
|
|
|
|
git := getGitRegistry()
|
|
|
|
url, err := git.GetURL(*t)
|
|
|
|
url, err := git.GetURL(t)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Failed to fetch type information for %s: %s", args[1], err)
|
|
|
|
log.Fatalf("Failed to fetch type information for \"%s:%s\": %s", t.Name, t.Version, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tUrl = url
|
|
|
|
|
|
|
|
|
|
|
|
return url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
schemaUrl := tUrl + ".schema"
|
|
|
|
func isHttp(t string) bool {
|
|
|
|
fmt.Println(callHttp(schemaUrl, "GET", "get schema for type ("+tUrl+")", nil))
|
|
|
|
return strings.HasPrefix(t, "http://") || strings.HasPrefix(t, "https://")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func loadTemplate(args []string) *expander.Template {
|
|
|
|
func loadTemplate(args []string) *expander.Template {
|
|
|
@ -262,6 +271,11 @@ func loadTemplate(args []string) *expander.Template {
|
|
|
|
log.Fatalf("cannot create configuration from supplied arguments: %s\n", err)
|
|
|
|
log.Fatalf("cannot create configuration from supplied arguments: %s\n", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Override name if set from flags.
|
|
|
|
|
|
|
|
if *deployment_name != "" {
|
|
|
|
|
|
|
|
template.Name = *deployment_name
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return template
|
|
|
|
return template
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -279,11 +293,7 @@ func getRegistryType(fullType string) *registry.Type {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func buildTemplateFromType(t registry.Type) *expander.Template {
|
|
|
|
func buildTemplateFromType(t registry.Type) *expander.Template {
|
|
|
|
git := getGitRegistry()
|
|
|
|
downloadURL := getDownloadUrl(t)
|
|
|
|
downloadURL, err := git.GetURL(t)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.Fatalf("Failed to get download URL for type %s:%s\n%s\n", t.Name, t.Version, err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
props := make(map[string]interface{})
|
|
|
|
props := make(map[string]interface{})
|
|
|
|
if *properties != "" {
|
|
|
|
if *properties != "" {
|
|
|
|