当前位置: 首页>>代码示例>>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;未经允许,请勿转载。