Documentation
¶
Index ¶
- func AddFileToArchive(tarWriter *tar.Writer, filePath, nameInArchive string) error
- func CreateDirectory(dirPath string, perm os.FileMode) error
- func Decrypt(encryptedText string) (string, error)
- func DockerLoginECR(ctx context.Context, region, registryID string) error
- func Encrypt(plaintext string) (string, error)
- func ErrorResponse(ctx *web.Controller, status int, message string, err error)
- func ExistsInArray[T comparable](arr []T, value T) bool
- func ExtractJSON(output string) (map[string]interface{}, error)
- func ExtractJobIDFromWorkflowID(workflowID, projectID string) (int, bool)
- func GetAndValidateLogBaseDir(filePath string) (string, error)
- func GetAndValidateSyncDir(baseDir string) (string, string, error)
- func GetCachedImages(ctx context.Context) ([]string, error)
- func GetDriverImageTags(ctx context.Context, imageName string, cachedTags bool) ([]string, string, error)
- func GetLogArchiveFilename(jobID int, filePath string) (string, error)
- func GetWorkerEnvVars() map[string]string
- func HandleError(w http.ResponseWriter, statusCode int, err error)
- func HandleErrorAsMessage(w http.ResponseWriter, statusCode int, err error)
- func HandleErrorJS(w http.ResponseWriter, r *http.Request, err error)
- func HandleJSONOK(w http.ResponseWriter, content interface{})
- func HandleResponseMessage(w http.ResponseWriter, statusCode int, content interface{}, message string)
- func ParseECRDetails(fullImageName string) (accountID, region, repoName string, err error)
- func ReadLinesBackward(f *os.File, startOffset int64, limit int, fileSize int64) ([]string, int64, bool, error)
- func ReadLinesForward(f *os.File, startOffset int64, limit int, fileSize int64) ([]string, int64, bool, error)
- func ReadLogs(mainLogDir string, cursor int64, limit int, direction string) (*dto.TaskLogsResponse, error)
- func RespondJSON(ctx *web.Controller, status int, success bool, message string, ...)
- func RetryWithBackoff(fn func() error, maxRetries int, initialDelay time.Duration) error
- func SuccessResponse(ctx *web.Controller, message string, data interface{})
- func Ternary(cond bool, a, b any) any
- func ToCron(frequency string) string
- func ToMapOfInterface(structure any) map[string]interface{}
- func ULID() string
- func WriteFile(filePath string, data []byte, perm os.FileMode) error
- type DockerHubTag
- type DockerHubTagsResponse
- type LineWithPos
- type LogEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFileToArchive ¶
addFileToArchive streams a file into the tar archive
func CreateDirectory ¶
CreateDirectory creates a directory with the specified permissions if it doesn't exist
func DockerLoginECR ¶
DockerLoginECR logs in to an AWS ECR repository using the AWS SDK
func ErrorResponse ¶
func ErrorResponse(ctx *web.Controller, status int, message string, err error)
func ExistsInArray ¶
func ExistsInArray[T comparable](arr []T, value T) bool
func ExtractJSON ¶
ExtractJSON extracts and returns the last valid JSON block from output
func ExtractJobIDFromWorkflowID ¶
ExtractJobIDFromWorkflowID extracts the JobID from Temporal workflow IDs created by this system.
Expected workflow ID shapes: - sync-<projectID>-<jobID> - sync-<projectID>-<jobID>-<suffix>
projectID itself can contain '-', so we match the exact prefix and then parse the leading integer.
func GetAndValidateLogBaseDir ¶
GetAndValidateLogBaseDir returns the base directory path for log files based on the SHA256 hash of the filePath (workflow ID) and validates it exists
func GetAndValidateSyncDir ¶
GetAndValidateSyncDir returns the logs directory and sync_* folder name under it
func GetCachedImages ¶
GetCachedImages retrieves locally cached Docker images
func GetDriverImageTags ¶
func GetDriverImageTags(ctx context.Context, imageName string, cachedTags bool) ([]string, string, error)
GetDriverImageTags returns image tags from ECR or Docker Hub with fallback to cached images
func GetLogArchiveFilename ¶
GetLogArchiveFilename generates the filename for the log archive download
func GetWorkerEnvVars ¶
GetWorkerEnvVars returns the environment variables from the worker container.
func HandleError ¶
func HandleError(w http.ResponseWriter, statusCode int, err error)
send error as direct text/string
func HandleErrorAsMessage ¶
func HandleErrorAsMessage(w http.ResponseWriter, statusCode int, err error)
send error as json response
func HandleErrorJS ¶
func HandleErrorJS(w http.ResponseWriter, r *http.Request, err error)
Handle errors and pass it to /error page
func HandleJSONOK ¶
func HandleJSONOK(w http.ResponseWriter, content interface{})
func HandleResponseMessage ¶
func HandleResponseMessage(w http.ResponseWriter, statusCode int, content interface{}, message string)
send a message as response
func ParseECRDetails ¶
ParseECRDetails extracts account ID, region, and repository name from ECR URI Example:
Input: "123456789012.dkr.ecr.us-west-2.amazonaws.com/olakego/source-mysql:latest"
Output: accountID = "123456789012"
region = "us-west-2"
repoName = "olakego/source-mysql:latest"
func ReadLinesBackward ¶
func ReadLinesBackward(f *os.File, startOffset int64, limit int, fileSize int64) ([]string, int64, bool, error)
ReadLinesBackward reads up to `limit` complete VALID log lines from file backwards starting at startOffset. Filters out empty lines, invalid JSON, and debug-level logs DURING reading. startOffset is treated as exclusive - we read lines that END BEFORE startOffset. Returns: valid lines (oldest->newest), newOffset (byte position before first returned line), hasMore, error.
func ReadLinesForward ¶
func ReadLinesForward(f *os.File, startOffset int64, limit int, fileSize int64) ([]string, int64, bool, error)
ReadLinesForward reads up to `limit` complete VALID log lines from file forwards starting at startOffset. Filters out empty lines, invalid JSON, and debug-level logs DURING reading. startOffset is treated as inclusive - we start reading from exactly that position. Returns: valid lines (oldest->newest), newOffset (byte position after last returned line), hasMore, error.
func ReadLogs ¶
func ReadLogs(mainLogDir string, cursor int64, limit int, direction string) (*dto.TaskLogsResponse, error)
ReadLogs reads logs from the given mainLogDir and returns structured log entries. Direction can be "older" or "newer". If cursor < 0, it tails from the end of the file. Returns a TaskLogsResponse-like struct: oldest->newest logs plus cursors and hasMore flags.
func RespondJSON ¶
func RespondJSON(ctx *web.Controller, status int, success bool, message string, data interface{})
func RetryWithBackoff ¶
RetryWithBackoff retries a function with exponential backoff
func SuccessResponse ¶
func SuccessResponse(ctx *web.Controller, message string, data interface{})
func ToMapOfInterface ¶
Types ¶
type DockerHubTag ¶
type DockerHubTag struct {
Name string `json:"name"`
}
DockerHubTag represents a single tag from Docker Hub API response
type DockerHubTagsResponse ¶
type DockerHubTagsResponse struct {
Results []DockerHubTag `json:"results"`
}
DockerHubTagsResponse represents the response structure from Docker Hub tags API
type LineWithPos ¶
type LineWithPos struct {
// contains filtered or unexported fields
}