Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ function build_and_run() {
cd $path || fail "Failed to navigate to path: $path"

go mod tidy
go build -ldflags="-w -s -X constants/constants.version=${GIT_VERSION} -X constants/constants.commitsha=${GIT_COMMITSHA} -X constants/constants.releasechannel=${RELEASE_CHANNEL}" -o olake main.go || fail "build failed"
go build -ldflags="-w -s -X github.com/datazip-inc/olake/constants.version=${GIT_VERSION} -X github.com/datazip-inc/olake/constants.commitSHA=${GIT_COMMITSHA} -X github.com/datazip-inc/olake/constants.releaseChannel=${RELEASE_CHANNEL}" -o olake main.go || fail "build failed"
echo "============================== Executing connector: $connector with args [$joined_arguments] =============================="
./olake $joined_arguments
}
Expand Down
32 changes: 32 additions & 0 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,41 @@ package constants

import (
"fmt"
"os"
"time"
)

// Build-time version information, injected via ldflags.
// Defaults are used when running locally without build flags.
var (
version = "dev"
commitSHA = "unknown"
releaseChannel = "dev"
)

// GetVersion returns the OLake build version. It first checks the build-time
// injected variable, then falls back to the DRIVER_VERSION environment variable
// (set in Docker images), and finally returns "dev" if neither is available.
func GetVersion() string {
if version != "" && version != "dev" {
return version
}
if v := os.Getenv("DRIVER_VERSION"); v != "" {
return v
}
return "dev"
}

// GetCommitSHA returns the git commit SHA used for the build.
func GetCommitSHA() string {
return commitSHA
}

// GetReleaseChannel returns the release channel (e.g., stable, beta, dev).
func GetReleaseChannel() string {
return releaseChannel
}

const (
DefaultRetryCount = 3
DefaultThreadCount = 3
Expand Down
1 change: 1 addition & 0 deletions protocol/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var RootCmd = &cobra.Command{

// logger uses CONFIG_FOLDER
logger.Init()
logger.Infof("OLake version: %s (commit: %s, channel: %s)", constants.GetVersion(), constants.GetCommitSHA(), constants.GetReleaseChannel())
telemetry.Init()

if len(args) == 0 {
Expand Down
9 changes: 3 additions & 6 deletions utils/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,8 @@ func countPartitionedStreams(catalog *types.Catalog) int {
return count
}

// getOlakeCLIVersion() extracts the olake version from the ENV embedded in the olake image
// getOlakeCLIVersion returns the OLake CLI version using the centralized
// version resolution from the constants package.
func getOlakeCLIVersion() string {
version := os.Getenv("DRIVER_VERSION")
if version == "" {
return "Not Available"
}
return version
return constants.GetVersion()
}