api

package
v0.1.0-beta.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorUpgradeWebsocket describes an error while upgrading http to a websocket endpoint.
	ErrorUpgradeWebsocket = HTTPError{
		Code: 500,
		Errors: []string{
			"could not upgrade to websocket",
		},
	}

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

	// ErrorWebsocketWrite describes an error in writing to websocket connection
	ErrorWebsocketWrite = HTTPError{
		Code: 500,
		Errors: []string{
			"could not write data via websocket",
		},
	}

	// 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
	GithubConfig *oauth2.Config
	// 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,
	db *gorm.DB,
	repo *repository.Repository,
	validator *validator.Validate,
	store sessions.Store,
	cookieName string,
	testing bool,
	isLocal bool,
	githubConfig *oauth.Config,
) *App

New returns a new App instance TODO -- this should accept an app/server config

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) HandleCreateAWSIntegration

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

HandleCreateAWSIntegration creates a new AWS integration in the DB

func (*App) HandleCreateGCPIntegration

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

HandleCreateGCPIntegration creates a new GCP integration in the DB

func (*App) HandleCreateProject

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

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

func (*App) HandleCreateProjectClusterCandidates

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

HandleCreateProjectClusterCandidates handles the creation of ClusterCandidates using a kubeconfig and a project id

func (*App) HandleCreateRegistry

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

HandleCreateRegistry creates a new registry

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) HandleDeleteProject

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

HandleDeleteProject deletes a project from the db, reading from the project_id in the URL param

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) HandleDeployTemplate

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

HandleDeployTemplate triggers a chart deployment from a template

func (*App) HandleGetPodLogs

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

HandleGetPodLogs returns real-time logs of the pod via websockets TODO: Refactor repeated calls.

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 kubernetes objects listed in a release identified by name and revision

func (*App) HandleGetReleaseControllers

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

HandleGetReleaseControllers retrieves controllers that belong to a release. Used to display status of charts.

func (*App) HandleListClusterIntegrations

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

HandleListClusterIntegrations lists the cluster integrations available to the instance

func (*App) HandleListImages

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

HandleListImages retrieves a list of repo names

func (*App) HandleListNamespaces

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

HandleListNamespaces retrieves a list of namespaces

func (*App) HandleListPods

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

HandleListPods returns all pods that match the given selectors TODO: Refactor repeated calls.

func (*App) HandleListProjectClusterCandidates

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

HandleListProjectClusterCandidates returns a list of externalized ClusterCandidates ([]models.ClusterCandidateExternal) based on a project ID

func (*App) HandleListProjectClusters

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

HandleListProjectClusters returns a list of clusters that have linked Integrations.

func (*App) HandleListProjectRegistries

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

HandleListProjectRegistries returns a list of registries for a project

func (*App) HandleListRegistryIntegrations

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

HandleListRegistryIntegrations lists the image registry integrations available to the instance

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) HandleListRepoIntegrations

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

HandleListRepoIntegrations lists the repo integrations available to the instance

func (*App) HandleListRepositories

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

HandleListRepositories returns a list of repositories for a given registry

func (*App) HandleListTemplates

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

HandleListTemplates retrieves a list of Porter templates TODO: test and reduce fragility (handle untar/parse error for individual charts) TODO: separate markdown retrieval into its own query if necessary

func (*App) HandleListUserProjects

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

HandleListUserProjects lists all projects belonging to a given user

func (*App) HandleLive

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

HandleLive responds immediately with an HTTP 200 status.

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) HandleReadProject

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

HandleReadProject returns an externalized Project (models.ProjectExternal) based on an ID

func (*App) HandleReadProjectCluster

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

HandleReadProjectCluster reads a cluster by id

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) HandleReady

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

HandleReady responds with HTTP 200 if healthy, 500 otherwise

func (*App) HandleResolveClusterCandidate

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

HandleResolveClusterCandidate accepts a list of resolving objects (ClusterResolver) for a given ClusterCandidate, which "resolves" that ClusterCandidate and creates a Cluster for a specific project

func (*App) HandleRollbackRelease

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

HandleRollbackRelease rolls a release back to a specified revision

func (*App) HandleStreamControllerStatus

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

HandleStreamControllerStatus test calls TODO: Refactor repeated calls.

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 (
	ErrProjectDecode ErrorCode = iota + 600
	ErrProjectValidateFields
	ErrProjectDataRead
)

Enumeration of user 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