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


Golang Deployment.Len方法代碼示例

本文整理匯總了Golang中rsprd/com/spread/pkg/deploy.Deployment.Len方法的典型用法代碼示例。如果您正苦於以下問題:Golang Deployment.Len方法的具體用法?Golang Deployment.Len怎麽用?Golang Deployment.Len使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rsprd/com/spread/pkg/deploy.Deployment的用法示例。


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

示例1: Deploy

// Deploy allows the creation of deploy.Deployments remotely
func (s *SpreadCli) Deploy() *cli.Command {
	return &cli.Command{
		Name:        "deploy",
		Usage:       "spread deploy [-s] PATH | COMMIT [kubectl context]",
		Description: "Deploys objects to a remote Kubernetes cluster.",
		ArgsUsage:   "-s will deploy only if no other deployment found (otherwise fails)",
		Action: func(c *cli.Context) {
			ref := c.Args().First()
			var dep *deploy.Deployment

			proj, err := s.project()
			if err == nil {
				var docs map[string]*pb.Document
				if len(ref) == 0 {
					s.printf("Deploying from index...")
					docs, err = proj.Index()
					if err != nil {
						s.fatalf("Error getting index: %v", err)
					}

					if err = s.promptForArgs(docs, false); err == nil {
						dep, err = deploy.DeploymentFromDocMap(docs)
					}

				} else {
					if docs, err = proj.ResolveCommit(ref); err == nil {
						if err = s.promptForArgs(docs, false); err == nil {
							dep, err = deploy.DeploymentFromDocMap(docs)
						}
					} else {
						dep, err = s.globalDeploy(ref)
					}
				}
			} else {
				dep, err = s.globalDeploy(ref)
			}

			if err != nil {
				s.fatalf("Failed to assemble deployment: %v", err)
			}

			context := c.Args().Get(1)
			cluster, err := deploy.NewKubeClusterFromContext(context)
			if err != nil {
				s.fatalf("Failed to deploy: %v", err)
			}

			s.printf("Deploying %d objects using the %s.", dep.Len(), displayContext(context))

			update := !c.Bool("s")
			err = cluster.Deploy(dep, update, false)
			if err != nil {
				//TODO: make better error messages (one to indicate a deployment already existed; another one if a deployment did not exist but some other error was thrown
				s.fatalf("Did not deploy.: %v", err)
			}

			s.printf("Deployment successful!")
		},
	}
}
開發者ID:redspread,項目名稱:spread,代碼行數:61,代碼來源:deploy.go


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