Documentation ¶
Index ¶
- Variables
- func AddUserToTeam(params teams.AddUserToTeamParams, principal interface{}) middleware.Responder
- func CreateTeamHandler(params teams.CreateTeamParams, principal interface{}) middleware.Responder
- func CreateUserHandler(params users.CreateUserParams, principal interface{}) middleware.Responder
- func DeleteTeamHandler(params teams.DeleteTeamParams, principal interface{}) middleware.Responder
- func DeleteUserHandler(params users.DeleteUserParams, principal interface{}) middleware.Responder
- func GetCurrentUserHandler(principal interface{}) middleware.Responder
- func GetTeamDetailsHandler(params teams.GetTeamDetailParams, principal interface{}) middleware.Responder
- func GetTeamsHandler(params teams.GetTeamsParams, principal interface{}) middleware.Responder
- func GetUserDetailsHandler(params users.GetUserDetailsParams, principal interface{}) middleware.Responder
- func LoginHandler(params auth.UserLoginParams) middleware.Responder
- func TokenAuthHandler(t string) (interface{}, error)
- func UpdateTeamHandler(params teams.UpdateTeamParams, principal interface{}) middleware.Responder
- type GenericError
- func NewBadRequestError(message ...interface{}) *GenericError
- func NewConflictError(message ...interface{}) *GenericError
- func NewForbiddenError() *GenericError
- func NewGenericError(code int32, message ...interface{}) *GenericError
- func NewInternalServerError(message ...interface{}) *GenericError
- func NewNotFoundError(message ...interface{}) *GenericError
- func NewUnauthorizedError(message ...interface{}) *GenericError
- type Reason
Constants ¶
This section is empty.
Variables ¶
var CreateAppHandler apps.CreateAppHandlerFunc = func(params apps.CreateAppParams, principal interface{}) middleware.Responder { tk := k8s.IToToken(principal) app := &models.App{AppIn: *params.Body} l := log.WithField("app", *app.Name).WithField("team", *app.Team).WithField("token", *tk.Email).WithField("requestId", helpers.NewShortUUID()) if err := k8s.Client.Apps().Create(app, helpers.FileStorage, tk); err != nil { if k8s.IsInputError(err) { l.WithError(err).Warn("error creating app") return NewBadRequestError(err) } else if k8s.IsAlreadyExistsError(err) { l.WithError(err).Debug("error creating app") return NewConflictError("app already exists") } else if k8s.IsUnauthorizedError(err) { l.WithError(err).Debug("error creating app") return NewUnauthorizedError("either the team doesn't exist or the user doesn't have access to it") } l.WithError(err).Error("error creating app") return NewInternalServerError(err) } return apps.NewCreateAppCreated().WithPayload(app) }
CreateAppHandler handler for "-X POST /apps"
var CreateDeploymentHandler deployments.CreateDeploymentHandlerFunc = func(params deployments.CreateDeploymentParams, principal interface{}) middleware.Responder { var r middleware.ResponderFunc = func(rw http.ResponseWriter, pr runtime.Producer) { tk := k8s.IToToken(principal) var description string if params.Description != nil { description = *params.Description } l := log.WithField("app", params.AppName).WithField("token", *tk.Email).WithField("requestId", helpers.NewShortUUID()) r, err := k8s.Client.Deployments().Create(params.AppName, description, ¶ms.AppTarball, helpers.FileStorage, tk) if err != nil { // FIXME: improve this... is it possible? var httpErr *GenericError if k8s.IsInputError(err) { l.WithError(err).Warn("error during deploy") httpErr = NewBadRequestError(err) } else if k8s.IsUnauthorizedError(err) { l.WithError(err).Warn("error during deploy") httpErr = NewUnauthorizedError(err) } else { l.WithError(err).Error("error during deploy") httpErr = NewInternalServerError(err) } rw.WriteHeader(int(*httpErr.Payload.Code)) rw.Write([]byte(*httpErr.Payload.Message)) return } l.Debug("starting the streaming of the build") defer r.Close() w := newFlushResponseWriter(rw) io.Copy(w, r) } return r }
CreateDeploymentHandler handler triggered when a deploy url is requested
var (
ErrMissingKey = std_errors.New("Missing key")
)
var GetAppDetailsHandler apps.GetAppDetailsHandlerFunc = func(params apps.GetAppDetailsParams, principal interface{}) middleware.Responder { tk := k8s.IToToken(principal) l := log.WithField("app", params.AppName).WithField("token", *tk.Email).WithField("requestId", helpers.NewShortUUID()) app, err := k8s.Client.Apps().Get(params.AppName, tk) if err != nil { if k8s.IsNotFoundError(err) { l.WithError(err).Debug("error getting app details") return NewNotFoundError(err) } else if k8s.IsUnauthorizedError(err) { l.WithError(err).Info("error getting app details") return NewUnauthorizedError(err) } l.WithError(err).Error("error getting app details") return NewInternalServerError(err) } return apps.NewGetAppDetailsOK().WithPayload(app) }
GetAppDetailsHandler return app details
var GetAppLogsHandler apps.GetAppLogsHandlerFunc = func(params apps.GetAppLogsParams, principal interface{}) middleware.Responder { var r middleware.ResponderFunc = func(rw http.ResponseWriter, pr runtime.Producer) { tk := k8s.IToToken(principal) opts := &api.PodLogOptions{ Follow: *params.Follow, TailLines: params.Lines, } l := log.WithField("app", params.AppName).WithField("token", *tk.Email).WithField("requestId", helpers.NewShortUUID()) r, err := k8s.Client.Apps().GetLogs(params.AppName, tk, opts) if err != nil { var httpErr *GenericError if k8s.IsInputError(err) { l.WithError(err).Warn("error requesting logs") httpErr = NewBadRequestError(err) } else if k8s.IsUnauthorizedError(err) { l.WithError(err).Warn("error requesting logs") httpErr = NewUnauthorizedError(err) } else if k8s.IsNotFoundError(err) { l.WithError(err).Warn("error requesting logs") httpErr = NewNotFoundError(err) } else { l.WithError(err).Warn("error requesting logs") httpErr = NewInternalServerError(err) } rw.WriteHeader(int(*httpErr.Payload.Code)) rw.Write([]byte(*httpErr.Payload.Message)) return } defer r.Close() w := newFlushResponseWriter(rw) io.Copy(w, r) } return r }
var GetAppsHandler apps.GetAppsHandlerFunc = func(params apps.GetAppsParams, principal interface{}) middleware.Responder { tk := k8s.IToToken(principal) l := log.WithField("token", *tk.Email).WithField("requestId", helpers.NewShortUUID()) appList, err := k8s.Client.Apps().List(tk) if err != nil { if k8s.IsNotFoundError(err) { l.WithError(err).Debug("error getting app list") return NewNotFoundError(err) } l.WithError(err).Error("error getting app list") return NewInternalServerError(err) } return apps.NewGetAppsOK().WithPayload(appList) }
GetAppsHandler returns all apps for the user
var PartialUpdateAppHandler apps.PartialUpdateAppHandlerFunc = func(params apps.PartialUpdateAppParams, principal interface{}) middleware.Responder { tk := k8s.IToToken(principal) l := log.WithField("app", params.AppName).WithField("token", *tk.Email).WithField("requestId", helpers.NewShortUUID()) app, err := k8s.Client.Apps().UpdateEnvVars(params.AppName, params.Body, helpers.FileStorage, tk) if err != nil { if k8s.IsInputError(err) { l.WithError(err).Warn("error on app partial update") return NewBadRequestError(err) } else if k8s.IsNotFoundError(err) { l.WithError(err).Debug("error on app partial update") return NewNotFoundError(err) } else if k8s.IsUnauthorizedError(err) { l.WithError(err).Warn("error on app partial update") return NewUnauthorizedError(err) } l.WithError(err).Error("error on app partial update") return NewInternalServerError(err) } return apps.NewPartialUpdateAppOK().WithPayload(app) }
PartialUpdateAppHandler partial updating app... only envvars for now
var UpdateAppAutoScaleHandler apps.UpdateAppAutoScaleHandlerFunc = func(params apps.UpdateAppAutoScaleParams, principal interface{}) middleware.Responder { tk := k8s.IToToken(principal) l := log.WithField("app", params.AppName).WithField("token", *tk.Email).WithField("requestId", helpers.NewShortUUID()) app, err := k8s.Client.Apps().UpdateAutoScale(params.AppName, params.Body, helpers.FileStorage, tk) if err != nil { if k8s.IsInputError(err) { l.WithError(err).Warn("error updating the app auto scale") return NewBadRequestError(err) } else if k8s.IsNotFoundError(err) { l.WithError(err).Debug("error updating the app auto scale") return NewNotFoundError(err) } else if k8s.IsUnauthorizedError(err) { l.WithError(err).Warn("error updating the app auto scale") return NewUnauthorizedError(err) } l.WithError(err).Error("error updating the app auto scale") return NewInternalServerError(err) } l.Debug(`app auto scale updated with success`) return apps.NewUpdateAppAutoScaleOK().WithPayload(app) }
UpdateAppAutoScaleHandler update app autoscale info
var UpdateAppHandler apps.UpdateAppHandlerFunc = func(params apps.UpdateAppParams, principal interface{}) middleware.Responder { return middleware.NotImplemented("operation apps.UpdateAppHandlerFunc has not yet been implemented") }
UpdateAppHandler handler for update app
var UpdateAppScaleHandler apps.UpdateAppScaleHandlerFunc = func(params apps.UpdateAppScaleParams, principal interface{}) middleware.Responder { tk := k8s.IToToken(principal) l := log.WithField("app", params.AppName).WithField("token", *tk.Email).WithField("requestId", helpers.NewShortUUID()) app, err := k8s.Client.Apps().UpdateScale(params.AppName, *params.Body.Scale, helpers.FileStorage, tk) if err != nil { if k8s.IsInputError(err) { l.WithError(err).Warn("error updating app scale") return NewBadRequestError(err) } else if k8s.IsNotFoundError(err) { l.WithError(err).Debug("error updating app scale") return NewNotFoundError(err) } else if k8s.IsUnauthorizedError(err) { l.WithError(err).Warn("error updating app scale") return NewUnauthorizedError(err) } l.WithError(err).Error("error updating app scale") return NewInternalServerError(err) } l.Debugf(`app scale updated with success to: %d`, app.Scale) return apps.NewUpdateAppScaleOK().WithPayload(app) }
UpdateAppScaleHandler handler for app scale -XPUT
Functions ¶
func AddUserToTeam ¶
func AddUserToTeam(params teams.AddUserToTeamParams, principal interface{}) middleware.Responder
AddUserToTeam add user to a specific team
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 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 TokenAuthHandler ¶
TokenAuthHandler try and validate the jwt token
func UpdateTeamHandler ¶
func UpdateTeamHandler(params teams.UpdateTeamParams, principal interface{}) middleware.Responder
UpdateTeamHandler ...
Types ¶
type GenericError ¶ added in v0.2.0
GenericError is used to help when returning simple and descritive errors to the api
func NewBadRequestError ¶ added in v0.2.0
func NewBadRequestError(message ...interface{}) *GenericError
NewBadRequestError returns a Bad Request (http status code 400) to the Api
func NewConflictError ¶ added in v0.2.0
func NewConflictError(message ...interface{}) *GenericError
NewConflictError returns a Conflict Error (http status code 409) to the Api
func NewForbiddenError ¶ added in v0.2.0
func NewForbiddenError() *GenericError
NewForbiddenError returns a Forbidden Error (http status code 403) to the Api
func NewGenericError ¶ added in v0.2.0
func NewGenericError(code int32, message ...interface{}) *GenericError
NewGenericError is a helper to create a GenericError
func NewInternalServerError ¶ added in v0.2.0
func NewInternalServerError(message ...interface{}) *GenericError
NewInternalServerError returns a Internal Server Error (http status code 500) to the Api
func NewNotFoundError ¶ added in v0.2.0
func NewNotFoundError(message ...interface{}) *GenericError
NewNotFoundError returns a Not Found Error (http status code 404) to the Api
func NewUnauthorizedError ¶ added in v0.2.0
func NewUnauthorizedError(message ...interface{}) *GenericError
NewUnauthorizedError returns a Unauthorized Error (http status code 401) to the Api
func (*GenericError) WithMessage ¶ added in v0.2.0
func (e *GenericError) WithMessage(message string) *GenericError
WithMessage add a message to the error
func (*GenericError) WithReason ¶ added in v0.2.0
func (e *GenericError) WithReason(reason Reason) *GenericError
WithReason add a reason to the error
func (*GenericError) WriteResponse ¶ added in v0.2.0
func (e *GenericError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer)
WriteResponse to fits the interface of middleware.Responder