handlers

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2016 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateDeploymentHandler deployments.CreateDeploymentHandlerFunc = func(params deployments.CreateDeploymentParams, principal interface{}) middleware.Responder {
	var r middleware.ResponderFunc = func(rw http.ResponseWriter, pr runtime.Producer) {
		appID := uint(params.AppID)

		sa := storage.Application{}
		sa.ID = appID

		fw := newFlushResponseWriter(rw)

		if storage.DB.Where(&storage.Application{TeamID: uint(params.TeamID)}).Preload("Team").Preload("EnvVars").Preload("Deployments").First(&sa).RecordNotFound() {
			log.Println("app info not found")
			fw.Write([]byte("App or team invalid... stopping proccess."))

			return
		}

		x := newDeployParams(&sa)
		teresaResp := &teresaResponder{
			params:           x,
			appID:            appID,
			description:      params.Description,
			errorDescription: "",
			fw:               fw,
		}
		log.Printf("starting deploy proccess [%s/%s/%s]\n", x.teamName, x.appName, x.id)

		if err := uploadArchiveToStorage(&x.storageIn, &params.AppTarball); err != nil {
			teresaResp.run(err, "uploading app tarball")
			return
		}

		fw.Println("Starting the build")
		if err := buildAppSlug(x, fw); err != nil {
			deleteArchiveOnStorage(&x.storageIn)
			teresaResp.run(err, "building app")
			return
		}

		deploy, err := getDeploy(x)
		if err != nil {
			deleteArchiveOnStorage(&x.storageIn)
			teresaResp.run(err, "get existant deploy")
			return
		}
		if deploy == nil {

			if _, err = createSlugRunnerDeploy(x, &sa); err != nil {
				deleteArchiveOnStorage(&x.storageIn)
				teresaResp.run(err, "creating deploy")
				return
			}

			fw.Println("creating the load balancer...")
			lbHostName, err := createServiceAndGetLBHostName(x)
			if err != nil {
				deleteDeploy(x)
				deleteArchiveOnStorage(&x.storageIn)
				teresaResp.run(err, "creating service")
				return
			}

			saa := storage.AppAddress{
				Address: lbHostName,
				AppID:   appID,
			}
			storage.DB.Create(&saa)
		} else {
			if _, err := updateSlugRunnerDeploySlug(x, deploy); err != nil {
				deleteArchiveOnStorage(&x.storageIn)
				teresaResp.run(err, "rolling update deploy")
				return
			}
		}
		teresaResp.run(nil, "deployment process finished succesfully")
	}
	return r
}

CreateDeploymentHandler handler triggered when a deploy url is requested

Functions

func AddUserToTeam

func AddUserToTeam(params teams.AddUserToTeamParams, principal interface{}) middleware.Responder

AddUserToTeam add user to a specific team

func CreateAppHandler

func CreateAppHandler(params apps.CreateAppParams, principal interface{}) middleware.Responder

CreateAppHandler create apps

func CreateTeamHandler

func CreateTeamHandler(params teams.CreateTeamParams, principal interface{}) middleware.Responder

CreateTeamHandler ...

func CreateUserHandler

func CreateUserHandler(params users.CreateUserParams, principal interface{}) middleware.Responder

CreateUserHandler ...

func DeleteTeamHandler

func DeleteTeamHandler(params teams.DeleteTeamParams, principal interface{}) middleware.Responder

DeleteTeamHandler ...

func DeleteUserHandler

func DeleteUserHandler(params users.DeleteUserParams, principal interface{}) middleware.Responder

DeleteUserHandler ...

func GetAppDetailsHandler

func GetAppDetailsHandler(params apps.GetAppDetailsParams, principal interface{}) middleware.Responder

GetAppDetailsHandler return app details

func GetAppsHandler

func GetAppsHandler(params apps.GetAppsParams, principal interface{}) middleware.Responder

GetAppsHandler return apps for a team

func GetCurrentUserHandler

func GetCurrentUserHandler(principal interface{}) middleware.Responder

GetCurrentUserHandler ...

func GetTeamDetailsHandler

func GetTeamDetailsHandler(params teams.GetTeamDetailParams, principal interface{}) middleware.Responder

GetTeamDetailsHandler ...

func GetTeamsHandler

func GetTeamsHandler(params teams.GetTeamsParams, principal interface{}) middleware.Responder

GetTeamsHandler ...

func GetUserDetailsHandler

func GetUserDetailsHandler(params users.GetUserDetailsParams, principal interface{}) middleware.Responder

GetUserDetailsHandler ...

func LoginHandler

func LoginHandler(params auth.UserLoginParams) middleware.Responder

LoginHandler validates a user

func PartialUpdateAppHandler

func PartialUpdateAppHandler(params apps.PartialUpdateAppParams, principal interface{}) middleware.Responder

PartialUpdateAppHandler partial updating app... only envvars for now

func TokenAuthHandler

func TokenAuthHandler(t string) (interface{}, error)

TokenAuthHandler try and validate the jwt token

func UpdateTeamHandler

func UpdateTeamHandler(params teams.UpdateTeamParams, principal interface{}) middleware.Responder

UpdateTeamHandler ...

Types

type BuilderConfig

type BuilderConfig struct {
	AwsKey     string        `envconfig:"storage_aws_key"`
	AwsSecret  string        `envconfig:"storage_aws_secret"`
	AwsRegion  string        `envconfig:"storage_aws_region"`
	AwsBucket  string        `envconfig:"storage_aws_bucket"`
	PodTimeout time.Duration `envconfig:"wait_pod_timeout" default:"3m"`
	LBTimeout  time.Duration `envconfig:"wait_lb_timeout" default:"5m"`
}

BuilderConfig struct to accommodate the builder config

type K8sConfig

type K8sConfig struct {
	Host     string `required:"true"`
	Username string `required:"true"`
	Password string `required:"true"`
	Insecure bool   `default:"false"`
}

K8sConfig struct to accommodate the k8s env config

type Token

type Token struct {
	UserID  uint   `json:"userId"`
	Email   string `json:"email"`
	IsAdmin bool   `json:"isAdmin"`
	jwt.StandardClaims
}

Token foo bar

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL