예제 #1
0
파일: detach.go 프로젝트: runabove/sail
func serviceDomainDetach(serviceID, domain string, args domainStruct) {
	// Split namespace and service
	host, app, service, tag, err := internal.ParseResourceName(serviceID)
	internal.Check(err)

	if !internal.CheckHostConsistent(host) {
		fmt.Fprintf(os.Stderr, "Error: Invalid Host %s for endpoint %s\n", host, internal.Host)
		os.Exit(1)
	} else if len(tag) > 0 {
		fmt.Fprintf(os.Stderr, "Error: Invalid service name. Please see sail service domain detach --help\n")
		os.Exit(1)
	}

	body, err := json.Marshal(args)
	internal.Check(err)

	// Sanity checks
	err = internal.CheckName(domain)
	internal.Check(err)

	path := fmt.Sprintf("/applications/%s/services/%s/attached-routes/%s", app, service, domain)
	data := internal.DeleteBodyWantJSON(path, body)

	internal.FormatOutput(data, func(data []byte) {
		fmt.Fprintf(os.Stderr, "Detached route %s %s%s from service %s/%s\n", args.Method, domain, args.Pattern, app, service)
	})
}
예제 #2
0
파일: detach.go 프로젝트: bewiwi/sail
func serviceDomainDetach(serviceID, domain string, args domainStruct) {
	t := strings.Split(serviceID, "/")
	if len(t) != 2 {
		fmt.Fprintln(os.Stderr, usageDomainDetach)
		return
	}

	body, err := json.Marshal(args)
	internal.Check(err)

	path := fmt.Sprintf("/applications/%s/services/%s/attached-routes/%s", t[0], t[1], domain)
	internal.FormatOutputDef(internal.DeleteBodyWantJSON(path, body))

}