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


Golang manifest.Manifest类代码示例

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


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

示例1: Run

func (p DBCreatePostgresql) Run(data manifest.Manifest) error {
	if data.GetBool("purge") {
		return p.Drop(data)
	} else {
		return p.Create(data)
	}
}
开发者ID:kulikov,项目名称:serve,代码行数:7,代码来源:db.create.postgresql.go

示例2: Run

func (p DeployMarathon) Run(data manifest.Manifest) error {
	if data.GetBool("purge") {
		return p.Uninstall(data)
	} else {
		return p.Install(data)
	}
}
开发者ID:kulikov,项目名称:serve,代码行数:7,代码来源:marathon.go

示例3: Uninstall

func (p DeployDebian) Uninstall(data manifest.Manifest) error {
	if err := utils.RunSshCmd(
		data.GetString("cluster"),
		data.GetString("ssh-user"),
		fmt.Sprintf("sudo apt-get purge %s -y", data.GetString("package")),
	); err != nil {
		return err
	}

	return utils.DeletePluginData("deploy.debian", data.GetString("app-name"), data.GetString("consul-address"))
}
开发者ID:kulikov,项目名称:serve,代码行数:11,代码来源:debian.go

示例4: Run

func (p TestAutotest) Run(data manifest.Manifest) error {
	if err := utils.RunCmd("rm -rf tests && git clone --depth 1 --single-branch --recursive %s tests", data.GetString("repo")); err != nil {
		return fmt.Errorf("Error on clone test git repo: %v", err)
	}

	return utils.RunCmd(
		"cd tests/ && ./test.sh --project=%s --version=%s --suite=%s",
		data.GetString("project"),
		data.GetString("version"),
		data.GetString("suite"),
	)
}
开发者ID:kulikov,项目名称:serve,代码行数:12,代码来源:autotest.go

示例5: Run

func (p ReleaseDebian) Run(data manifest.Manifest) error {
	return utils.RunSshCmd(
		data.GetString("cluster"),
		data.GetString("ssh-user"),
		fmt.Sprintf(
			"sudo %s/debian-way/release.sh --package='%s' --site='%s' --mode='%s'",
			data.GetString("ci-tools-path"),
			data.GetString("package"),
			data.GetString("site"),
			data.GetString("mode"),
		),
	)
}
开发者ID:kulikov,项目名称:serve,代码行数:13,代码来源:debian.go

示例6: Drop

func (p DBCreatePostgresql) Drop(data manifest.Manifest) error {
	return utils.RunSingleSshCmd(
		data.GetString("host"),
		data.GetString("ssh-user"),
		fmt.Sprintf("sudo -Hu postgres psql -c \\\"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='%s';\\\" && sudo -Hu postgres dropdb --if-exists \"%s\"",
			data.GetString("target"), data.GetString("target")),
	)
}
开发者ID:kulikov,项目名称:serve,代码行数:8,代码来源:db.create.postgresql.go

示例7: Run

func (p TarballBuild) Run(data manifest.Manifest) error {
	utils.RunCmd("rm -rf ./tarball.tmp && mkdir ./tarball.tmp")

	for _, f := range data.GetArray("files") {
		if file, ok := f.Unwrap().(string); ok {
			utils.RunCmd("cp -a %s ./tarball.tmp/", file)
		} else if files, ok := f.Unwrap().(map[string]interface{}); ok {
			for from, to := range files {
				utils.RunCmd("cp -a %s ./tarball.tmp/%s", from, to)
			}
		}
	}

	if err := utils.RunCmd("tar -zcf tarball.tar.gz -C ./tarball.tmp/ ."); err != nil {
		return err
	}

	return utils.RunCmd("curl -vsSf -XPUT -T tarball.tar.gz %s", data.GetString("registry-url"))
}
开发者ID:kulikov,项目名称:serve,代码行数:19,代码来源:tarball.go

示例8: main

func main() {
	manifestFile := kingpin.Flag("manifest", "Path to manifest.yml file.").Default("manifest.yml").String()
	plugin := kingpin.Arg("plugin", "Plugin name for run.").String()
	vars := *kingpin.Flag("var", "key=value pairs with manifest vars.").StringMap()
	dryRun := kingpin.Flag("dry-run", "Show manifest section only").Bool()
	noColor := kingpin.Flag("no-color", "Disable colored output").Bool()
	pluginData := kingpin.Flag("plugin-data", "Data for plugin").String()

	kingpin.Version(version)
	kingpin.Parse()

	var plugins []manifest.PluginData
	var err error
	var manifestData *manifest.Manifest

	color.NoColor = *noColor

	if *pluginData != "" {
		manifestData = manifest.LoadJSON(*pluginData)
	} else {
		manifestData = manifest.Load(*manifestFile, vars)
	}

	if *plugin == "" && *dryRun {
		fmt.Printf("%s\n%s\n%s\n",
			color.GreenString(">>> manifest:"),
			manifestData.String(),
			color.GreenString("<<< manifest: OK\n"))
		return
	}

	if *pluginData != "" {
		plugins = []manifest.PluginData{manifestData.GetPluginWithData(*plugin)}
	} else {
		plugins, err = manifestData.FindPlugins(*plugin)
	}

	if err != nil {
		log.Fatalln(color.RedString("Error find plugins for '%s': %v", *plugin, err))
	}

	for _, pair := range plugins {
		log.Printf("%s\n%s\n\n", color.GreenString(">>> %s:", pair.PluginName), color.CyanString("%s", pair.Data))

		if !*dryRun {
			if err := pair.Plugin.Run(pair.Data); err != nil {
				fmt.Println("")
				log.Fatalln(color.RedString("Error on run plugin `%s`: %v", pair.PluginName, err))
			} else {
				log.Println(color.GreenString("<<< %s: OK", pair.PluginName))
			}
		}
	}
}
开发者ID:kulikov,项目名称:serve,代码行数:54,代码来源:serve.go

示例9: Run

func (p SbtBuild) Run(data manifest.Manifest) error {
	return utils.RunCmd(
		`sbt ';set every version := "%s"' clean "%s" %s`,
		data.GetString("version"),
		data.GetString("test"),
		data.GetStringOr("sbt", ""),
	)
}
开发者ID:kulikov,项目名称:serve,代码行数:8,代码来源:sbt.go

示例10: Uninstall

func (p DeployMarathon) Uninstall(data manifest.Manifest) error {
	marathonApi, err := MarathonClient(data.GetString("marathon-address"))
	if err != nil {
		return err
	}

	name := data.GetString("app-name")

	if _, err := marathonApi.Application(name); err == nil {
		if _, err := marathonApi.DeleteApplication(name, false); err != nil {
			return err
		}
	} else {
		log.Println(color.YellowString("App `%s` doesnt exists in marathon!", name))
	}

	return utils.DeletePluginData("deploy.marathon", name, data.GetString("consul-address"))
}
开发者ID:kulikov,项目名称:serve,代码行数:18,代码来源:marathon.go

示例11: Run

func (p ExternalPlugin) Run(data manifest.Manifest) error {
	return utils.RunCmdWithEnv(fmt.Sprintf("%s --plugin-data '%s'", p.Path, strings.Replace(data.String(), "\n", "", -1)), data.ToEnvMap("SERVE_"))
}
开发者ID:kulikov,项目名称:serve,代码行数:3,代码来源:external.plugins.go

示例12: Run

func (p ShBuild) Run(data manifest.Manifest) error {
	return utils.RunCmd(data.GetString("sh"))
}
开发者ID:kulikov,项目名称:serve,代码行数:3,代码来源:sh.go

示例13: Install

func (p DeployMarathon) Install(data manifest.Manifest) error {
	marathonApi, err := MarathonClient(data.GetString("marathon-address"))
	if err != nil {
		return err
	}

	fullName := data.GetString("app-name")

	bs, bf, bmax, grace := 5.0, 2.0, 120.0, 30.0
	app := &marathon.Application{
		BackoffSeconds:             &bs,
		BackoffFactor:              &bf,
		MaxLaunchDelaySeconds:      &bmax,
		TaskKillGracePeriodSeconds: &grace,
		UpgradeStrategy: &marathon.UpgradeStrategy{
			MinimumHealthCapacity: 0.5, // rolling update
			MaximumOverCapacity:   0.0,
		},
	}

	portArgs := ""
	if port := data.GetString("listen-port"); port != "" {
		portArgs = "--port " + port
	}

	app.Name(fullName)
	app.Command(fmt.Sprintf("exec serve-tools consul supervisor --service '%s' %s start %s", fullName, portArgs, data.GetString("cmd")))
	app.Count(data.GetInt("instances"))
	app.Memory(float64(data.GetInt("mem")))

	if cpu, err := strconv.ParseFloat(data.GetString("cpu"), 64); err == nil {
		app.CPU(cpu)
	}

	if cluster := data.GetString("cluster"); cluster != "" {
		cs := strings.SplitN(cluster, ":", 2)
		app.AddConstraint(cs[0], "CLUSTER", cs[1])
		app.AddLabel(cs[0], cs[1])
	}

	for _, cons := range data.GetArray("constraints") {
		if consArr, ok := cons.Unwrap().([]interface{}); ok {
			consStrings := make([]string, len(consArr))
			for i, c := range consArr {
				consStrings[i] = fmt.Sprintf("%s", c)
			}
			app.AddConstraint(consStrings...)
		}
	}

	for _, port := range data.GetArray("ports") {
		app.AddPortDefinition(marathon.PortDefinition{Name: port.GetStringOr("name", "")}.SetPort(port.GetIntOr("port", 0)))
	}

	app.AddEnv("SERVICE_DEPLOY_TIME", time.Now().Format(time.RFC3339)) // force redeploy app

	for k, v := range data.GetMap("environment") {
		app.AddEnv(k, fmt.Sprintf("%s", v.Unwrap()))
	}

	app.AddUris(data.GetString("package-uri"))

	// todo: в манифесте задавать массив healthchecks, их использовтаь в марафоне и консул-супервизоре
	// todo: открыть сетевой доступ от марафона до мезос-агентов, чтобы марафон мог хелсчеки посылать

	//if portArgs != "" {
	//	health := marathon.NewDefaultHealthCheck()
	//	health.Protocol = "TCP"
	//	health.IntervalSeconds = 5
	//	*health.PortIndex = 0
	//	app.AddHealthCheck(*health)
	//}

	if _, err := marathonApi.UpdateApplication(app, false); err != nil {
		color.Yellow("marathon <- %s", app)
		return err
	}

	color.Green("marathon <- %s", app)

	consulApi, err := utils.ConsulClient(data.GetString("consul-address"))
	if err != nil {
		return err
	}

	if err := utils.RegisterPluginData("deploy.marathon", data.GetString("app-name"), data.String(), data.GetString("consul-address")); err != nil {
		return err
	}

	return backoff.Retry(func() error {
		services, _, err := consulApi.Health().Service(fullName, "", true, nil)

		if err != nil {
			log.Println(color.RedString("Error in check health in consul: %v", err))
			return err
		}

		if len(services) == 0 {
			log.Printf("Service `%s` not started yet! Retry...", fullName)
			return fmt.Errorf("Service `%s` not started!", fullName)
//.........这里部分代码省略.........
开发者ID:kulikov,项目名称:serve,代码行数:101,代码来源:marathon.go

示例14: Install

func (p DeployTarball) Install(data manifest.Manifest) error {
	tmp := "tarball-" + utils.RandomString(16)
	dest := data.GetString("install-root") + "/" + data.GetString("package-name")

	hooks := make([]string, 0)
	for _, hook := range data.GetArray("hooks") {
		if hook.Has("postinstall") {
			hooks = append(hooks, "sudo "+hook.GetString("postinstall"))
		}
	}

	hookCmd := strings.Join(hooks, " && ")
	if hookCmd != "" {
		hookCmd = " && " + hookCmd
	}

	/**
	 * todo: register package in consul services catalog
	 */
	if err := utils.RunParallelSshCmd(
		data.GetString("cluster"),
		data.GetString("ssh-user"),
		fmt.Sprint(
			"curl -vsSf -o /tmp/"+tmp+".tar.gz "+data.GetString("package-uri"),
			" && rm -rf /tmp/"+tmp+"/",
			" && mkdir -p /tmp/"+tmp+"/",
			" && tar xzf /tmp/"+tmp+".tar.gz -C /tmp/"+tmp+"/",
			" && sudo rm -rf "+dest,
			" && sudo mkdir -p "+dest,
			" && sudo mv /tmp/"+tmp+"/* "+dest+"/",
			" && sudo chown -R "+data.GetString("user")+":"+data.GetString("group")+" "+dest+"/",
			" && rm -rf /tmp/"+tmp+".tar.gz /tmp/"+tmp+"/",
			hookCmd,
		),
		50,
	); err != nil {
		return err
	}

	return utils.RegisterPluginData("deploy.tarball", data.GetString("package-name"), data.String(), data.GetString("consul-address"))
}
开发者ID:kulikov,项目名称:serve,代码行数:41,代码来源:tarball.go

示例15: Uninstall

func (p DeployTarball) Uninstall(data manifest.Manifest) error {
	if err := utils.RunParallelSshCmd(
		data.GetString("cluster"),
		data.GetString("ssh-user"),
		fmt.Sprint("sudo rm -rf "+data.GetString("install-root")+"/"+data.GetString("package-name")),
		50,
	); err != nil {
		return err
	}

	return utils.DeletePluginData("deploy.tarball", data.GetString("package-name"), data.GetString("consul-address"))
}
开发者ID:kulikov,项目名称:serve,代码行数:12,代码来源:tarball.go


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