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


Golang models.GetApp函数代码示例

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


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

示例1: AppCreate

func AppCreate(rw http.ResponseWriter, r *http.Request) error {
	name := r.FormValue("name")

	app := &models.App{
		Name: name,
	}

	err := app.Create()

	if awsError(err) == "AlreadyExistsException" {
		app, err := models.GetApp(name)

		if err != nil {
			return err
		}

		return RenderForbidden(rw, fmt.Sprintf("There is already an app named %s (%s)", name, app.Status))
	}

	if err != nil {
		return err
	}

	app, err = models.GetApp(name)

	if err != nil {
		return err
	}

	return RenderJson(rw, app)
}
开发者ID:jbuck,项目名称:rack,代码行数:31,代码来源:apps.go

示例2: AppCreate

func AppCreate(rw http.ResponseWriter, r *http.Request) *httperr.Error {
	name := r.FormValue("name")

	app := &models.App{
		Name: name,
	}

	err := app.Create()

	if awsError(err) == "AlreadyExistsException" {
		app, err := models.GetApp(name)

		if err != nil {
			return httperr.Server(err)
		}

		return httperr.Errorf(403, "there is already an app named %s (%s)", name, app.Status)
	}

	if err != nil {
		return httperr.Server(err)
	}

	app, err = models.GetApp(name)

	if err != nil {
		return httperr.Server(err)
	}

	return RenderJson(rw, app)
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:31,代码来源:apps.go

示例3: AppCreate

func AppCreate(rw http.ResponseWriter, r *http.Request) *httperr.Error {
	name := r.FormValue("name")
	if name == os.Getenv("RACK") {
		return httperr.Errorf(403, "application name cannot match rack name (%s). Please choose a different name for your app.", name)
	}

	// Early check for unbound app only.
	if app, err := models.GetAppUnbound(name); err == nil {
		return httperr.Errorf(403, "there is already a legacy app named %s (%s). We recommend you delete this app and create it again.", name, app.Status)
	}

	// If unbound check fails this will result in a bound app.
	app := &models.App{Name: name}
	err := app.Create()

	if awsError(err) == "AlreadyExistsException" {
		app, err := models.GetApp(name)
		if err != nil {
			return httperr.Server(err)
		}

		return httperr.Errorf(403, "there is already an app named %s (%s)", name, app.Status)
	}

	if err != nil {
		return httperr.Server(err)
	}

	app, err = models.GetApp(name)
	if err != nil {
		return httperr.Server(err)
	}

	return RenderJson(rw, app)
}
开发者ID:gmelika,项目名称:rack,代码行数:35,代码来源:apps.go

示例4: ParametersSet

func ParametersSet(rw http.ResponseWriter, r *http.Request) *httperr.Error {
	app := mux.Vars(r)["app"]

	a, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return httperr.Errorf(404, "no such app: %s", app)
	}

	if err != nil {
		return httperr.Server(err)
	}

	r.ParseMultipartForm(2048)

	params := map[string]string{}

	for key, values := range r.Form {
		params[key] = values[0]
	}

	err = a.UpdateParams(params)

	if err != nil {
		return httperr.Server(err)
	}

	return RenderSuccess(rw)
}
开发者ID:soulware,项目名称:rack,代码行数:29,代码来源:parameters.go

示例5: AppLogs

func AppLogs(ws *websocket.Conn) error {
	defer ws.Close()

	app := mux.Vars(ws.Request())["app"]

	a, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return fmt.Errorf("no such app: %s", app)
	}

	if err != nil {
		return err
	}

	logs := make(chan []byte)
	done := make(chan bool)

	a.SubscribeLogs(logs, done)

	for data := range logs {
		ws.Write(data)
	}

	return nil
}
开发者ID:jbuck,项目名称:rack,代码行数:26,代码来源:apps.go

示例6: ReleasePromote

func ReleasePromote(rw http.ResponseWriter, r *http.Request) *httperr.Error {
	vars := mux.Vars(r)
	app := vars["app"]
	release := vars["release"]

	_, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return httperr.Errorf(404, "no such app: %s", app)
	}

	rr, err := models.GetRelease(app, release)

	if err != nil && strings.HasPrefix(err.Error(), "no such release") {
		return httperr.Errorf(404, "no such release: %s", release)
	}

	if err != nil {
		return httperr.Server(err)
	}

	err = rr.Promote()

	if awsError(err) == "ValidationError" {
		return httperr.Errorf(403, err.(awserr.Error).Message())
	}

	if err != nil {
		return httperr.Server(err)
	}

	return RenderJson(rw, rr)
}
开发者ID:nicolas-brousse,项目名称:rack,代码行数:33,代码来源:releases.go

示例7: ProcessShow

func ProcessShow(rw http.ResponseWriter, r *http.Request) *httperr.Error {
	vars := mux.Vars(r)
	app := vars["app"]
	process := vars["process"]

	_, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return httperr.Errorf(404, "no such app: %s", app)
	}

	p, err := models.GetProcess(app, process)

	if err != nil {
		return httperr.Server(err)
	}

	err = p.FetchStats()

	if err != nil {
		return httperr.Server(err)
	}

	return RenderJson(rw, p)
}
开发者ID:soulware,项目名称:rack,代码行数:25,代码来源:processes.go

示例8: ProcessRunDetached

func ProcessRunDetached(rw http.ResponseWriter, r *http.Request) *httperr.Error {
	vars := mux.Vars(r)
	app := vars["app"]
	process := vars["process"]
	command := GetForm(r, "command")
	release := GetForm(r, "release")

	a, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return httperr.Errorf(404, "no such app: %s", app)
	}

	err = a.RunDetached(process, command, release)

	if err != nil {
		if strings.HasPrefix(err.Error(), "no such release") {
			return httperr.Errorf(404, err.Error())
		}

		return httperr.Server(err)
	}

	return RenderSuccess(rw)
}
开发者ID:gmelika,项目名称:rack,代码行数:25,代码来源:processes.go

示例9: BuildCreate

func BuildCreate(rw http.ResponseWriter, r *http.Request) *httperr.Error {
	vars := mux.Vars(r)
	app := vars["app"]

	cache := !(r.FormValue("cache") == "false")
	manifest := r.FormValue("manifest")
	description := r.FormValue("description")

	repo := r.FormValue("repo")
	index := r.FormValue("index")

	source, _, err := r.FormFile("source")
	if err != nil && err != http.ErrMissingFile && err != http.ErrNotMultipart {
		helpers.TrackError("build", err, map[string]interface{}{"at": "FormFile"})
		return httperr.Server(err)
	}

	// Log into private registries that we might pull from
	// TODO: move to prodiver BuildCreate
	err = models.LoginPrivateRegistries()
	if err != nil {
		return httperr.Server(err)
	}

	a, err := models.GetApp(app)
	if err != nil {
		return httperr.Server(err)
	}

	// Log into registry that we will push to
	_, err = models.AppDockerLogin(*a)
	if err != nil {
		return httperr.Server(err)
	}

	var b *structs.Build

	// if source file was posted, build from tar
	if source != nil {
		b, err = models.Provider().BuildCreateTar(app, source, r.FormValue("manifest"), r.FormValue("description"), cache)
	} else if repo != "" {
		b, err = models.Provider().BuildCreateRepo(app, repo, r.FormValue("manifest"), r.FormValue("description"), cache)
	} else if index != "" {
		var i structs.Index
		err := json.Unmarshal([]byte(index), &i)
		if err != nil {
			return httperr.Server(err)
		}

		b, err = models.Provider().BuildCreateIndex(app, i, manifest, description, cache)
	} else {
		return httperr.Errorf(403, "no source, repo or index")
	}

	if err != nil {
		return httperr.Server(err)
	}

	return RenderJson(rw, b)
}
开发者ID:gmelika,项目名称:rack,代码行数:60,代码来源:builds.go

示例10: ProcessStop

func ProcessStop(rw http.ResponseWriter, r *http.Request) error {
	vars := mux.Vars(r)
	app := vars["app"]
	process := vars["process"]

	_, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return RenderNotFound(rw, fmt.Sprintf("no such app: %s", app))
	}

	ps, err := models.GetProcess(app, process)

	if err != nil {
		return err
	}

	if ps == nil {
		return RenderNotFound(rw, fmt.Sprintf("no such process: %s", process))
	}

	err = ps.Stop()

	if err != nil {
		return err
	}

	return RenderJson(rw, ps)
}
开发者ID:jbuck,项目名称:rack,代码行数:29,代码来源:processes.go

示例11: AppLogs

func AppLogs(ws *websocket.Conn) *httperr.Error {
	app := mux.Vars(ws.Request())["app"]

	a, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return httperr.Errorf(404, "no such app: %s", app)
	}

	if err != nil {
		return httperr.Server(err)
	}

	logs := make(chan []byte)
	done := make(chan bool)

	a.SubscribeLogs(logs, done)

	go signalWsClose(ws, done)

	for data := range logs {
		ws.Write(data)
	}

	return nil
}
开发者ID:soulware,项目名称:rack,代码行数:26,代码来源:apps.go

示例12: ReleasePromote

func ReleasePromote(rw http.ResponseWriter, r *http.Request) error {
	vars := mux.Vars(r)
	app := vars["app"]
	release := vars["release"]

	_, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return RenderNotFound(rw, fmt.Sprintf("no such app: %s", app))
	}

	rr, err := models.GetRelease(app, release)

	if err != nil && strings.HasPrefix(err.Error(), "no such release") {
		return RenderNotFound(rw, fmt.Sprintf("no such release: %s", release))
	}

	if err != nil {
		return err
	}

	err = rr.Promote()

	if awsError(err) == "ValidationError" {
		return RenderForbidden(rw, err.(awserr.Error).Message())
	}

	if err != nil {
		return err
	}

	return RenderJson(rw, rr)
}
开发者ID:harryross,项目名称:rack,代码行数:33,代码来源:releases.go

示例13: AppDelete

func AppDelete(rw http.ResponseWriter, r *http.Request) *httperr.Error {
	name := mux.Vars(r)["app"]

	app, err := models.GetApp(name)

	if awsError(err) == "ValidationError" {
		return httperr.Errorf(404, "no such app: %s", name)
	}

	if err != nil {
		return httperr.Server(err)
	}

	if app.Tags["Type"] != "app" || app.Tags["System"] != "convox" || app.Tags["Rack"] != os.Getenv("RACK") {
		return httperr.Errorf(404, "invalid app: %s", name)
	}

	err = app.Delete()

	if err != nil {
		return httperr.Server(err)
	}

	return RenderSuccess(rw)
}
开发者ID:soulware,项目名称:rack,代码行数:25,代码来源:apps.go

示例14: FormationSet

func FormationSet(rw http.ResponseWriter, r *http.Request) error {
	vars := mux.Vars(r)
	app := vars["app"]
	process := vars["process"]
	count := GetForm(r, "count")
	memory := GetForm(r, "memory")

	_, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return RenderNotFound(rw, fmt.Sprintf("no such app: %s", app))
	}

	err = models.SetFormation(app, process, count, memory)

	if ae, ok := err.(awserr.Error); ok {
		if ae.Code() == "ValidationError" {
			switch {
			case strings.Index(ae.Error(), "No updates are to be performed") > -1:
				return fmt.Errorf("no updates are to be performed: %s", app)
			case strings.Index(ae.Error(), "can not be updated") > -1:
				return fmt.Errorf("app is already updating: %s", app)
			}
		}
	}

	if err != nil {
		return err
	}

	return RenderSuccess(rw)
}
开发者ID:harryross,项目名称:rack,代码行数:32,代码来源:formation.go

示例15: ReleaseShow

func ReleaseShow(rw http.ResponseWriter, r *http.Request) *httperr.Error {
	vars := mux.Vars(r)
	app := vars["app"]
	release := vars["release"]

	_, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		return httperr.Errorf(404, "no such app: %s", app)
	}

	rr, err := models.GetRelease(app, release)

	if err != nil && strings.HasPrefix(err.Error(), "no such release") {
		return httperr.Errorf(404, "no such release: %s", release)
	}

	fmt.Printf("err %+v\n", err)

	if err != nil {
		return httperr.Server(err)
	}

	return RenderJson(rw, rr)
}
开发者ID:nicolas-brousse,项目名称:rack,代码行数:25,代码来源:releases.go


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