Skip to content

Commit

Permalink
Add --version flag (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
peimanja authored May 23, 2022
1 parent da6e5da commit 1cb07ed
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ jobs:
SOURCE_COMMIT=${{ github.sha }}
SOURCE_BRANCH=${{ github.ref }}
BUILD_DATE=${{ steps.date.outputs.value }}
BUILD_USER=github-actions
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
goos: darwin
steps:
- uses: actions/checkout@v2
- id: date
run: echo "::set-output name=value::$(date +%FT%TZ)"
- uses: wangyoucao577/go-release-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -27,4 +29,5 @@ jobs:
-X github.com/prometheus/common/version.Version=${{ github.event.release.tag_name }}
-X github.com/prometheus/common/version.Revision=${{ github.sha }}
-X github.com/prometheus/common/version.Branch=${{ github.ref }}
-X github.com/prometheus/common/version.BuildDate=${{ github.event.release.created_at }}
-X github.com/prometheus/common/version.BuildDate=${{ steps.date.outputs.value }}
-X github.com/prometheus/common/version.BuildUser=github-actions
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ ARG VERSION
ARG SOURCE_COMMIT
ARG SOURCE_BRANCH
ARG BUILD_DATE
ARG BUILD_USER

RUN GOOS=linux GOARCH=amd64 go build -o /go/bin/artifactory_exporter -ldflags " \
-X github.com/prometheus/common/version.Version=${VERSION} \
-X github.com/prometheus/common/version.Revision=${SOURCE_COMMIT} \
-X github.com/prometheus/common/version.Branch=${SOURCE_BRANCH} \
-X github.com/prometheus/common/version.BuildDate=${BUILD_DATE}"
-X github.com/prometheus/common/version.BuildDate=${BUILD_DATE} \
-X github.com/prometheus/common/version.BuildUser=${BUILD_USER}"

FROM gcr.io/distroless/base-debian11
COPY --from=build /go/bin/artifactory_exporter /
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# JFrog Artifactory Exporter
# JFrog Artifactory Exporter

[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/peimanja/artifactory_exporter/Build)](https://github.com/peimanja/artifactory_exporter/actions) [![Docker Build](https://img.shields.io/docker/cloud/build/peimanja/artifactory_exporter)](https://hub.docker.com/r/peimanja/artifactory_exporter/builds) [![Go Report Card](https://goreportcard.com/badge/github.com/peimanja/artifactory_exporter)](https://goreportcard.com/report/github.com/peimanja/artifactory_exporter)

A [Prometheus](https://prometheus.io) exporter for [JFrog Artifactory](https://jfrog.com/artifactory) stats.
A [Prometheus](https://prometheus.io) exporter for [JFrog Artifactory](https://jfrog.com/artifactory) stats.


## Note
Expand Down Expand Up @@ -117,6 +117,7 @@ Flags:
--artifactory.timeout=5s Timeout for trying to get stats from JFrog Artifactory.
--log.level=info Only log messages with the given severity or above. One of: [debug, info, warn, error]
--log.format=logfmt Output format of log messages. One of: [logfmt, json]
--version Show application version.
```

| Flag / Environment Variable | Required | Default | Description |
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/kelseyhightower/envconfig"
"github.com/prometheus/common/promlog"
"github.com/prometheus/common/promlog/flag"
"github.com/prometheus/common/version"
"gopkg.in/alecthomas/kingpin.v2"
)

Expand Down Expand Up @@ -46,6 +47,7 @@ func NewConfig() (*Config, error) {
promlogConfig := &promlog.Config{}
flag.AddFlags(kingpin.CommandLine, promlogConfig)
kingpin.HelpFlag.Short('h')
kingpin.Version(version.Info() + " " + version.BuildContext())
kingpin.Parse()
logger := promlog.New(promlogConfig)

Expand Down

0 comments on commit 1cb07ed

Please sign in to comment.