Documentation
¶
Index ¶
- Variables
- func AddFileToArchive(tarWriter *tar.Writer, filePath, nameInArchive string) error
- func BuildReleasesResponse(currentVersion, olakeSourceVersion string, ...) (*dto.ReleasesResponse, error)
- func CreateDirectory(dirPath string, perm os.FileMode) error
- func Decrypt(encryptedText string) (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 FetchAndBuildReleaseMetadata(ctx context.Context, repo, releaseType string, limit int) ([]*dto.ReleaseMetadataResponse, error)
- func FetchFeaturesJSON(ctx context.Context) ([]*dto.ReleaseMetadataResponse, error)
- 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 MergeReleaseDescriptions(primary *dto.ReleaseTypeData, primaryTitle string, ...) *dto.ReleaseTypeData
- func ParseECRDetails(fullImageName string) (accountID, region, repoName string, err error)
- func ParseGCRArtifactRegistryDetails(fullImageName string) (project, location, repository, packageName 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 GitHubRelease
- type GithubReleaseSource
- type LineWithPos
- type LogEntry
- type ReleaseType
Constants ¶
This section is empty.
Variables ¶
var ReleaseSources = []GithubReleaseSource{ {Type: ReleaseOlakeUI, Repo: "olake-ui", OnlyNewerReleases: true}, {Type: ReleaseWorker, Repo: "olake-helm", OnlyNewerReleases: true}, {Type: ReleaseOlakeHelm, Repo: "olake-helm"}, {Type: ReleaseOlake, Repo: "olake", OnlyNewerReleases: true}, }
ReleaseSources defines the list of GitHub repositories to fetch releases from.
Functions ¶
func AddFileToArchive ¶
addFileToArchive streams a file into the tar archive
func BuildReleasesResponse ¶
func BuildReleasesResponse(currentVersion, olakeSourceVersion string, fetched map[ReleaseType][]*dto.ReleaseMetadataResponse) (*dto.ReleasesResponse, error)
BuildReleasesResponse builds the final releases response from fetched data. currentVersion is used for olake-ui and worker releases. olakeSourceVersion is used for olake source releases (minimum version from database).
func CreateDirectory ¶
CreateDirectory creates a directory with the specified permissions if it doesn't exist
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 FetchAndBuildReleaseMetadata ¶
func FetchAndBuildReleaseMetadata(ctx context.Context, repo, releaseType string, limit int) ([]*dto.ReleaseMetadataResponse, error)
FetchAndBuildReleaseMetadata fetches GitHub releases and converts them into normalized, sorted ReleaseMetadataResponse objects.
func FetchFeaturesJSON ¶
func FetchFeaturesJSON(ctx context.Context) ([]*dto.ReleaseMetadataResponse, error)
FetchFeaturesJSON fetches the features.json file from GitHub.
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, Artifact Registry, 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 MergeReleaseDescriptions ¶
func MergeReleaseDescriptions(primary *dto.ReleaseTypeData, primaryTitle string, secondary *dto.ReleaseTypeData, secondaryTitle string) *dto.ReleaseTypeData
MergeReleaseDescriptions merges secondary release notes into primary by version.
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 ParseGCRArtifactRegistryDetails ¶
func ParseGCRArtifactRegistryDetails(fullImageName string) (project, location, repository, packageName string, err error)
ParseGCRArtifactRegistryDetails extracts project, location, repository, and package name from an Artifact Registry Docker image URI.
Example:
Input: "us-docker.pkg.dev/my-project/my-repo/olakego/source-mysql:v1.0.0"
Output: project = "my-project"
location = "us"
repository = "my-repo"
packageName = "olakego/source-mysql"
The package name is URL-encoded for the API (e.g., "olakego%2Fsource-mysql")
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 GitHubRelease ¶
type GitHubRelease struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
Body string `json:"body"`
PublishedAt time.Time `json:"published_at"`
HTMLURL string `json:"html_url"`
Prerelease bool `json:"prerelease"`
Draft bool `json:"draft"`
}
GitHubRelease represents a release from GitHub API response.
type GithubReleaseSource ¶
type GithubReleaseSource struct {
Type ReleaseType
Repo string
OnlyNewerReleases bool
}
GithubReleaseSource represents a GitHub repository source for fetching releases. It defines the release type, repository name, and whether to filter only newer releases.
type LineWithPos ¶
type LineWithPos struct {
// contains filtered or unexported fields
}
type LogEntry ¶
type LogEntry struct {
Level string `json:"level"`
Time time.Time `json:"time"`
Message json.RawMessage `json:"message"` // store raw JSON
}
LogEntry represents a log entry
type ReleaseType ¶
type ReleaseType string
ReleaseType represents the type of release source.
const ( ReleaseOlakeUI ReleaseType = "olake_ui" ReleaseWorker ReleaseType = "worker" ReleaseOlakeHelm ReleaseType = "olake_helm" ReleaseOlake ReleaseType = "olake" ReleaseFeatures ReleaseType = "features" )