當前位置: 首頁>>代碼示例>>Golang>>正文


Golang internal.FormatOutputDef函數代碼示例

本文整理匯總了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)
}
開發者ID:runabove,項目名稱:sail,代碼行數:28,代碼來源:show.go

示例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])))
	}
}
開發者ID:bewiwi,項目名稱:sail,代碼行數:8,代碼來源:show.go

示例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))
}
開發者ID:bewiwi,項目名稱:sail,代碼行數:10,代碼來源:delete.go

示例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))
}
開發者ID:bewiwi,項目名稱:sail,代碼行數:10,代碼來源:delete.go

示例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))

}
開發者ID:bewiwi,項目名稱:sail,代碼行數:11,代碼來源:rangeAdd.go

示例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))
}
開發者ID:bewiwi,項目名稱:sail,代碼行數:12,代碼來源:token.go

示例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))
}
開發者ID:runabove,項目名稱:sail,代碼行數:12,代碼來源:webhook.go

示例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))
}
開發者ID:bewiwi,項目名稱:sail,代碼行數:14,代碼來源:token.go

示例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()))
}
開發者ID:runabove,項目名稱:sail,代碼行數:14,代碼來源:webhook.go

示例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))

}
開發者ID:bewiwi,項目名稱:sail,代碼行數:14,代碼來源:add.go

示例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))

}
開發者ID:bewiwi,項目名稱:sail,代碼行數:14,代碼來源:detach.go

示例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))

}
開發者ID:bewiwi,項目名稱:sail,代碼行數:15,代碼來源:attach.go

示例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))
}
開發者ID:runabove,項目名稱:sail,代碼行數:15,代碼來源:sshkey.go

示例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)))
}
開發者ID:runabove,項目名稱:sail,代碼行數:15,代碼來源:env.go

示例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()))
}
開發者ID:runabove,項目名稱:sail,代碼行數:15,代碼來源:sshkey.go


注:本文中的github.com/runabove/sail/internal.FormatOutputDef函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。