api

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorDataWrite describes an error in writing to the database
	ErrorDataWrite = HTTPError{
		Code: 500,
		Errors: []string{
			"could not write to database",
		},
	}

	// ErrorDataRead describes an error when reading from the database
	ErrorDataRead = HTTPError{
		Code: 500,
		Errors: []string{
			"could not read from database",
		},
	}

	// ErrorInternal describes a generic internal server error
	ErrorInternal = HTTPError{
		Code: 500,
		Errors: []string{
			"internal server error",
		},
	}
)

Functions

This section is empty.

Types

type App

type App struct {
	TestAgents *TestAgents
	// contains filtered or unexported fields
}

App represents an API instance with handler methods attached, a DB connection and a logger instance

func New

func New(
	logger *lr.Logger,
	repo *repository.Repository,
	validator *validator.Validate,
	store sessions.Store,
	cookieName string,
	testing bool,
) *App

New returns a new App instance

func (*App) HandleAuthCheck

func (app *App) HandleAuthCheck(w http.ResponseWriter, r *http.Request)

HandleAuthCheck checks whether current session is authenticated and returns user ID if so.

func (*App) HandleCreateUser

func (app *App) HandleCreateUser(w http.ResponseWriter, r *http.Request)

HandleCreateUser validates a user form entry, converts the user to a gorm model, and saves the user to the database

func (*App) HandleDeleteUser

func (app *App) HandleDeleteUser(w http.ResponseWriter, r *http.Request)

HandleDeleteUser removes a user after checking that the sent password is correct

func (*App) HandleGetRelease

func (app *App) HandleGetRelease(w http.ResponseWriter, r *http.Request)

HandleGetRelease retrieves a single release based on a name and revision

func (*App) HandleGetReleaseComponents

func (app *App) HandleGetReleaseComponents(w http.ResponseWriter, r *http.Request)

HandleGetReleaseComponents retrieves a single release based on a name and revision

func (*App) HandleListNamespaces

func (app *App) HandleListNamespaces(w http.ResponseWriter, r *http.Request)

HandleListNamespaces retrieves a list of namespaces

func (*App) HandleListReleaseHistory

func (app *App) HandleListReleaseHistory(w http.ResponseWriter, r *http.Request)

HandleListReleaseHistory retrieves a history of releases based on a release name

func (*App) HandleListReleases

func (app *App) HandleListReleases(w http.ResponseWriter, r *http.Request)

HandleListReleases retrieves a list of releases for a cluster with various filter options

func (*App) HandleLoginUser

func (app *App) HandleLoginUser(w http.ResponseWriter, r *http.Request)

HandleLoginUser checks the request header for cookie and validates the user.

func (*App) HandleLogoutUser

func (app *App) HandleLogoutUser(w http.ResponseWriter, r *http.Request)

HandleLogoutUser detaches the user from the session

func (*App) HandleReadUser

func (app *App) HandleReadUser(w http.ResponseWriter, r *http.Request)

HandleReadUser returns an externalized User (models.UserExternal) based on an ID

func (*App) HandleReadUserContexts

func (app *App) HandleReadUserContexts(w http.ResponseWriter, r *http.Request)

HandleReadUserContexts returns the externalized User.Contexts ([]models.Context) based on a user ID

func (*App) HandleRollbackRelease

func (app *App) HandleRollbackRelease(w http.ResponseWriter, r *http.Request)

HandleRollbackRelease rolls a release back to a specified revision

func (*App) HandleUpdateUser

func (app *App) HandleUpdateUser(w http.ResponseWriter, r *http.Request)

HandleUpdateUser validates an update user form entry, updates the user in the database, and writes status accepted

func (*App) HandleUpgradeRelease

func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request)

HandleUpgradeRelease upgrades a release with new values.yaml

func (*App) Logger

func (app *App) Logger() *lr.Logger

Logger returns the logger instance in use by App

type ErrorCode

type ErrorCode int64

ErrorCode is a custom Porter error code, useful for frontend messages

const (
	ErrK8sDecode ErrorCode = iota + 600
	ErrK8sValidate
)

Enumeration of k8s API error codes, represented as int64

const (
	ErrReleaseDecode ErrorCode = iota + 600
	ErrReleaseValidateFields
	ErrReleaseReadData
	ErrReleaseDeploy
)

Enumeration of release API error codes, represented as int64

const (
	ErrUserDecode ErrorCode = iota + 600
	ErrUserValidateFields
	ErrUserDataRead
)

Enumeration of user API error codes, represented as int64

type HTTPError

type HTTPError struct {
	Code   ErrorCode `json:"code"`
	Errors []string  `json:"errors"`
}

HTTPError is the object returned when the API encounters an error: this gets marshaled into JSON

type TestAgents

type TestAgents struct {
	HelmAgent             *helm.Agent
	HelmTestStorageDriver *storage.Storage
	K8sAgent              *kubernetes.Agent
}

TestAgents are the k8s agents used for testing

Jump to

Keyboard shortcuts

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