helpers

package
v0.0.0-...-88c5504 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MPL-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const RequiredCliVersion string = "2.2.0"

RequiredCliVersion : ..

Variables

View Source
var (
	// AuthNonAdmin : Response body for non authorized requests on admin resources
	AuthNonAdmin = []byte(`{"message": "You don't have permissions to perform this action, please login with an admin account"}`)
	// AuthNonOwner : Response body for non authorized requests on owned resources
	AuthNonOwner = []byte(`{"message": "You don't have permissions to perform this action, please login as a resource owner"}`)
	// AuthNonReadable : Response body for non authorized requests on admin resources
	AuthNonReadable = []byte(`{"message": "You don't have permissions to perform this action, please contact the resource owner"}`)
	// GetProject : ...
	GetProject = "get_project"
	// DeleteProject : ...
	DeleteProject = "delete_project"
	// UpdateProject : ...
	UpdateProject = "update_project"
	// DeleteEnv : ...
	DeleteEnv = "delete_env"
	// DeleteEnvForce : ..
	DeleteEnvForce = "delete_env_force"
	// UpdateEnv : ...
	UpdateEnv = "update_env"
	// GetEnv : ...
	GetEnv = "get_environment"
	// SyncEnv : ...
	SyncEnv = "sync_env"
	// ListBuilds : ...
	ListBuilds = "list_builds"
	// DeleteBuild : ...
	DeleteBuild = "delete_build"
	// GetBuild : ...
	GetBuild = "get_build"
	// ResetBuild : ...
	ResetBuild = "reset_build"
	// SubmitBuild : ...
	SubmitBuild = "submit_build"
	// DiffBuild : ...
	DiffBuild = "diff_build"
	// GetPolicy : ...
	GetPolicy = "get_policy"
	// DeletePolicy : ...
	DeletePolicy = "delete_policy"
	// UpdatePolicy : ...
	UpdatePolicy = "update_policy"
)
View Source
var (
	// ErrUnauthorized : HTTP 403 error
	ErrUnauthorized = echo.NewHTTPError(http.StatusForbidden, "")
	// ErrNotFound : HTTP 404 error
	ErrNotFound = echo.NewHTTPError(http.StatusNotFound, "")
	// ErrBadReqBody : HTTP 400 error
	ErrBadReqBody = echo.NewHTTPError(http.StatusBadRequest, "")
	// ErrGatewayTimeout : HTTP 504 error
	ErrGatewayTimeout = echo.NewHTTPError(http.StatusGatewayTimeout, "")
	// ErrInternal : HTTP 500 error
	ErrInternal = echo.NewHTTPError(http.StatusInternalServerError, "")
	// ErrNotImplemented : HTTP 405 error
	ErrNotImplemented = echo.NewHTTPError(http.StatusNotImplemented, "")
	// ErrExists : HTTP Error
	ErrExists = echo.NewHTTPError(http.StatusSeeOther, "")
)
View Source
var L = logrus.New()

L : API-gateway logger

Functions

func Bool

func Bool(b bool) *bool

Bool : ...

func ErrMessage

func ErrMessage(msg string) []byte

ErrMessage prepares a message string to be responded

func GetAuthorizedParamFilter

func GetAuthorizedParamFilter(c echo.Context, au User) map[string]interface{}

GetAuthorizedParamFilter : Get filters based on the params defined on the url

func GetParamFilter

func GetParamFilter(c echo.Context) map[string]interface{}

GetParamFilter : Returns a filter based on parameters defined on the url stem

func GetRequestBody

func GetRequestBody(c echo.Context) ([]byte, error)

GetRequestBody : Get the request body

func GetSearchFilter

func GetSearchFilter(c echo.Context) map[string]interface{}

GetSearchFilter : Returns a filter based on url query values from the request

func IsAuthorized

func IsAuthorized(au User, resource string) (int, []byte)

IsAuthorized : Validates if the given user has access to the given resource

func IsAuthorizedToReadResource

func IsAuthorizedToReadResource(au User, endpoint, resource, resourceID string) (int, []byte)

IsAuthorizedToReadResource : check if the user is authorized to read only access a specific resource

func IsAuthorizedToResource

func IsAuthorizedToResource(au User, endpoint, resource, resourceID string) (int, []byte)

IsAuthorizedToResource : check if the user is authorized to access a specific resource

func IsLicensed

func IsLicensed(au User, resource string) (int, []byte)

IsLicensed : checks if the action being performed is licensed

func Licensed

func Licensed() error

Licensed : Checks if the current api is running with premium support

func Respond

func Respond(c echo.Context, st int, b []byte) error

Respond : manage responses

func ValidCliVersion

func ValidCliVersion(r *http.Request) error

ValidCliVersion checks to see if the client version meets minimum requirements

Types

type ResponseError

type ResponseError struct {
	Error     string          `json:"_error"`
	Code      string          `json:"_code"`
	HTTPError *echo.HTTPError `json:"-"`
}

ResponseError is

func ResponseErr

func ResponseErr(msg *nats.Msg) *ResponseError

ResponseErr : ..

type User

type User interface {
	GetAdmin() bool
	IsOwner(resourceType, resourceID string) bool
	IsReader(resourceType, resourceID string) bool
}

User : interface for users

Jump to

Keyboard shortcuts

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