本文整理匯總了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!")
},
}
}