本文整理汇总了Golang中github.com/runabove/sail/internal.FormatOutputDef函数的典型用法代码示例。如果您正苦于以下问题:Golang FormatOutputDef函数的具体用法?Golang FormatOutputDef怎么用?Golang FormatOutputDef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FormatOutputDef函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: networkShow
func networkShow(networkID string) {
// Split namespace and repository
host, app, net, tag, err := internal.ParseResourceName(networkID)
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 network name. Please see sail network show --help\n")
os.Exit(1)
}
var network map[string]interface{}
var ranges []string
b := internal.ReqWant("GET", http.StatusOK, fmt.Sprintf("/applications/%s/networks/%s", app, net), nil)
internal.Check(json.Unmarshal(b, &network))
brange := internal.ReqWant("GET", http.StatusOK, fmt.Sprintf("/applications/%s/networks/%s/ranges", app, net), nil)
internal.Check(json.Unmarshal(brange, &ranges))
network["range"] = ranges
n, err := json.Marshal(network)
internal.Check(err)
internal.FormatOutputDef(n)
}
示例2: serviceShow
func serviceShow(serviceID string) {
t := strings.Split(serviceID, "/")
if len(t) != 2 {
fmt.Fprintln(os.Stderr, "Invalid usage. sail service show <applicationName>/<serviceId>. Please see sail service show --help")
} else {
internal.FormatOutputDef(internal.GetWantJSON(fmt.Sprintf("/applications/%s/services/%s", t[0], t[1])))
}
}
示例3: networkRemove
func networkRemove(networkID string) {
t := strings.Split(networkID, "/")
if len(t) != 2 {
fmt.Fprintln(os.Stderr, "Invalid usage. sail network delete <applicationName>/<networkId>. Please see sail network delete --help")
return
}
path := fmt.Sprintf("/applications/%s/networks/%s", t[0], t[1])
internal.FormatOutputDef(internal.DeleteWantJSON(path))
}
示例4: repositoryRemove
func repositoryRemove(repositoryID string) {
t := strings.Split(repositoryID, "/")
if len(t) != 2 {
fmt.Fprintln(os.Stderr, "Invalid usage. sail repository delete <applicationName>/<repositoryId>. Please see sail repository delete --help")
return
}
path := fmt.Sprintf("/repositories/%s/%s", t[0], t[1])
internal.FormatOutputDef(internal.DeleteWantJSON(path))
}
示例5: networkRangeAdd
func networkRangeAdd(networkID, ipFrom, ipTo string) {
t := strings.Split(networkID, "/")
if len(t) != 2 {
fmt.Fprintln(os.Stderr, "Invalid usage. sail network range-add <applicationName>/<networkId> <ipFrom> <ipTo>. Please see sail network range-add --help")
return
}
path := fmt.Sprintf("/applications/%s/networks/%s/ranges/%s-%s", t[0], t[1], ipFrom, ipTo)
internal.FormatOutputDef(internal.PostWantJSON(path))
}
示例6: cmdCreate
func cmdCreate(cmd *cobra.Command, args []string) {
usage := "Invalid usage. sail metric token create <applicationName>. Please see sail metric token create --help\n"
if len(args) != 1 {
fmt.Fprintf(os.Stderr, usage)
return
}
// Get args
application := args[0]
path := fmt.Sprintf("/applications/%s/metrics/token", application)
internal.FormatOutputDef(internal.PostWantJSON(path))
}
示例7: webhookAdd
func webhookAdd(namespace, webhookURL string) {
path := fmt.Sprintf("/applications/%s/hook", namespace)
rawBody := webhookStruct{URL: webhookURL}
body, err := json.MarshalIndent(rawBody, " ", " ")
if err != nil {
fmt.Fprintf(os.Stderr, "Fatal: %s\n", err)
return
}
internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))
}
示例8: cmdRevoke
func cmdRevoke(cmd *cobra.Command, args []string) {
usage := "Invalid usage. sail metric token revoke <applicationName> <token>. Please see sail metric token revoke --help\n"
if len(args) != 2 {
fmt.Fprintf(os.Stderr, usage)
return
}
// Get args
application := args[0]
token := args[1]
path := fmt.Sprintf("/applications/%s/metrics/token/%s", application, token)
internal.FormatOutputDef(internal.DeleteWantJSON(path))
}
示例9: webhookDelete
func webhookDelete(namespace, webhookURL string) {
urlEscape := url.QueryEscape(webhookURL)
path := fmt.Sprintf("/applications/%s/hook", namespace)
// pass urlEscape as query string argument
BaseURL, err := url.Parse(path)
internal.Check(err)
params := url.Values{}
params.Add("url", urlEscape)
BaseURL.RawQuery = params.Encode()
internal.FormatOutputDef(internal.DeleteWantJSON(BaseURL.String()))
}
示例10: networkAdd
func networkAdd(networkID string, args networkAddStruct) {
t := strings.Split(networkID, "/")
if len(t) != 2 {
fmt.Fprintln(os.Stderr, "Invalid usage. sail network add <applicationName>/<networkId>. Please see sail network add --help")
return
}
body, err := json.Marshal(args)
internal.Check(err)
path := fmt.Sprintf("/applications/%s/networks/%s", t[0], t[1])
internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))
}
示例11: serviceDomainDetach
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))
}
示例12: serviceDomainAttach
func serviceDomainAttach(serviceID, domain, pattern, method string) {
t := strings.Split(serviceID, "/")
if len(t) != 2 {
fmt.Fprintln(os.Stderr, usageDomainAttach)
return
}
args := domainStruct{Pattern: pattern, Method: method}
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.PostBodyWantJSON(path, body))
}
示例13: sshKeyAdd
func sshKeyAdd(keyLine, keyName string) {
path := "/user/keys"
rawBody := sshkeyStruct{
KeyLine: string(keyLine),
KeyName: string(keyName),
}
body, err := json.MarshalIndent(rawBody, " ", " ")
if err != nil {
fmt.Fprintf(os.Stderr, "Fatal: %s\n", err)
return
}
internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))
}
示例14: cmdListEnv
func cmdListEnv(cmd *cobra.Command, args []string) {
var applicationName string
switch len(args) {
case 0:
applicationName = internal.GetUserName()
case 1:
applicationName = args[0]
default:
fmt.Fprintln(os.Stderr, "Invalid usage. Please see sail application env list --help")
return
}
internal.FormatOutputDef(internal.GetWantJSON(fmt.Sprintf("/applications/%s/env", applicationName)))
}
示例15: sshKeyDelete
func sshKeyDelete(fingerprint string) {
urlEscape := url.QueryEscape(fingerprint)
path := "/user/keys"
// pass urlEscape as query string argument
BaseURL, err := url.Parse(path)
internal.Check(err)
params := url.Values{}
params.Add("fingerprint", urlEscape)
BaseURL.RawQuery = params.Encode()
internal.FormatOutputDef(internal.DeleteWantJSON(BaseURL.String()))
}