Skip to content

Commit

Permalink
Merge pull request #25 from hlts2/fix/set-driver-version-info
Browse files Browse the repository at this point in the history
Set driver version in the binary based on release version
  • Loading branch information
Praveen005 authored Nov 6, 2024
2 parents 3d6898a + 639b13f commit ccf133c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN go mod verify
RUN find .

# Build the binary.
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s -X github.com/civo/civo-csi/driver.CSIVersion=${VERSION}" -o /app/civo-csi
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s -X github.com/civo/civo-csi/pkg/driver.Version=${VERSION}" -o /app/civo-csi


############################
Expand Down
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"flag"
"os"
"os/signal"
"strings"
Expand All @@ -13,10 +14,20 @@ import (
"github.com/rs/zerolog/log"
)

var (
versionInfo = flag.Bool("version", false, "Print the driver version")
)

func main() {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})

flag.Parse()
if *versionInfo {
log.Info().Str("version", driver.Version).Msg("CSI driver")
return
}

apiURL := strings.TrimSpace(os.Getenv("CIVO_API_URL"))
apiKey := strings.TrimSpace(os.Getenv("CIVO_API_KEY"))
region := strings.TrimSpace(os.Getenv("CIVO_REGION"))
Expand Down
7 changes: 2 additions & 5 deletions pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ import (
"google.golang.org/grpc"
)

// CSIVersion is the version of the csi to set in the User-Agent header
var CSIVersion = "dev"

// Name is the name of the driver
const Name string = "Civo CSI Driver"

// Version is the current release of the driver
const Version string = "0.0.1"
// Version is the current version of the driver to set in the User-Agent header
var Version string = "0.0.1"

// DefaultVolumeSizeGB is the default size in Gigabytes of an unspecified volume
const DefaultVolumeSizeGB int = 10
Expand Down

0 comments on commit ccf133c

Please sign in to comment.