api

package
v0.0.0-...-04c1da9 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 53 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchToken

func FetchToken(db *gorm.DB, tfoResourceSpec models.TFOResourceSpec, tenant, clusterName, apiURL string) string

func GetApiURL

func GetApiURL(c *gin.Context, serviceIP *string) string

func IsWorkflowRunning

func IsWorkflowRunning(status tfv1beta1.TerraformStatus) bool

Take into account pod phases as well as task state to determine if the workflow is still running.

func RemoteDebug

func RemoteDebug(parentClientset kubernetes.Interface, clusterName, namespace, name string, tty *os.File, c *gin.Context, terminalSizeQueue remotecommand.TerminalSizeQueue, cmd []string) error

RemoteDebug starts the debug pod and connects in a tty that will be synced thru a websocket. Anything written to stdout will be synced to the tty. stderr logs will show up in the api logs and not the tty.

func Reverse

func Reverse[T any](input []T) []T

Types

type APIHandler

type APIHandler struct {
	Server *gin.Engine
	DB     *gorm.DB

	Cache *cache.Cache
	// contains filtered or unexported fields
}

func NewAPIHandler

func NewAPIHandler(db *gorm.DB, clientset kubernetes.Interface, ssoConfig *SSOConfig, serviceIP, dashboard *string) *APIHandler

func (APIHandler) AddCluster

func (h APIHandler) AddCluster(c *gin.Context)

func (APIHandler) AddTFOTaskLogs

func (h APIHandler) AddTFOTaskLogs(c *gin.Context)

func (APIHandler) AddTaskPod

func (h APIHandler) AddTaskPod(c *gin.Context)

func (APIHandler) AllApprovals

func (h APIHandler) AllApprovals(c *gin.Context)

func (APIHandler) Debugger

func (h APIHandler) Debugger(c *gin.Context)

func (APIHandler) GetApprovalStatus

func (h APIHandler) GetApprovalStatus(c *gin.Context)

GetApprovalStatus only looks at the latest resource spec by getting the TFOResource's 'LatestGeneration'. Use the generation to get the TFOResourceSpec and parses the "spec" for the requireApproval value. If the value is "true", this function finds the latest plan task by getting the TaskPod with the highest rerun number. The UUID of the TaskPod is used to lookup the Approval status to return to the caller.

func (APIHandler) GetApprovalStatusViaTaskPodUUID

func (h APIHandler) GetApprovalStatusViaTaskPodUUID(c *gin.Context)

func (APIHandler) GetCluster

func (h APIHandler) GetCluster(c *gin.Context)

func (APIHandler) GetClustersResources

func (h APIHandler) GetClustersResources(c *gin.Context)

func (APIHandler) GetClustersResourcesLogs

func (h APIHandler) GetClustersResourcesLogs(c *gin.Context)

GetClustersResourceLogs will return the latest logs for the selected resource. The only filted allowed in this call is the generation to switch getting the latest logs for a given generation.

func (APIHandler) GetDistinctGeneration

func (h APIHandler) GetDistinctGeneration(c *gin.Context)

func (APIHandler) GetResourceByUUID

func (h APIHandler) GetResourceByUUID(c *gin.Context)

func (APIHandler) GetTFOTaskLogsViaTask

func (h APIHandler) GetTFOTaskLogsViaTask(c *gin.Context)

func (APIHandler) GetTaskPod

func (h APIHandler) GetTaskPod(c *gin.Context)

func (APIHandler) GetUuidByClusterID

func (h APIHandler) GetUuidByClusterID(c *gin.Context)

func (APIHandler) Index

func (h APIHandler) Index(c *gin.Context)

func (APIHandler) LastTaskLog

func (h APIHandler) LastTaskLog(c *gin.Context)

func (APIHandler) LatestGeneration

func (h APIHandler) LatestGeneration(uuid string) string

func (APIHandler) ListClusters

func (h APIHandler) ListClusters(c *gin.Context)

func (APIHandler) LookupResourceSpec

func (h APIHandler) LookupResourceSpec(generation, uuid string) *models.TFOResourceSpec

func (APIHandler) RegisterRoutes

func (h APIHandler) RegisterRoutes()

func (APIHandler) ResourceEvent

func (h APIHandler) ResourceEvent(c *gin.Context)

func (APIHandler) ResourceLogWatcher

func (h APIHandler) ResourceLogWatcher(c *gin.Context)

func (APIHandler) ResourceLogs

func (h APIHandler) ResourceLogs(generationFilter, rerunFilter, taskTypeFilter, uuid string) ([]ResourceLog, error)

func (APIHandler) ResourcePoll

func (h APIHandler) ResourcePoll(c *gin.Context)

ResourcePoll is a short poll that checks and returns resources created from the tf resource's workflow that have the correct label and annotation value.

func (APIHandler) ResourceStatusCheck

func (h APIHandler) ResourceStatusCheck(c *gin.Context)

func (APIHandler) ResourceStatusCheckViaTask

func (h APIHandler) ResourceStatusCheckViaTask(c *gin.Context)

func (APIHandler) SyncEvent

func (h APIHandler) SyncEvent(c *gin.Context)

func (APIHandler) TotalFailedResources

func (h APIHandler) TotalFailedResources(c *gin.Context)

func (APIHandler) TotalResources

func (h APIHandler) TotalResources(c *gin.Context)

func (APIHandler) UpdateApproval

func (h APIHandler) UpdateApproval(c *gin.Context)

UpdateApproval takes the uuid and a JSON data param and create a row in the approval table.

func (APIHandler) UpdateResourceStatusViaTask

func (h APIHandler) UpdateResourceStatusViaTask(c *gin.Context)

func (APIHandler) VClusterHealth

func (h APIHandler) VClusterHealth(c *gin.Context)

func (APIHandler) VClusterTFOHealth

func (h APIHandler) VClusterTFOHealth(c *gin.Context)

type ByCreatedAt

type ByCreatedAt []PodInfo

ByCreatedAt implements sort.Interface for []PodInfo based on the CreatedAt field

func (ByCreatedAt) Len

func (a ByCreatedAt) Len() int

func (ByCreatedAt) Less

func (a ByCreatedAt) Less(i, j int) bool

func (ByCreatedAt) Swap

func (a ByCreatedAt) Swap(i, j int)

type GetApprovalStatusResponseData

type GetApprovalStatusResponseData struct {
	TFOResourceUUID string `json:"tfo_resource_uuid"`
	TaskPodUUID     string `json:"task_pod_uuid"`

	// Status is fuzzy. -1 means it hasn't been decided, 0 is false, 1 is true for the approvals.
	// Hasn't been decided means there is no record in the approvals table matching the uuid.
	Status int `json:"status"`
}

type GetResourceSpecResponseData

type GetResourceSpecResponseData struct {
	models.TFOResourceSpec `json:",inline"`
}

type PodExec

type PodExec struct {
	Closer chan error
	// contains filtered or unexported fields
}

type PodExecFactory struct{}

func New

func New(clientset kubernetes.Interface, clusterName, namespace, name string, c *gin.Context, cmd []string) (*PodExec, error)

command string, argv []string, headers map[string][]string, options ...Option

func (*PodExec) Close

func (p *PodExec) Close() error

func (*PodExec) Read

func (podExec *PodExec) Read(p []byte) (n int, err error)

func (*PodExec) ResizeTerminal

func (p *PodExec) ResizeTerminal(columns int, rows int) error

ResizeTerminal sets a new size of the terminal.

func (*PodExec) WindowTitleVariables

func (p *PodExec) WindowTitleVariables() map[string]interface{}

WindowTitleVariables returns any values that can be used to fill out the title of a terminal.

func (*PodExec) Write

func (podExec *PodExec) Write(p []byte) (n int, err error)

type PodInfo

type PodInfo struct {
	Name      string
	CreatedAt time.Time
}

type ResourceLog

type ResourceLog struct {
	ID              uint   `json:"id"`
	LogMessage      string `json:"message"`
	TaskType        string `json:"task_type"`
	Rerun           int    `json:"rerun"`
	LineNo          string `json:"line_no"`
	TFOResourceUUID string `json:"tfo_resource_uuid"`
}

ResourceLog data contract for clients to consume

type Response

type Response struct {
	StatusInfo StatusInfo  `json:"status_info"`
	Data       interface{} `json:"data"`
}

type SAMLOptions

type SAMLOptions struct {
	// contains filtered or unexported fields
}

type SSOConfig

type SSOConfig struct {
	URL string
	// contains filtered or unexported fields
}

func NewSAMLConfig

func NewSAMLConfig(issuer, recipient, metadataURL string) (*SSOConfig, error)

type SocketListener

type SocketListener struct {
	Connection  *websocket.Conn
	IsListening bool
	EventType   chan int
	Message     []byte
	Err         error
}

func (*SocketListener) Listen

func (s *SocketListener) Listen()

Listen runs a background function and returns a response on the EventType channel.

type StatusCheckResponse

type StatusCheckResponse struct {
	DidStart     bool   `json:"did_start"`
	DidComplete  bool   `json:"did_complete"`
	CurrentState string `json:"current_state"`
	CurrentTask  string `json:"current_task"`
}

type StatusInfo

type StatusInfo struct {
	StatusCode int64  `json:"status_code"`
	Message    string `json:"message"`
}

type TaskLog

type TaskLog struct {
	TaskType string `json:"task_type"`
	UUID     string `json:"uuid"`
	Message  string `json:"message"`
	Rerun    int    `json:"rerun"`
}

type TermSizer

type TermSizer struct {
	SizeCh chan remotecommand.TerminalSize
}

func (TermSizer) Next

Jump to

Keyboard shortcuts

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