controllers

package
v0.0.0-...-1045ef1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WSUpgrader = websocket.Upgrader{
	CheckOrigin: func(r *http.Request) bool {
		s := r.Context().Value("session").(session.Session)
		if !s.IsValid() {
			return false
		}
		return true
	},
}

WSUpgrader upgrades HTTP connections to WebSocket connections

Functions

func AuthenticateClientJWT

func AuthenticateClientJWT(w http.ResponseWriter, r *http.Request)

AuthenticateClientJWT authenticates a client signed jwt token. This usually gets called after a call to /login. The login route returns a server phrase which is signed using the clients private auth. To authenticate the clients signed token this route is called and the token is validated against the clients public auth on the host machine.

func CreateOrUpdateDeployment

func CreateOrUpdateDeployment(w http.ResponseWriter, r *http.Request)

CreateOrUpdateDeployment saves a deployment configuration

func CreateOrUpdateSecret

func CreateOrUpdateSecret(w http.ResponseWriter, r *http.Request)

CreateOrUpdateSecret saves a deployment secret

func CreateSession

func CreateSession(w http.ResponseWriter, r *http.Request)

CreateSession returns a session with an active access token. Access tokens are useful for CI

func DeleteDeployment

func DeleteDeployment(w http.ResponseWriter, r *http.Request)

DeleteDeployment deletes a deployments container resources and configuration

func DeleteSecret

func DeleteSecret(w http.ResponseWriter, r *http.Request)

DeleteSecret removes a deployment secret

func DeleteSession

func DeleteSession(w http.ResponseWriter, r *http.Request)

DeleteSession will delete a session revoking any further request using that session token

func GetAllDeployments

func GetAllDeployments(w http.ResponseWriter, _ *http.Request)

GetAllDeployments returns a list of deployments with their configurations, containers and recent activity

func GetDeployment

func GetDeployment(w http.ResponseWriter, r *http.Request)

GetDeployment returns a deployments and it configuration, containers and recent activity

func GetDeploymentContainers

func GetDeploymentContainers(w http.ResponseWriter, r *http.Request)

GetDeploymentContainers returns all containers for a deployment

func GetJobByID

func GetJobByID(w http.ResponseWriter, r *http.Request)

GetJobByID returns a job by id

func GetJobsByDaysAgo

func GetJobsByDaysAgo(w http.ResponseWriter, r *http.Request)

GetJobsByDaysAgo returns all deployment jobs within a date range (default is `7` days ago)

func GetJobsByDeployment

func GetJobsByDeployment(w http.ResponseWriter, r *http.Request)

GetJobsByDeployment returns all jobs within a date range (default is 7d ago)

func GetSecrets

func GetSecrets(w http.ResponseWriter, r *http.Request)

GetSecrets returns all secrets for a deployment

func GetSessions

func GetSessions(w http.ResponseWriter, _ *http.Request)

GetSessions returns a list of user sessions. A session is an authenticated client with a valid access token

func HealthCheck

func HealthCheck(w http.ResponseWriter, r *http.Request)

HealthCheck returns the health and status of the running Krane instance

func RequestLoginPhrase

func RequestLoginPhrase(w http.ResponseWriter, _ *http.Request)

RequestLoginPhrase request a preliminary login request for authentication with the krane server. This will return a request id and phrase. The phrase should be encrypted using the clients private key. This route does not return a token. You must use /auth and provide the signed phrase.

func RestartDeploymentContainers

func RestartDeploymentContainers(w http.ResponseWriter, r *http.Request)

RestartDeploymentContainers re-creates all containers for a deployment Note: this is the same as calling /deployments/{deployment} since both re-create container resources

func RootPath

func RootPath(w http.ResponseWriter, _ *http.Request)

RootPath returns a plain-text response and 200 OK

func RunDeployment

func RunDeployment(w http.ResponseWriter, r *http.Request)

RunDeployment triggers a deployment run creating container resources

func StartDeploymentContainers

func StartDeploymentContainers(w http.ResponseWriter, r *http.Request)

StartDeploymentContainers starts all containers (if any) for a deployment Note: this does not create any containers, only start already existing ones

func StopDeploymentContainers

func StopDeploymentContainers(w http.ResponseWriter, r *http.Request)

StopDeploymentContainers stops all containers (if any) for a deployment Note: this does not create any containers, only stops already existing ones

func SubscribeToContainerLogs

func SubscribeToContainerLogs(w http.ResponseWriter, r *http.Request)

SubscribeToContainerLogs opens a websocket connection and subscribes the client to container logs

func SubscribeToDeploymentEvents

func SubscribeToDeploymentEvents(w http.ResponseWriter, r *http.Request)

SubscribeToDeploymentEvents opens a websocket connection and subscribes the client to deployment events

func SubscribeToDeploymentLogs

func SubscribeToDeploymentLogs(w http.ResponseWriter, r *http.Request)

SubscribeToDeploymentLogs opens a websocket connection and subscribes the client to deployment events

Types

type AuthRequest

type AuthRequest struct {
	RequestID string `json:"request_id" binding:"required"`
	Token     string `json:"token" binding:"required"`
}

AuthRequest represents the payload expected when authenticating with Krane

type LoginResponse

type LoginResponse struct {
	RequestID string `json:"request_id"`
	Phrase    string `json:"phrase"`
}

LoginResponse is the response received when you initially want to authenticate. The request_id is a uuid stored for future validation and the phrase is a generated phrased containing that request_id meant to be signed by the clients private key to later be unsigned by the clients public key to establish an authenticated sessions

Jump to

Keyboard shortcuts

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