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


Golang application.Application類代碼示例

本文整理匯總了Golang中github.com/kumoru/kumoru-sdk-go/pkg/service/application.Application的典型用法代碼示例。如果您正苦於以下問題:Golang Application類的具體用法?Golang Application怎麽用?Golang Application使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Application類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Archive

//Archive an Application
func Archive(cmd *cli.Cmd) {
	uuid := cmd.String(cli.StringArg{
		Name:      "UUID",
		Desc:      "Application UUID",
		HideValue: true,
	})

	cmd.Action = func() {
		app := application.Application{
			UUID: *uuid,
		}

		_, resp, errs := app.Delete()

		if errs != nil {
			log.Fatalf("Could not archive applications: %s", errs)
		}

		if resp.StatusCode != 202 {
			log.Fatalf("Could not archive applications: %s", resp.Status)
		}

		fmt.Printf("Application %s accepted for archival\n", *uuid)
	}
}
開發者ID:devx,項目名稱:kumoru-sdk-go,代碼行數:26,代碼來源:applications.go

示例2: Show

//Show an Application.
func Show(cmd *cli.Cmd) {
	uuid := cmd.String(cli.StringArg{
		Name:      "UUID",
		Desc:      "Application UUID",
		HideValue: true,
	})

	cmd.Action = func() {
		app := application.Application{
			UUID: *uuid,
		}

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

		if errs != nil {
			log.Fatalf("Could not retrieve application: %s", errs)
		}

		if resp.StatusCode != 200 {
			log.Fatalf("Could not retrieve application: %s", resp.Status)
		}

		printAppDetail(application)
	}
}
開發者ID:devx,項目名稱:kumoru-sdk-go,代碼行數:26,代碼來源:applications.go

示例3: Deploy

//Deploy an Application
func Deploy(cmd *cli.Cmd) {
	uuid := cmd.String(cli.StringArg{
		Name:      "UUID",
		Desc:      "Application UUID",
		HideValue: true,
	})

	cmd.Action = func() {
		app := application.Application{
			UUID: *uuid,
		}

		application, resp, errs := app.Show() // TODO remove this duplication of application.Show() logic

		if errs != nil {
			log.Fatalf("Could not retrieve deployment token: %s", errs)
		}

		if resp.StatusCode != 200 {
			log.Fatalf("Could not retrieve deployment token: %s", resp.Status)
		}

		application, resp, errs = application.Deploy()

		if errs != nil {
			log.Fatalf("Could not deploy application: %s", errs)
		}

		if resp.StatusCode != 202 {
			log.Fatalf("Could not deploy application: %s", resp.Status)
		}

		fmt.Printf("Deploying application %s\n", application.UUID)
	}

}
開發者ID:devx,項目名稱:kumoru-sdk-go,代碼行數:37,代碼來源:applications.go

示例4: 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

示例5: Patch

//Patch an Application.
func Patch(cmd *cli.Cmd) {
	uuid := cmd.String(cli.StringArg{
		Name:      "UUID",
		Desc:      "Application UUID",
		HideValue: true,
	})

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

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

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

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

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

	privateKey := cmd.String(cli.StringOpt{
		Name:      "private_key_file",
		Desc:      "File (PEM) 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 assocaited 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",
		HideValue: true,
	})

	labels := cmd.Strings(cli.StringsOpt{
		Name:      "l label",
		Desc:      "Label associated with the aplication",
		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{
			UUID: *uuid,
		}

		var eVars []string

		if *envFile != "" {
			eVars = readEnvFile(*envFile)
		} else {
			eVars = *enVars
		}

		var m string
		if *meta != "" {
			mData := metaData(*meta, *labels)

			mdata, err := json.Marshal(mData)
			if err != nil {
				log.Fatal(err)
//.........這裏部分代碼省略.........
開發者ID:devx,項目名稱:kumoru-sdk-go,代碼行數:101,代碼來源:applications.go


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