Documentation
¶
Index ¶
- Variables
- func GetApiURL(c *gin.Context, serviceIP *string) string
- func IsWorkflowRunning(status tfv1beta1.TerraformStatus) bool
- func NewTaskToken(db *gorm.DB, tfoResourceSpec models.TFOResourceSpec, ...) (*string, error)
- func NewTaskTokenFromRefreshToken(db *gorm.DB, refreshToken, apiURL string, clientset kubernetes.Interface) (string, error)
- func RemoteDebug(parentClientset kubernetes.Interface, clusterName, namespace, name string, ...) error
- func Reverse[T any](input []T) []T
- type APIHandler
- func (h APIHandler) AddCluster(c *gin.Context)
- func (h APIHandler) AddTaskPod(c *gin.Context)
- func (h APIHandler) AllApprovals(c *gin.Context)
- func (h APIHandler) Debugger(c *gin.Context)
- func (h APIHandler) GetApprovalStatus(c *gin.Context)
- func (h APIHandler) GetApprovalStatusViaTaskPodUUID(c *gin.Context)
- func (h APIHandler) GetCluster(c *gin.Context)
- func (h APIHandler) GetClustersResources(c *gin.Context)
- func (h APIHandler) GetClustersResourcesLogs(c *gin.Context)
- func (h APIHandler) GetDistinctGeneration(c *gin.Context)
- func (h APIHandler) GetResourceByUUID(c *gin.Context)
- func (h APIHandler) GetTFOTaskLogsViaTask(c *gin.Context)
- func (h APIHandler) GetTaskPod(c *gin.Context)
- func (h APIHandler) GetUuidByClusterID(c *gin.Context)
- func (h APIHandler) Index(c *gin.Context)
- func (h APIHandler) LastTaskLog(c *gin.Context)
- func (h APIHandler) LatestGeneration(uuid string) string
- func (h APIHandler) ListClusters(c *gin.Context)
- func (h APIHandler) LookupResourceSpec(generation, uuid string) *models.TFOResourceSpec
- func (h APIHandler) RegisterRoutes()
- func (h APIHandler) ResourceEvent(c *gin.Context)
- func (h APIHandler) ResourceLogWatcher(c *gin.Context)
- func (h APIHandler) ResourceLogs(generationFilter, rerunFilter, taskTypeFilter, uuid string) ([]ResourceLog, error)
- func (h APIHandler) ResourcePoll(c *gin.Context)
- func (h APIHandler) ResourceStatusCheck(c *gin.Context)
- func (h APIHandler) ResourceStatusCheckViaTask(c *gin.Context)
- func (h APIHandler) SyncEvent(c *gin.Context)
- func (h APIHandler) TotalFailedResources(c *gin.Context)
- func (h APIHandler) TotalResources(c *gin.Context)
- func (h APIHandler) UnlockTerraform(c *gin.Context)
- func (h APIHandler) UpdateApproval(c *gin.Context)
- func (h APIHandler) UpdateResourceStatusViaTask(c *gin.Context)
- func (h APIHandler) VClusterHealth(c *gin.Context)
- func (h APIHandler) VClusterTFOHealth(c *gin.Context)
- type ByCreatedAt
- type GetApprovalStatusResponseData
- type GetResourceSpecResponseData
- type PodExec
- type PodInfo
- type ResourceLog
- type Response
- type SAMLOptions
- type SSOConfig
- type SocketListener
- type StatusCheckResponse
- type StatusInfo
- type TaskLog
- type TermSizer
Constants ¶
This section is empty.
Variables ¶
var VCLUSTER_DEBUG_HOST string = os.Getenv("TFO_API_VCLUSTER_DEBUG_HOST")
Functions ¶
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 NewTaskToken ¶
func NewTaskToken(db *gorm.DB, tfoResourceSpec models.TFOResourceSpec, _tenantID, clusterName, apiURL string, clientset kubernetes.Interface) (*string, error)
Generate a new JWT Token and Refresh Token. Saves the token into the database and creats a Secret in the tasks namespace inside the vcluster. The secrets is to be used with envFrom inside the task pods.
The generated name is the resourceName + "-jwt".
func RemoteDebug ¶
func RemoteDebug(parentClientset kubernetes.Interface, clusterName, namespace, name string, tty *os.File, c *gin.Context, terminalSizeQueue remotecommand.TerminalSizeQueue, cmd, execCommand []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.
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, fswatchImage string) *APIHandler
func (APIHandler) AddCluster ¶
func (h APIHandler) AddCluster(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) UnlockTerraform ¶
func (h APIHandler) UnlockTerraform(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 (*PodExec) ResizeTerminal ¶
ResizeTerminal sets a new size of the terminal.
func (*PodExec) WindowTitleVariables ¶
WindowTitleVariables returns any values that can be used to fill out the title of a terminal.
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 ¶
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 StatusInfo ¶
type TermSizer ¶
type TermSizer struct {
SizeCh chan remotecommand.TerminalSize
}
func (TermSizer) Next ¶
func (t TermSizer) Next() *remotecommand.TerminalSize