当前位置: 首页>>代码示例>>Golang>>正文


Golang Application.Create方法代码示例

本文整理汇总了Golang中github.com/kumoru/kumoru-sdk-go/pkg/service/application.Application.Create方法的典型用法代码示例。如果您正苦于以下问题:Golang Application.Create方法的具体用法?Golang Application.Create怎么用?Golang Application.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/kumoru/kumoru-sdk-go/pkg/service/application.Application的用法示例。


在下文中一共展示了Application.Create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Create

//Create an Application.
func Create(cmd *cli.Cmd) {
	locationUuid := cmd.String(cli.StringArg{
		Name:      "LOCATION_UUID",
		Desc:      "UUID of location to create application in",
		HideValue: true,
	})

	image := cmd.String(cli.StringArg{
		Name:      "IMG_URL",
		Desc:      "Image URL",
		HideValue: true,
	})

	name := cmd.String(cli.StringArg{
		Name:      "APP_NAME",
		Desc:      "Application Name",
		HideValue: true,
	})

	certificate := cmd.String(cli.StringOpt{
		Name:      "certificate_file",
		Desc:      "File(PEM encoded) containing the SSL certificate associated with the application",
		HideValue: true,
	})

	certificateChain := cmd.String(cli.StringOpt{
		Name:      "certificate_chain_file",
		Desc:      "File(PEM encoded) contianing the certificate chain associated with the public certificate (optional)",
		HideValue: true,
	})

	envFile := cmd.String(cli.StringOpt{
		Name:      "env_file",
		Desc:      "Environment variables file",
		HideValue: true,
	})

	privateKey := cmd.String(cli.StringOpt{
		Name:      "private_key_file",
		Desc:      "File(PEM encoded) containing the SSL key associated with the public certificate (required if providing a certificate)",
		HideValue: true,
	})

	sslPorts := cmd.Strings(cli.StringsOpt{
		Name:      "ssl_port",
		Desc:      "Port to be associated with the certificate",
		HideValue: true,
	})

	enVars := cmd.Strings(cli.StringsOpt{
		Name:      "e env",
		Desc:      "Environment variable (i.e. MYSQL_PASSWORD=complexpassword",
		HideValue: true,
	})

	rules := cmd.Strings(cli.StringsOpt{
		Name:      "r rule",
		Desc:      "Application Deployment rules",
		HideValue: true,
	})

	ports := cmd.Strings(cli.StringsOpt{
		Name:      "p port",
		Desc:      "Port (non-ssl)",
		HideValue: true,
	})

	labels := cmd.Strings(cli.StringsOpt{
		Name:      "l label",
		Desc:      "Label associated with the application",
		HideValue: true,
	})

	meta := cmd.String(cli.StringOpt{
		Name:      "m metadata",
		Desc:      "Metadata associated with the application being created. Must be JSON formatted.",
		HideValue: true,
	})

	cmd.Action = func() {
		app := application.Application{
			Certificates: readCertificates(certificate, privateKey, certificateChain),
			Environment:  transformEnvironment(envFile, enVars),
			ImageURL:     *image,
			Location: map[string]string{
				"uuid": *locationUuid,
			},
			Metadata: metaData(*meta, *labels),
			Name:     *name,
			Ports:    *ports,
			Rules:    transformRules(rules),
			SSLPorts: *sslPorts,
		}

		application, resp, errs := app.Create()

		if len(errs) > 0 {
			log.Fatalf("Could not create application: %s", errs[0])
		}
//.........这里部分代码省略.........
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:101,代码来源:applications.go


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