Skip to content

Commit

Permalink
clair: change version information
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Mar 6, 2020
1 parent 33b3224 commit 4091329
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

FROM golang:1.14-alpine AS build
RUN apk add --no-cache build-base
ARG CLAIR_VERSION=dev
WORKDIR /build/
ADD . /build/
ARG CLAIR_VERSION=dev
RUN go build \
-mod=vendor \
-ldflags="-X github.com/quay/clair/v4/cmd/clair/main.Version=${CLAIR_VERSION}" \
-ldflags="-X main.Version=${CLAIR_VERSION}" \
./cmd/clair

FROM alpine:3.10 AS final
Expand Down
12 changes: 7 additions & 5 deletions cmd/clair/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import (
"github.com/quay/clair/v4/config"
)

const (
Version = "v4.0.0-rc01"
)
// Version is a version string, optionally injected at build time.
var Version string

func main() {
// parse conf cli
Expand Down Expand Up @@ -62,7 +61,6 @@ func main() {
ctx = log.WithContext(ctx)
logger := log.With().
Str("component", "cmd/clair/main").
Str("version", Version).
Logger()
logfunc := func(_ net.Listener) context.Context {
return ctx
Expand Down Expand Up @@ -125,7 +123,11 @@ func main() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)

logger.Info().Msg("🆙")
up := logger.Info()
if Version != "" {
up = up.Str("version", Version)
}
up.Msg("ready")
// block
select {
case sig := <-c:
Expand Down

0 comments on commit 4091329

Please sign in to comment.