• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang internal.FormatOutputDef函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/runabove/sail/internal.FormatOutputDef函数的典型用法代码示例。如果您正苦于以下问题:Golang FormatOutputDef函数的具体用法?Golang FormatOutputDef怎么用?Golang FormatOutputDef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FormatOutputDef函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: networkRangeAdd

func networkRangeAdd(networkID, ipFrom, ipTo 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)
	}

	path := fmt.Sprintf("/applications/%s/networks/%s/ranges/%s-%s", app, net, ipFrom, ipTo)
	internal.FormatOutputDef(internal.PostWantJSON(path))

}
开发者ID:runabove,项目名称:sail,代码行数:17,代码来源:rangeAdd.go


示例17: cmdDelEnv

func cmdDelEnv(cmd *cobra.Command, args []string) {
	var applicationName string
	var key string

	switch len(args) {
	case 1:
		applicationName = internal.GetUserName()
		key = args[0]
	case 2:
		applicationName = args[0]
		key = args[1]
	default:
		fmt.Fprintln(os.Stderr, "Invalid usage. Please see sail application env set --help")
		return
	}

	internal.FormatOutputDef(internal.DeleteWantJSON(fmt.Sprintf("/applications/%s/env/%s", applicationName, key)))
}
开发者ID:runabove,项目名称:sail,代码行数:18,代码来源:env.go


示例18: networkAdd

func networkAdd(networkID string, args networkAddStruct) {
	// 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 add --help\n")
		os.Exit(1)
	}

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

	path := fmt.Sprintf("/applications/%s/networks/%s", app, net)
	internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))

}
开发者ID:runabove,项目名称:sail,代码行数:20,代码来源:add.go


示例19: repositoryAdd

func repositoryAdd(repositoryName string, args repositoryAddStruct) {
	// Split namespace and repository
	host, app, repo, tag, err := internal.ParseResourceName(repositoryName)
	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 repository name. Please see sail repository add --help\n")
		os.Exit(1)
	}

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

	path := fmt.Sprintf("/repositories/%s/%s", app, repo)
	internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))

}
开发者ID:runabove,项目名称:sail,代码行数:20,代码来源:add.go


示例20: networkShow

func networkShow(networkID string) {
	t := strings.Split(networkID, "/")
	if len(t) != 2 {
		fmt.Fprintln(os.Stderr, "Invalid usage. sail network show <applicationName>/<networkId>. Please see sail network show --help")
	} else {

		var network map[string]interface{}
		var ranges []string

		b := internal.ReqWant("GET", http.StatusOK, fmt.Sprintf("/applications/%s/networks/%s", t[0], t[1]), nil)
		internal.Check(json.Unmarshal(b, &network))

		brange := internal.ReqWant("GET", http.StatusOK, fmt.Sprintf("/applications/%s/networks/%s/ranges", t[0], t[1]), nil)
		internal.Check(json.Unmarshal(brange, &ranges))

		network["range"] = ranges
		n, err := json.Marshal(network)
		internal.Check(err)
		internal.FormatOutputDef(n)
	}
}
开发者ID:bewiwi,项目名称:sail,代码行数:21,代码来源:show.go



注:本文中的github.com/runabove/sail/internal.FormatOutputDef函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang internal.ParseResourceName函数代码示例发布时间:2022-05-28
下一篇:
Golang internal.CheckHostConsistent函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap